/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
StorageObserver* observer = StorageObserver::Self();
NS_ASSERTION(
observer, "No StorageObserver, cannot observe private data delete notifications!");
if (observer) {
observer->AddSink(this);
}
NS_ASSERTION(!sSelf, "Somebody is trying to " "do_CreateInstance(\"@mozilla/dom/localStorage-manager;1\"");
sSelf = this;
if (!XRE_IsParentProcess()) { // Do this only on the child process. The thread IPC bridge // is also used to communicate chrome observer notifications. // Note: must be called after we set sSelf for (const uint32_t id : {0, 1}) {
StorageDBChild::GetOrCreate(id);
}
}
}
// static
nsAutoCString LocalStorageManager::CreateOrigin( const nsACString& aOriginSuffix, const nsACString& aOriginNoSuffix) { // Note: some hard-coded sqlite statements are dependent on the format this // method returns. Changing this without updating those sqlite statements // will cause malfunction.
// Lifetime handled by the cache, do persist
cache->Init(this, true, aPrincipal, aQuotaKey); return cache.forget();
}
void LocalStorageManager::DropCache(LocalStorageCache* aCache) { if (!NS_IsMainThread()) {
NS_WARNING( "StorageManager::DropCache called on a non-main thread, shutting " "down?");
}
// Get or create a cache for the given scope if (!cache) { if (aCreateMode == CreateMode::UseIfExistsNeverCreate) {
*aRetval = nullptr; return NS_OK;
}
if (aCreateMode == CreateMode::CreateIfShouldPreload) { const uint32_t privateBrowsingId =
aStoragePrincipal->GetPrivateBrowsingId();
// This is a demand to just preload the cache, if the scope has // no data stored, bypass creation and preload of the cache.
StorageDBChild* db = StorageDBChild::Get(privateBrowsingId); if (db) { if (!db->ShouldPreloadOrigin(LocalStorageManager::CreateOrigin(
originAttrSuffix, originKey))) { return NS_OK;
}
} else { if (originKey.EqualsLiteral("knalb.:about")) { return NS_OK;
}
}
}
if (!backgroundActor->CanSend()) { return NS_ERROR_FAILURE;
} #endif
// There is always a single instance of a cache per scope // in a single instance of a DOM storage manager.
cache = PutCache(originAttrSuffix, originKey, quotaKey, aStoragePrincipal);
#if !defined(MOZ_WIDGET_ANDROID)
LocalStorageCacheChild* actor = new LocalStorageCacheChild(cache);
NS_IMETHODIMP
LocalStorageManager::CloneStorage(Storage* aStorage) { // Cloning is supported only for sessionStorage return NS_ERROR_NOT_IMPLEMENTED;
}
if (!strcmp(aTopic, "browser:purge-sessionStorage")) { // This is only meant for SessionStorageManager. return NS_OK;
}
// Clear from caches everything that has been stored // while in session-only mode if (!strcmp(aTopic, "session-only-cleared")) {
ClearCaches(LocalStorageCache::kUnloadSession, pattern, aOriginScope); return NS_OK;
}
// Clear all private-browsing caches if (!strcmp(aTopic, "private-browsing-data-cleared")) {
ClearCaches(LocalStorageCache::kUnloadComplete, pattern, ""_ns); return NS_OK;
}
// Clear localStorage data belonging to an origin pattern if (!strcmp(aTopic, "clear-origin-attributes-data") ||
!strcmp(aTopic, "dom-storage:clear-origin-attributes-data")) {
ClearCaches(LocalStorageCache::kUnloadComplete, pattern, ""_ns); return NS_OK;
}
if (!strcmp(aTopic, "profile-change")) { // For case caches are still referenced - clear them completely
ClearCaches(LocalStorageCache::kUnloadComplete, pattern, ""_ns);
mCaches.Clear(); return NS_OK;
}
#ifdef DOM_STORAGE_TESTS if (!strcmp(aTopic, "test-reload")) { // This immediately completely reloads all caches from the database.
ClearCaches(LocalStorageCache::kTestReload, pattern, ""_ns); return NS_OK;
}
if (!strcmp(aTopic, "test-flushed")) { if (!XRE_IsParentProcess()) {
nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService(); if (obs) {
obs->NotifyObservers(nullptr, "domstorage-test-flushed", nullptr);
}
}
// Cause sSelf to be populated.
nsCOMPtr<nsIDOMStorageManager> initializer =
do_GetService("@mozilla.org/dom/localStorage-manager;1");
MOZ_ASSERT(sSelf, "Didn't initialize?");
return sSelf;
}
} // namespace mozilla::dom
¤ Dauer der Verarbeitung: 0.26 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.