Bug 1187151 (part 2) - Replace nsBaseHashtable::Enumerate() calls in dom/base/ with iterators. r=janv.

This commit is contained in:
Nicholas Nethercote 2015-11-13 00:25:28 -08:00
parent 424a9ed0d9
commit 28cfa4194e
2 changed files with 19 additions and 29 deletions

View File

@ -2526,35 +2526,30 @@ QuotaManager::UpdateOriginAccessTime(PersistenceType aPersistenceType,
}
}
// static
PLDHashOperator
QuotaManager::RemoveQuotaCallback(const nsACString& aKey,
nsAutoPtr<GroupInfoPair>& aValue,
void* aUserArg)
{
NS_ASSERTION(!aKey.IsEmpty(), "Empty key!");
NS_ASSERTION(aValue, "Null pointer!");
RefPtr<GroupInfo> groupInfo =
aValue->LockedGetGroupInfo(PERSISTENCE_TYPE_TEMPORARY);
if (groupInfo) {
groupInfo->LockedRemoveOriginInfos();
}
groupInfo = aValue->LockedGetGroupInfo(PERSISTENCE_TYPE_DEFAULT);
if (groupInfo) {
groupInfo->LockedRemoveOriginInfos();
}
return PL_DHASH_REMOVE;
}
void
QuotaManager::RemoveQuota()
{
MutexAutoLock lock(mQuotaMutex);
mGroupInfoPairs.Enumerate(RemoveQuotaCallback, nullptr);
for (auto iter = mGroupInfoPairs.Iter(); !iter.Done(); iter.Next()) {
nsAutoPtr<GroupInfoPair>& pair = iter.Data();
MOZ_ASSERT(!iter.Key().IsEmpty(), "Empty key!");
MOZ_ASSERT(pair, "Null pointer!");
RefPtr<GroupInfo> groupInfo =
pair->LockedGetGroupInfo(PERSISTENCE_TYPE_TEMPORARY);
if (groupInfo) {
groupInfo->LockedRemoveOriginInfos();
}
groupInfo = pair->LockedGetGroupInfo(PERSISTENCE_TYPE_DEFAULT);
if (groupInfo) {
groupInfo->LockedRemoveOriginInfos();
}
iter.Remove();
}
NS_ASSERTION(mTemporaryStorageUsage == 0, "Should be zero!");
}

View File

@ -461,11 +461,6 @@ private:
const nsACString& aOrigin,
nsAutoCString& _retval);
static PLDHashOperator
RemoveQuotaCallback(const nsACString& aKey,
nsAutoPtr<GroupInfoPair>& aValue,
void* aUserArg);
mozilla::Mutex mQuotaMutex;
nsClassHashtable<nsCStringHashKey, GroupInfoPair> mGroupInfoPairs;