Bug 1171830 - Remove PL_DHashTableEnumerator use from nsDocLoader. r=smaug.

--HG--
extra : rebase_source : 9887a36a6c83e81a429b45c36aa9d151793c6b41
This commit is contained in:
Nicholas Nethercote 2015-06-10 13:07:40 -07:00
parent 1e87b534d2
commit f2296a2185
2 changed files with 10 additions and 33 deletions

View File

@ -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<const nsRequestInfo*>(hdr);
int64_t* max = static_cast<int64_t* >(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<const nsRequestInfo*>(iter.NextEntry());
if (info->mMaxProgress < info->mCurrentProgress) {
return int64_t(-1);
}
max += info->mMaxProgress;
}
return max;
}

View File

@ -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...