diff --git a/dom/localstorage/ActorsParent.cpp b/dom/localstorage/ActorsParent.cpp index dcaadc2aad0c..3b789bc09ed7 100644 --- a/dom/localstorage/ActorsParent.cpp +++ b/dom/localstorage/ActorsParent.cpp @@ -2819,6 +2819,8 @@ class QuotaClient final : public mozilla::dom::quota::Client { void ReleaseIOThreadObjects() override; + void OnStorageInitFailed() override; + void AbortOperations(const nsACString& aOrigin) override; void AbortOperationsForProcess(ContentParentId aContentParentId) override; @@ -8805,6 +8807,14 @@ void QuotaClient::ReleaseIOThreadObjects() { gArchivedOrigins = nullptr; } +void QuotaClient::OnStorageInitFailed() { + AssertIsOnIOThread(); + MOZ_DIAGNOSTIC_ASSERT(QuotaManager::Get()); + MOZ_DIAGNOSTIC_ASSERT(!QuotaManager::Get()->IsTemporaryStorageInitialized()); + + gUsages = nullptr; +} + void QuotaClient::AbortOperations(const nsACString& aOrigin) { AssertIsOnBackgroundThread(); diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index 1f2763fca94b..e4e66508f3cf 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -5826,6 +5826,13 @@ nsresult QuotaManager::EnsureTemporaryStorageIsInitialized() { // for whole profile can be collected nsresult statusKeeper = NS_OK; + AutoTArray, Client::TYPE_MAX>& clients = mClients; + auto autoNotifier = MakeScopeExit([&clients] { + for (RefPtr& client : clients) { + client->OnStorageInitFailed(); + } + }); + nsresult rv = InitializeRepository(PERSISTENCE_TYPE_DEFAULT); if (NS_WARN_IF(NS_FAILED(rv))) { RECORD_IN_NIGHTLY(statusKeeper, rv); @@ -5878,6 +5885,8 @@ nsresult QuotaManager::EnsureTemporaryStorageIsInitialized() { CheckTemporaryStorageLimits(); + autoNotifier.release(); + return rv; } diff --git a/dom/quota/Client.h b/dom/quota/Client.h index d2f536b5dc4d..f99fba35f67a 100644 --- a/dom/quota/Client.h +++ b/dom/quota/Client.h @@ -164,6 +164,8 @@ class Client { virtual void ReleaseIOThreadObjects() = 0; + virtual void OnStorageInitFailed(){}; + // Methods which are called on the background thread. virtual void AbortOperations(const nsACString& aOrigin) = 0;