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
This commit is contained in:
roc+%cs.cmu.edu
2007-09-30 21:34:56 +00:00
parent 8e8ebb375c
commit 6b325628dd
2 changed files with 31 additions and 0 deletions

View File

@@ -160,6 +160,14 @@ nsSHEntry::~nsSHEntry()
if (viewer) {
viewer->Destroy();
}
#ifdef DEBUG
nsExpirationTracker<nsSHEntry,3>::Iterator iterator(gHistoryTracker);
nsSHEntry* elem;
while ((elem = iterator.Next()) != nsnull) {
NS_ASSERTION(elem != this, "Found dead entry still in the tracker!");
}
#endif
}
//*****************************************************************************

View File

@@ -234,6 +234,29 @@ template <class T, PRUint32 K> class nsExpirationTracker {
AgeOneGeneration();
}
}
class Iterator {
private:
nsExpirationTracker<T,K>* mTracker;
PRUint32 mGeneration;
PRUint32 mIndex;
public:
Iterator(nsExpirationTracker<T,K>* aTracker)
: mTracker(aTracker), mGeneration(0), mIndex(0) {}
T* Next() {
while (mGeneration < K) {
nsTArray<T*>* generation = &mTracker->mGenerations[mGeneration];
if (mIndex < generation->Length()) {
++mIndex;
return (*generation)[mIndex - 1];
}
++mGeneration;
}
return nsnull;
}
};
friend class Iterator;
protected:
/**