mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1187134 (part 4) - Replace nsBaseHashtable::Enumerate() calls in netwerk/cache{,2}/ with iterators. r=valentin.
--HG-- extra : rebase_source : 0d62ad6d5e6cad0d4202cb58ec77890e3213cecf
This commit is contained in:
parent
2e1080a108
commit
edfdcd39d9
@ -882,7 +882,7 @@ CacheFile::ThrowMemoryCachedData()
|
||||
|
||||
// We cannot release all cached chunks since we need to keep preloaded chunks
|
||||
// in memory. See initialization of mPreloadChunkCount for explanation.
|
||||
mCachedChunks.Enumerate(&CacheFile::CleanUpCachedChunks, this);
|
||||
CleanUpCachedChunks();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1587,7 +1587,7 @@ CacheFile::RemoveInput(CacheFileInputStream *aInput, nsresult aStatus)
|
||||
|
||||
// If the input didn't read all data, there might be left some preloaded
|
||||
// chunks that won't be used anymore.
|
||||
mCachedChunks.Enumerate(&CacheFile::CleanUpCachedChunks, this);
|
||||
CleanUpCachedChunks();
|
||||
|
||||
Telemetry::Accumulate(Telemetry::NETWORK_CACHE_V2_INPUT_STREAM_STATUS,
|
||||
StatusToTelemetryEnum(aStatus));
|
||||
@ -1895,23 +1895,24 @@ CacheFile::FailUpdateListeners(
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
PLDHashOperator
|
||||
CacheFile::CleanUpCachedChunks(const uint32_t& aIdx,
|
||||
RefPtr<CacheFileChunk>& aChunk,
|
||||
void* aClosure)
|
||||
void
|
||||
CacheFile::CleanUpCachedChunks()
|
||||
{
|
||||
CacheFile *file = static_cast<CacheFile*>(aClosure);
|
||||
for (auto iter = mCachedChunks.Iter(); !iter.Done(); iter.Next()) {
|
||||
uint32_t idx = iter.Key();
|
||||
const RefPtr<CacheFileChunk>& chunk = iter.Data();
|
||||
|
||||
LOG(("CacheFile::CleanUpCachedChunks() [this=%p, idx=%u, chunk=%p]", file,
|
||||
aIdx, aChunk.get()));
|
||||
LOG(("CacheFile::CleanUpCachedChunks() [this=%p, idx=%u, chunk=%p]", this,
|
||||
idx, chunk.get()));
|
||||
|
||||
if (file->MustKeepCachedChunk(aIdx)) {
|
||||
if (MustKeepCachedChunk(idx)) {
|
||||
LOG(("CacheFile::CleanUpCachedChunks() - Keeping chunk"));
|
||||
return PL_DHASH_NEXT;
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG(("CacheFile::CleanUpCachedChunks() - Removing chunk"));
|
||||
return PL_DHASH_REMOVE;
|
||||
iter.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -173,9 +173,7 @@ private:
|
||||
RefPtr<CacheFileChunk>& aChunk,
|
||||
void* aClosure);
|
||||
|
||||
static PLDHashOperator CleanUpCachedChunks(const uint32_t& aIdx,
|
||||
RefPtr<CacheFileChunk>& aChunk,
|
||||
void* aClosure);
|
||||
void CleanUpCachedChunks();
|
||||
|
||||
nsresult PadChunkWithZeroes(uint32_t aChunkIdx);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user