Bug 1187152 (part 1) - Replace nsBaseHashtable::Enumerate() calls in modules/ with iterators. r=mwu.

This commit is contained in:
Nicholas Nethercote 2015-11-22 18:52:40 -08:00
parent f01997aef8
commit d71cb426cd

View File

@ -1331,16 +1331,6 @@ nsZipReaderCache::ReleaseZip(nsJAR* zip)
return NS_OK;
}
static PLDHashOperator
FindFlushableZip(const nsACString &aKey, RefPtr<nsJAR>& aCurrent, void*)
{
if (aCurrent->GetReleaseTime() != PR_INTERVAL_NO_TIMEOUT) {
aCurrent->SetZipReaderCache(nullptr);
return PL_DHASH_REMOVE;
}
return PL_DHASH_NEXT;
}
NS_IMETHODIMP
nsZipReaderCache::Observe(nsISupports *aSubject,
const char *aTopic,
@ -1348,7 +1338,13 @@ nsZipReaderCache::Observe(nsISupports *aSubject,
{
if (strcmp(aTopic, "memory-pressure") == 0) {
MutexAutoLock lock(mLock);
mZips.Enumerate(FindFlushableZip, nullptr);
for (auto iter = mZips.Iter(); !iter.Done(); iter.Next()) {
RefPtr<nsJAR>& current = iter.Data();
if (current->GetReleaseTime() != PR_INTERVAL_NO_TIMEOUT) {
current->SetZipReaderCache(nullptr);
iter.Remove();
}
}
}
else if (strcmp(aTopic, "chrome-flush-caches") == 0) {
MutexAutoLock lock(mLock);