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(); }