From 6b325628dd807879552b03baebe06265ffecf2ef Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Sun, 30 Sep 2007 21:34:56 +0000 Subject: [PATCH] Bug 392873. Add debugging code to help track down a crash in the bfcache-expiry code. r+sr=bzbarsky,a=damon git-svn-id: svn://10.0.0.236/trunk@236961 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/shistory/src/nsSHEntry.cpp | 8 +++++++ mozilla/xpcom/ds/nsExpirationTracker.h | 23 +++++++++++++++++++++ 2 files changed, 31 insertions(+) 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: /**