Bug 1419771 - Introduce DOMPreferences, a thread-safe access to preferences for DOM - part 22 - DOMPreferences initialized at startup, r=asuth
☠☠ backed out by ccd7b237c433 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 13 Dec 2017 14:02:47 -0600
changeset 396312 b2b7b46c8ad0ed72ebfc2a192e841f90e8620c91
parent 396311 0206657d2ea2d9a83ab4859c7dcae5c9c875dcc1
child 396313 f5ea86116d56e8e90689ec325061c948869159ba
push id56975
push userdluca@mozilla.com
push dateThu, 14 Dec 2017 09:59:07 +0000
treeherderautoland@16bcfaad13e1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1419771
milestone59.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 1419771 - Introduce DOMPreferences, a thread-safe access to preferences for DOM - part 22 - DOMPreferences initialized at startup, r=asuth
dom/base/DOMPreferences.cpp
dom/base/DOMPreferences.h
dom/base/DOMPreferencesInternal.h
dom/base/FuzzingFunctions.h
dom/base/IntlUtils.cpp
dom/base/IntlUtils.h
layout/build/nsLayoutStatics.cpp
--- a/dom/base/DOMPreferences.cpp
+++ b/dom/base/DOMPreferences.cpp
@@ -6,16 +6,31 @@
 
 #include "DOMPreferences.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Preferences.h"
 
 namespace mozilla {
 namespace dom {
 
+void
+DOMPreferences::Initialize()
+{
+  MOZ_ASSERT(NS_IsMainThread());
+
+  // Let's cache all the values on the main-thread.
+#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
+  DOMPreferences::DumpEnabled();
+#endif
+
+#define PREF(name, pref) DOMPreferences::name();
+#include "DOMPreferencesInternal.h"
+#undef PREF
+}
+
 #define PREF(name, pref)                               \
   /* static */ bool                                    \
   DOMPreferences::name()                               \
   {                                                    \
     static bool initialized = false;                   \
     static Atomic<bool> cachedValue;                   \
     if (!initialized) {                                \
       initialized = true;                              \
@@ -30,37 +45,17 @@ PREF(DumpEnabled, "browser.dom.window.du
 #else
 /* static */ bool
 DOMPreferences::DumpEnabled()
 {
   return true;
 }
 #endif
 
-PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
-PREF(DOMCachesEnabled, "dom.caches.enabled")
-PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
-PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
-PREF(NotificationEnabled, "dom.webnotifications.enabled")
-PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
-PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
-PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
-PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
-PREF(StorageManagerEnabled, "dom.storageManager.enabled")
-PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
-PREF(PushEnabled, "dom.push.enabled")
-PREF(StreamsEnabled, "dom.streams.enabled")
-PREF(RequestContextEnabled, "dom.requestcontext.enabled")
-PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
-PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
-PREF(NetworkInformationEnabled, "dom.netinfo.enabled")
-PREF(FetchObserverEnabled, "dom.fetchObserver.enabled")
-PREF(ResistFingerprintingEnabled, "privacy.resistFingerprinting")
-PREF(DevToolsEnabled, "devtools.enabled")
-
+#include "DOMPreferencesInternal.h"
 #undef PREF
 
 #define PREF_WEBIDL(name)                              \
   /* static */ bool                                    \
   DOMPreferences::name(JSContext* aCx, JSObject* aObj) \
   {                                                    \
     return DOMPreferences::name();                     \
   }
--- a/dom/base/DOMPreferences.h
+++ b/dom/base/DOMPreferences.h
@@ -8,16 +8,19 @@
 #define mozilla_dom_DOMPreferences_h
 
 namespace mozilla {
 namespace dom {
 
 class DOMPreferences final
 {
 public:
+  // This must be called on the main-thread.
+  static void Initialize();
+
   // Returns true if the browser.dom.window.dump.enabled pref is set.
   static bool DumpEnabled();
 
   // Returns true if the canvas.imagebitmap_extensions.enabled pref is set.
   static bool ImageBitmapExtensionsEnabled();
   static bool ImageBitmapExtensionsEnabled(JSContext* aCx, JSObject* aObj);
 
   // Returns true if the dom.caches.enabled pref is set.
new file mode 100644
--- /dev/null
+++ b/dom/base/DOMPreferencesInternal.h
@@ -0,0 +1,26 @@
+/* -*- 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/. */
+
+PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
+PREF(DOMCachesEnabled, "dom.caches.enabled")
+PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
+PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
+PREF(NotificationEnabled, "dom.webnotifications.enabled")
+PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
+PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
+PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
+PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
+PREF(StorageManagerEnabled, "dom.storageManager.enabled")
+PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
+PREF(PushEnabled, "dom.push.enabled")
+PREF(StreamsEnabled, "dom.streams.enabled")
+PREF(RequestContextEnabled, "dom.requestcontext.enabled")
+PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
+PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
+PREF(NetworkInformationEnabled, "dom.netinfo.enabled")
+PREF(FetchObserverEnabled, "dom.fetchObserver.enabled")
+PREF(ResistFingerprintingEnabled, "privacy.resistFingerprinting")
+PREF(DevToolsEnabled, "devtools.enabled")
--- a/dom/base/FuzzingFunctions.h
+++ b/dom/base/FuzzingFunctions.h
@@ -3,16 +3,19 @@
 /* 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/. */
 
 #ifndef mozilla_dom_FuzzingFunctions
 #define mozilla_dom_FuzzingFunctions
 
 namespace mozilla {
+
+class ErrorResult;
+
 namespace dom {
 
 class GlobalObject;
 
 class FuzzingFunctions final
 {
 public:
   static void
--- a/dom/base/IntlUtils.cpp
+++ b/dom/base/IntlUtils.cpp
@@ -5,16 +5,20 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "IntlUtils.h"
 
 #include "mozilla/dom/ToJSValue.h"
 #include "mozIMozIntl.h"
 #include "nsContentUtils.h"
 
+#ifdef XP_WIN
+#undef GetLocaleInfo
+#endif
+
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(IntlUtils, mWindow)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(IntlUtils)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(IntlUtils)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IntlUtils)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
--- a/dom/base/IntlUtils.h
+++ b/dom/base/IntlUtils.h
@@ -5,16 +5,20 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef mozilla_dom_IntlUtils_h
 #define mozilla_dom_IntlUtils_h
 
 #include "mozilla/dom/IntlUtilsBinding.h"
 #include "nsWrapperCache.h"
 #include "xpcprivate.h"
 
+#ifdef XP_WIN
+#undef GetLocaleInfo
+#endif
+
 class nsPIDOMWindowInner;
 
 namespace mozilla {
 namespace dom {
 
 class IntlUtils final : public nsISupports
                       , public nsWrapperCache
 {
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -314,16 +314,19 @@ nsLayoutStatics::Initialize()
   // On Android, we instantiate it when constructing AndroidBridge.
   MediaPrefs::GetSingleton();
 #endif
 
   // This must be initialized on the main-thread.
   mozilla::dom::IPCBlobInputStreamStorage::Initialize();
 
   mozilla::dom::U2FTokenManager::Initialize();
+
+  mozilla::dom::DOMPreferences::Initialize();
+
   return NS_OK;
 }
 
 void
 nsLayoutStatics::Shutdown()
 {
   // Don't need to shutdown nsWindowMemoryReporter, that will be done by the
   // memory reporter manager.