Bug 1526891 - Part 6: Introduce InitializeQuotaManager and call it in nsLayoutStatics::Initialize; r=asuth
authorJan Varga <jan.varga@gmail.com>
Sat, 23 Feb 2019 17:08:42 +0100
changeset 520819 4733f0d7f7c5dd802a5bda3e040dd20946da3023
parent 520818 8173a37df52bff6d1e207058d0fec29129fe449d
child 520820 bb96024458d0e147889b755048cd19c5b8573a01
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1526891
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1526891 - Part 6: Introduce InitializeQuotaManager and call it in nsLayoutStatics::Initialize; r=asuth Differential Revision: https://phabricator.services.mozilla.com/D20915
dom/quota/ActorsParent.cpp
dom/quota/ActorsParent.h
layout/build/nsLayoutStatics.cpp
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -1351,16 +1351,20 @@ void ReportInternalError(const char* aFi
       NS_ConvertUTF8toUTF16(
           nsPrintfCString("Quota %s: %s:%" PRIu32, aStr, aFile, aLine)),
       "quota",
       false /* Quota Manager is not active in private browsing mode */);
 }
 
 namespace {
 
+#ifdef DEBUG
+bool gQuotaManagerInitialized = false;
+#endif
+
 StaticRefPtr<QuotaManager> gInstance;
 bool gCreateFailed = false;
 StaticRefPtr<QuotaManager::CreateRunnable> gCreateRunnable;
 mozilla::Atomic<bool> gShutdown(false);
 
 // Constants for temporary storage limit computing.
 static const int32_t kDefaultFixedLimitKB = -1;
 static const uint32_t kDefaultChunkSizeKB = 10 * 1024;
@@ -2152,16 +2156,26 @@ nsresult GetTemporaryStorageLimit(nsIFil
 }
 
 }  // namespace
 
 /*******************************************************************************
  * Exported functions
  ******************************************************************************/
 
+void InitializeQuotaManager() {
+  MOZ_ASSERT(XRE_IsParentProcess());
+  MOZ_ASSERT(NS_IsMainThread());
+  MOZ_ASSERT(!gQuotaManagerInitialized);
+
+#ifdef DEBUG
+  gQuotaManagerInitialized = true;
+#endif
+}
+
 PQuotaParent* AllocPQuotaParent() {
   AssertIsOnBackgroundThread();
 
   if (NS_WARN_IF(QuotaManager::IsShuttingDown())) {
     return nullptr;
   }
 
   RefPtr<Quota> actor = new Quota();
--- a/dom/quota/ActorsParent.h
+++ b/dom/quota/ActorsParent.h
@@ -8,16 +8,18 @@
 #define mozilla_dom_quota_ActorsParent_h
 
 namespace mozilla {
 namespace dom {
 namespace quota {
 
 class PQuotaParent;
 
+void InitializeQuotaManager();
+
 PQuotaParent* AllocPQuotaParent();
 
 bool DeallocPQuotaParent(PQuotaParent* aActor);
 
 }  // namespace quota
 }  // namespace dom
 }  // namespace mozilla
 
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -113,25 +113,27 @@
 #include "mozilla/dom/U2FTokenManager.h"
 #ifdef OS_WIN
 #  include "mozilla/dom/WinWebAuthnManager.h"
 #endif
 #include "mozilla/dom/PointerEventHandler.h"
 #include "mozilla/dom/RemoteWorkerService.h"
 #include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/ReportingHeader.h"
+#include "mozilla/dom/quota/ActorsParent.h"
 #include "mozilla/dom/localstorage/ActorsParent.h"
 #include "mozilla/net/UrlClassifierFeatureFactory.h"
 #include "nsThreadManager.h"
 #include "mozilla/css/ImageLoader.h"
 
 using namespace mozilla;
 using namespace mozilla::net;
 using namespace mozilla::dom;
 using namespace mozilla::dom::ipc;
+using namespace mozilla::dom::quota;
 
 nsrefcnt nsLayoutStatics::sLayoutStaticRefcnt = 0;
 
 nsresult nsLayoutStatics::Initialize() {
   NS_ASSERTION(sLayoutStaticRefcnt == 0, "nsLayoutStatics isn't zero!");
 
   sLayoutStaticRefcnt = 1;
   NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt, "nsLayoutStatics",
@@ -299,16 +301,17 @@ nsresult nsLayoutStatics::Initialize() {
   mozilla::Fuzzyfox::Start();
 
   ClearSiteData::Initialize();
 
   // Reporting API.
   ReportingHeader::Initialize();
 
   if (XRE_IsParentProcess()) {
+    InitializeQuotaManager();
     InitializeLocalStorage();
   }
 
   ThirdPartyUtil::Startup();
 
   return NS_OK;
 }