void DOMStorageManager::ClearCaches(uint32_t aUnloadFlags, const OriginAttributesPattern& aPattern, const nsACString& aOriginScope) { for (auto iter1 = mCaches.Iter(); !iter1.Done(); iter1.Next()) { PrincipalOriginAttributes oa; DebugOnly<bool> rv = oa.PopulateFromSuffix(iter1.Key()); MOZ_ASSERT(rv); if (!aPattern.Matches(oa)) { // This table doesn't match the given origin attributes pattern continue; } CacheOriginHashtable* table = iter1.Data(); for (auto iter2 = table->Iter(); !iter2.Done(); iter2.Next()) { DOMStorageCache* cache = iter2.Get()->cache(); if (aOriginScope.IsEmpty() || StringBeginsWith(cache->OriginNoSuffix(), aOriginScope)) { cache->UnloadItems(aUnloadFlags); } } } }
void DOMStorageManager::ClearCaches(uint32_t aUnloadFlags, const nsACString& aKeyPrefix) { for (auto iter = mCaches.Iter(); !iter.Done(); iter.Next()) { DOMStorageCache* cache = iter.Get()->cache(); nsCString& key = const_cast<nsCString&>(cache->Scope()); if (aKeyPrefix.IsEmpty() || StringBeginsWith(key, aKeyPrefix)) { cache->UnloadItems(aUnloadFlags); } } }
PLDHashOperator DOMStorageManager::ClearCacheEnumerator(DOMStorageCacheHashKey* aEntry, void* aClosure) { DOMStorageCache* cache = aEntry->cache(); nsCString& key = const_cast<nsCString&>(cache->Scope()); ClearCacheEnumeratorData* data = static_cast<ClearCacheEnumeratorData*>(aClosure); if (data->mKeyPrefix.IsEmpty() || StringBeginsWith(key, data->mKeyPrefix)) { cache->UnloadItems(data->mUnloadFlags); } return PL_DHASH_NEXT; }