Bug 1462069 P0 Allow ServiceWorkerParentInterceptEnabled() to be used off-main-thread. r=asuth
☠☠ backed out by dab096c54952 ☠ ☠
authorBen Kelly <ben@wanderview.com>
Fri, 01 Jun 2018 13:39:56 -0700
changeset 420948 ec66aff745a89871345694ea00c349976c89d8f0
parent 420947 209cc0d0c1dfd6970d19012a178663d4d5cee0f2
child 420949 457cb3f8a0d903fbe86289995db5a8c57fa92687
push id34083
push userapavel@mozilla.com
push dateSat, 02 Jun 2018 23:03:25 +0000
treeherdermozilla-central@1f62ecdf59b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1462069
milestone62.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 1462069 P0 Allow ServiceWorkerParentInterceptEnabled() to be used off-main-thread. r=asuth
dom/serviceworkers/ServiceWorkerUtils.cpp
--- a/dom/serviceworkers/ServiceWorkerUtils.cpp
+++ b/dom/serviceworkers/ServiceWorkerUtils.cpp
@@ -9,28 +9,24 @@
 #include "mozilla/Preferences.h"
 
 namespace mozilla {
 namespace dom {
 
 bool
 ServiceWorkerParentInterceptEnabled()
 {
-  // For right now we only support main thread.  In the future we could make
-  // this use an atomic bool if we need to support worker threads.
-  MOZ_ASSERT(NS_IsMainThread());
-
   static bool sInit = false;
-  static bool sEnabled;
+  static Atomic<bool> sEnabled;
 
   if (!sInit) {
     MOZ_ASSERT(NS_IsMainThread());
-    Preferences::AddBoolVarCache(&sEnabled,
-                                 "dom.serviceWorkers.parent_intercept",
-                                 false);
+    Preferences::AddAtomicBoolVarCache(&sEnabled,
+                                       "dom.serviceWorkers.parent_intercept",
+                                       false);
     sInit = true;
   }
 
   return sEnabled;
 }
 
 bool
 ServiceWorkerRegistrationDataIsValid(const ServiceWorkerRegistrationData& aData)