already_AddRefed<DOMStorageCache> DOMStorageManager::PutCache(const nsACString& aScope, nsIPrincipal* aPrincipal) { DOMStorageCacheHashKey* entry = mCaches.PutEntry(aScope); nsRefPtr<DOMStorageCache> cache = entry->cache(); nsAutoCString quotaScope; CreateQuotaDBKey(aPrincipal, quotaScope); switch (mType) { case SessionStorage: // Lifetime handled by the manager, don't persist entry->HardRef(); cache->Init(nullptr, false, aPrincipal, quotaScope); break; case LocalStorage: // Lifetime handled by the cache, do persist cache->Init(this, true, aPrincipal, quotaScope); break; default: MOZ_ASSERT(false); } return cache.forget(); }
already_AddRefed<DOMStorageCache> DOMStorageManager::PutCache(const nsACString& aOriginSuffix, const nsACString& aOriginNoSuffix, nsIPrincipal* aPrincipal) { CacheOriginHashtable* table = mCaches.LookupOrAdd(aOriginSuffix); DOMStorageCacheHashKey* entry = table->PutEntry(aOriginNoSuffix); RefPtr<DOMStorageCache> cache = entry->cache(); nsAutoCString quotaOrigin; CreateQuotaDBKey(aPrincipal, quotaOrigin); switch (mType) { case SessionStorage: // Lifetime handled by the manager, don't persist entry->HardRef(); cache->Init(this, false, aPrincipal, quotaOrigin); break; case LocalStorage: // Lifetime handled by the cache, do persist cache->Init(this, true, aPrincipal, quotaOrigin); break; default: MOZ_ASSERT(false); } return cache.forget(); }
DOMStorageCache* DOMStorageManager::GetCache(const nsACString& aScope) const { DOMStorageCacheHashKey* entry = mCaches.GetEntry(aScope); if (!entry) { return nullptr; } return entry->cache(); }
DOMStorageCache* DOMStorageManager::GetCache(const nsACString& aOriginSuffix, const nsACString& aOriginNoSuffix) { CacheOriginHashtable* table = mCaches.LookupOrAdd(aOriginSuffix); DOMStorageCacheHashKey* entry = table->GetEntry(aOriginNoSuffix); if (!entry) { return nullptr; } return entry->cache(); }