mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-22 12:04:38 +00:00
Bug 1171830 - Remove PL_DHashTableEnumerator use from nsDocLoader. r=smaug.
--HG-- extra : rebase_source : 9887a36a6c83e81a429b45c36aa9d151793c6b41
This commit is contained in:
parent
1e87b534d2
commit
f2296a2185
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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...
|
||||
|
Loading…
x
Reference in New Issue
Block a user