From f2296a21854625de550ace04caef282a53aa8699 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 10 Jun 2015 13:07:40 -0700 Subject: [PATCH] Bug 1171830 - Remove PL_DHashTableEnumerator use from nsDocLoader. r=smaug. --HG-- extra : rebase_source : 9887a36a6c83e81a429b45c36aa9d151793c6b41 --- uriloader/base/nsDocLoader.cpp | 40 +++++++++------------------------- uriloader/base/nsDocLoader.h | 3 --- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index 240c817570ab..cd85b439635c 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -1343,43 +1343,23 @@ nsDocLoader::nsRequestInfo* nsDocLoader::GetRequestInfo(nsIRequest* aRequest) (PL_DHashTableSearch(&mRequestInfoHash, aRequest)); } -// PLDHashTable enumeration callback that just removes every entry -// from the hash. -static PLDHashOperator -RemoveInfoCallback(PLDHashTable *table, PLDHashEntryHdr *hdr, uint32_t number, - void *arg) -{ - return PL_DHASH_REMOVE; -} - void nsDocLoader::ClearRequestInfoHash(void) { - PL_DHashTableEnumerate(&mRequestInfoHash, RemoveInfoCallback, nullptr); -} - -// PLDHashTable enumeration callback that calculates the max progress. -PLDHashOperator -nsDocLoader::CalcMaxProgressCallback(PLDHashTable* table, PLDHashEntryHdr* hdr, - uint32_t number, void* arg) -{ - const nsRequestInfo* info = static_cast(hdr); - int64_t* max = static_cast(arg); - - if (info->mMaxProgress < info->mCurrentProgress) { - *max = int64_t(-1); - - return PL_DHASH_STOP; - } - - *max += info->mMaxProgress; - - return PL_DHASH_NEXT; + mRequestInfoHash.Clear(); } int64_t nsDocLoader::CalculateMaxProgress() { int64_t max = mCompletedTotalProgress; - PL_DHashTableEnumerate(&mRequestInfoHash, CalcMaxProgressCallback, &max); + PLDHashTable::Iterator iter(&mRequestInfoHash); + while (iter.HasMoreEntries()) { + auto info = static_cast(iter.NextEntry()); + + if (info->mMaxProgress < info->mCurrentProgress) { + return int64_t(-1); + } + max += info->mMaxProgress; + } return max; } diff --git a/uriloader/base/nsDocLoader.h b/uriloader/base/nsDocLoader.h index 087d57641df8..49521c6edbe8 100644 --- a/uriloader/base/nsDocLoader.h +++ b/uriloader/base/nsDocLoader.h @@ -324,9 +324,6 @@ private: nsRequestInfo *GetRequestInfo(nsIRequest* aRequest); void ClearRequestInfoHash(); int64_t CalculateMaxProgress(); - static PLDHashOperator CalcMaxProgressCallback(PLDHashTable* table, - PLDHashEntryHdr* hdr, - uint32_t number, void* arg); /// void DumpChannelInfo(void); // used to clear our internal progress state between loads...