diff --git a/mozilla/docshell/shistory/src/nsSHEntry.cpp b/mozilla/docshell/shistory/src/nsSHEntry.cpp index 32a8bc87afa..4e8b015ee6b 100644 --- a/mozilla/docshell/shistory/src/nsSHEntry.cpp +++ b/mozilla/docshell/shistory/src/nsSHEntry.cpp @@ -160,6 +160,14 @@ nsSHEntry::~nsSHEntry() if (viewer) { viewer->Destroy(); } + +#ifdef DEBUG + nsExpirationTracker::Iterator iterator(gHistoryTracker); + nsSHEntry* elem; + while ((elem = iterator.Next()) != nsnull) { + NS_ASSERTION(elem != this, "Found dead entry still in the tracker!"); + } +#endif } //***************************************************************************** diff --git a/mozilla/xpcom/ds/nsExpirationTracker.h b/mozilla/xpcom/ds/nsExpirationTracker.h index 0c88a391232..c006fc4f479 100644 --- a/mozilla/xpcom/ds/nsExpirationTracker.h +++ b/mozilla/xpcom/ds/nsExpirationTracker.h @@ -234,6 +234,29 @@ template class nsExpirationTracker { AgeOneGeneration(); } } + + class Iterator { + private: + nsExpirationTracker* mTracker; + PRUint32 mGeneration; + PRUint32 mIndex; + public: + Iterator(nsExpirationTracker* aTracker) + : mTracker(aTracker), mGeneration(0), mIndex(0) {} + T* Next() { + while (mGeneration < K) { + nsTArray* generation = &mTracker->mGenerations[mGeneration]; + if (mIndex < generation->Length()) { + ++mIndex; + return (*generation)[mIndex - 1]; + } + ++mGeneration; + } + return nsnull; + } + }; + + friend class Iterator; protected: /**