Bug 1517089 - Part 1: Introduce InitializeLocalStorage and call it in nsLayoutStatics::Initialize; r=asuth
authorJan Varga <jan.varga@gmail.com>
Thu, 07 Feb 2019 19:50:57 +0100
changeset 457568 9b51d5398126be69bf30d2d08bd4c9a47dc33478
parent 457567 ce8c71866841cb72b8d82acd3826ef163c48b5db
child 457569 09ac1f780e566b62a91e62df10ff0c37622b0b22
push id35515
push userrmaries@mozilla.com
push dateThu, 07 Feb 2019 21:44:23 +0000
treeherdermozilla-central@4e98200ee530 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1517089
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 1517089 - Part 1: Introduce InitializeLocalStorage and call it in nsLayoutStatics::Initialize; r=asuth
dom/localstorage/ActorsParent.cpp
dom/localstorage/ActorsParent.h
layout/build/nsLayoutStatics.cpp
--- a/dom/localstorage/ActorsParent.cpp
+++ b/dom/localstorage/ActorsParent.cpp
@@ -2716,16 +2716,20 @@ class QuotaClient::MatchFunction final :
   NS_DECL_ISUPPORTS
   NS_DECL_MOZISTORAGEFUNCTION
 };
 
 /*******************************************************************************
  * Globals
  ******************************************************************************/
 
+#ifdef DEBUG
+bool gLocalStorageInitialized = false;
+#endif
+
 typedef nsTArray<PrepareDatastoreOp*> PrepareDatastoreOpArray;
 
 StaticAutoPtr<PrepareDatastoreOpArray> gPrepareDatastoreOps;
 
 typedef nsDataHashtable<nsCStringHashKey, Datastore*> DatastoreHashtable;
 
 StaticAutoPtr<DatastoreHashtable> gDatastores;
 
@@ -2943,16 +2947,26 @@ void SnapshotPrefillPrefChangedCallback(
 }
 
 }  // namespace
 
 /*******************************************************************************
  * Exported functions
  ******************************************************************************/
 
+void InitializeLocalStorage() {
+  MOZ_ASSERT(XRE_IsParentProcess());
+  MOZ_ASSERT(NS_IsMainThread());
+  MOZ_ASSERT(!gLocalStorageInitialized);
+
+#ifdef DEBUG
+  gLocalStorageInitialized = true;
+#endif
+}
+
 PBackgroundLSDatabaseParent* AllocPBackgroundLSDatabaseParent(
     const PrincipalInfo& aPrincipalInfo, const uint32_t& aPrivateBrowsingId,
     const uint64_t& aDatastoreId) {
   AssertIsOnBackgroundThread();
 
   if (NS_WARN_IF(QuotaClient::IsShuttingDownOnBackgroundThread())) {
     return nullptr;
   }
--- a/dom/localstorage/ActorsParent.h
+++ b/dom/localstorage/ActorsParent.h
@@ -26,16 +26,18 @@ class PBackgroundLSRequestParent;
 class PBackgroundLSSimpleRequestParent;
 
 namespace quota {
 
 class Client;
 
 }  // namespace quota
 
+void InitializeLocalStorage();
+
 PBackgroundLSDatabaseParent* AllocPBackgroundLSDatabaseParent(
     const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
     const uint32_t& aPrivateBrowsingId, const uint64_t& aDatastoreId);
 
 bool RecvPBackgroundLSDatabaseConstructor(
     PBackgroundLSDatabaseParent* aActor,
     const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
     const uint32_t& aPrivateBrowsingId, const uint64_t& aDatastoreId);
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -113,16 +113,17 @@
 #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/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;
@@ -297,16 +298,20 @@ nsresult nsLayoutStatics::Initialize() {
 
   mozilla::Fuzzyfox::Start();
 
   ClearSiteData::Initialize();
 
   // Reporting API.
   ReportingHeader::Initialize();
 
+  if (XRE_IsParentProcess()) {
+    InitializeLocalStorage();
+  }
+
   return NS_OK;
 }
 
 void nsLayoutStatics::Shutdown() {
   // Don't need to shutdown nsWindowMemoryReporter, that will be done by the
   // memory reporter manager.
 
   if (XRE_IsParentProcess() || XRE_IsContentProcess()) {