From f4d108788baad15e267c2a5d06e4e59c9ac7cf48 Mon Sep 17 00:00:00 2001 From: Jan Varga Date: Sun, 25 Aug 2019 00:45:19 +0000 Subject: [PATCH] Bug 1563023 - Part 8: Ignore quota cache if the user loads the same profile in different builds; r=asuth This patch adds support for quota cache invalidation if the profile is loaded in different builds. Differential Revision: https://phabricator.services.mozilla.com/D39673 --HG-- extra : moz-landing-system : lando --- dom/quota/ActorsParent.cpp | 15 +++++++++++++++ dom/quota/QuotaManager.h | 2 ++ toolkit/xre/nsAppRunner.cpp | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index 0d4f18389d29..9ed57c7b1520 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -1840,6 +1840,7 @@ void ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr) { namespace { +bool gInvalidateQuotaCache = false; StaticAutoPtr gBaseDirPath; StaticAutoPtr gBuildId; @@ -6480,6 +6481,15 @@ nsresult QuotaManager::EnsureStorageIsInitialized() { } } + if (cacheUsable && gInvalidateQuotaCache) { + rv = InvalidateCache(connection); + if (NS_WARN_IF(NS_FAILED(rv))) { + return rv; + } + + gInvalidateQuotaCache = false; + } + mStorageConnection = connection; mCacheUsable = cacheUsable; @@ -7175,6 +7185,11 @@ bool QuotaManager::ParseOrigin(const nsACString& aOrigin, nsCString& aSpec, return true; } +// static +void QuotaManager::InvalidateQuotaCache() { + gInvalidateQuotaCache = true; +} + uint64_t QuotaManager::LockedCollectOriginsForEviction( uint64_t aMinSizeToBeFreed, nsTArray>& aLocks) { mQuotaMutex.AssertCurrentThreadOwns(); diff --git a/dom/quota/QuotaManager.h b/dom/quota/QuotaManager.h index 0457e018c9cb..08f814bc630e 100644 --- a/dom/quota/QuotaManager.h +++ b/dom/quota/QuotaManager.h @@ -430,6 +430,8 @@ class QuotaManager final : public BackgroundThreadObject { static bool ParseOrigin(const nsACString& aOrigin, nsCString& aSpec, OriginAttributes* aAttrs); + static void InvalidateQuotaCache(); + private: QuotaManager(); diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 9f491f61f99a..d7883d9f70a0 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -97,6 +97,7 @@ #include "nsIWidget.h" #include "nsIDocShell.h" #include "nsAppShellCID.h" +#include "mozilla/dom/quota/QuotaManager.h" #include "mozilla/scache/StartupCache.h" #include "gfxPlatform.h" @@ -320,6 +321,7 @@ using namespace mozilla::startup; using mozilla::Unused; using mozilla::dom::ContentChild; using mozilla::dom::ContentParent; +using mozilla::dom::quota::QuotaManager; using mozilla::intl::LocaleService; using mozilla::scache::StartupCache; @@ -4170,6 +4172,8 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) { bool startupCacheValid = true; if (!cachesOK || !versionOK) { + QuotaManager::InvalidateQuotaCache(); + startupCacheValid = RemoveComponentRegistries(mProfD, mProfLD, false); // Rewrite compatibility.ini to match the current build. The next run