Bug 1078163 - WorkerNavigator strings should honor general.*.override prefs in e10s mode. r=khuey, a=lmandel
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 08 Oct 2014 13:56:50 +0100
changeset 218370 e96a7a4f3bbea42c4022ff76e1da9e2fd93d90d9
parent 218369 9f08e6014c5e44fe3d6561690194400b9e17e6c4
child 218371 fc59036ff930a674eb41dea5216f498e1e880aa5
push id7100
push userryanvm@gmail.com
push dateSat, 11 Oct 2014 22:05:28 +0000
treeherdermozilla-aurora@e96a7a4f3bbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, lmandel
bugs1078163
milestone34.0a2
Bug 1078163 - WorkerNavigator strings should honor general.*.override prefs in e10s mode. r=khuey, a=lmandel
dom/base/Navigator.cpp
dom/workers/RuntimeService.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -364,16 +364,18 @@ Navigator::GetAppName(nsAString& aAppNam
  *
  * "en", "en-US" and "i-cherokee" and "" are valid languages tokens.
  *
  * An empty array will be returned if there is no valid languages.
  */
 void
 Navigator::GetAcceptLanguages(nsTArray<nsString>& aLanguages)
 {
+  aLanguages.Clear();
+
   // E.g. "de-de, en-us,en".
   const nsAdoptingString& acceptLang =
     Preferences::GetLocalizedString("intl.accept_languages");
 
   // Split values on commas.
   nsCharSeparatedTokenizer langTokenizer(acceptLang, ',');
   while (langTokenizer.hasMoreTokens()) {
     nsDependentSubstring lang = langTokenizer.nextToken();
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -169,19 +169,16 @@ const uint32_t kNoIndex = uint32_t(-1);
 const JS::ContextOptions kRequiredContextOptions =
   JS::ContextOptions().setDontReportUncaught(true);
 
 uint32_t gMaxWorkersPerDomain = MAX_WORKERS_PER_DOMAIN;
 
 // Does not hold an owning reference.
 RuntimeService* gRuntimeService = nullptr;
 
-// Only non-null during the call to Init.
-RuntimeService* gRuntimeServiceDuringInit = nullptr;
-
 #ifdef ENABLE_TESTS
 bool gTestPBackground = false;
 #endif // ENABLE_TESTS
 
 enum {
   ID_Worker = 0,
   ID_ChromeWorker,
   ID_Event,
@@ -321,17 +318,17 @@ GenerateSharedWorkerKey(const nsACString
 }
 
 void
 LoadRuntimeOptions(const char* aPrefName, void* /* aClosure */)
 {
   AssertIsOnMainThread();
 
   RuntimeService* rts = RuntimeService::GetService();
-  if (!rts && !gRuntimeServiceDuringInit) {
+  if (!rts) {
     // May be shutting down, just bail.
     return;
   }
 
   const nsDependentCString prefName(aPrefName);
 
   // Several other pref branches will get included here so bail out if there is
   // another callback that will handle this change.
@@ -382,17 +379,17 @@ LoadRuntimeOptions(const char* aPrefName
 
 #ifdef JS_GC_ZEAL
 void
 LoadGCZealOptions(const char* /* aPrefName */, void* /* aClosure */)
 {
   AssertIsOnMainThread();
 
   RuntimeService* rts = RuntimeService::GetService();
-  if (!rts && !gRuntimeServiceDuringInit) {
+  if (!rts) {
     // May be shutting down, just bail.
     return;
   }
 
   int32_t gczeal = GetWorkerPref<int32_t>(NS_LITERAL_CSTRING(PREF_GCZEAL), -1);
   if (gczeal < 0) {
     gczeal = 0;
   }
@@ -445,17 +442,17 @@ UpdatOtherJSGCMemoryOption(RuntimeServic
 
 void
 LoadJSGCMemoryOptions(const char* aPrefName, void* /* aClosure */)
 {
   AssertIsOnMainThread();
 
   RuntimeService* rts = RuntimeService::GetService();
 
-  if (!rts && !gRuntimeServiceDuringInit) {
+  if (!rts) {
     // May be shutting down, just bail.
     return;
   }
 
   NS_NAMED_LITERAL_CSTRING(jsPrefix, PREF_JS_OPTIONS_PREFIX);
   NS_NAMED_LITERAL_CSTRING(workersPrefix, PREF_WORKERS_OPTIONS_PREFIX);
 
   const nsDependentCString fullPrefName(aPrefName);
@@ -1378,29 +1375,28 @@ RuntimeService::~RuntimeService()
 
 // static
 RuntimeService*
 RuntimeService::GetOrCreateService()
 {
   AssertIsOnMainThread();
 
   if (!gRuntimeService) {
-    nsRefPtr<RuntimeService> service = new RuntimeService();
-    if (NS_FAILED(service->Init())) {
+    // The observer service now owns us until shutdown.
+    gRuntimeService = new RuntimeService();
+    if (NS_FAILED(gRuntimeService->Init())) {
       NS_WARNING("Failed to initialize!");
-      service->Cleanup();
+      gRuntimeService->Cleanup();
+      gRuntimeService = nullptr;
       return nullptr;
     }
 
 #ifdef ENABLE_TESTS
     gTestPBackground = mozilla::Preferences::GetBool("pbackground.testing", false);
 #endif // ENABLE_TESTS
-
-    // The observer service now owns us until shutdown.
-    gRuntimeService = service;
   }
 
   return gRuntimeService;
 }
 
 // static
 RuntimeService*
 RuntimeService::GetService()
@@ -1804,19 +1800,16 @@ RuntimeService::Init()
                                  false))) {
     NS_WARNING("Failed to register for memory pressure notifications!");
   }
 
   if (NS_FAILED(obs->AddObserver(this, NS_IOSERVICE_OFFLINE_STATUS_TOPIC, false))) {
     NS_WARNING("Failed to register for offline notification event!");
   }
 
-  NS_ASSERTION(!gRuntimeServiceDuringInit, "This should be null!");
-  gRuntimeServiceDuringInit = this;
-
   if (NS_FAILED(Preferences::RegisterCallback(
                                  LoadJSGCMemoryOptions,
                                  PREF_JS_OPTIONS_PREFIX PREF_MEM_OPTIONS_PREFIX,
                                  nullptr)) ||
       NS_FAILED(Preferences::RegisterCallbackAndCall(
                             LoadJSGCMemoryOptions,
                             PREF_WORKERS_OPTIONS_PREFIX PREF_MEM_OPTIONS_PREFIX,
                             nullptr)) ||
@@ -1861,19 +1854,16 @@ RuntimeService::Init()
                                                  nullptr)) ||
       NS_FAILED(Preferences::RegisterCallbackAndCall(
                                                  JSVersionChanged,
                                                  PREF_WORKERS_LATEST_JS_VERSION,
                                                  nullptr))) {
     NS_WARNING("Failed to register pref callbacks!");
   }
 
-  NS_ASSERTION(gRuntimeServiceDuringInit == this, "Should be 'this'!");
-  gRuntimeServiceDuringInit = nullptr;
-
   // We assume atomic 32bit reads/writes. If this assumption doesn't hold on
   // some wacky platform then the worst that could happen is that the close
   // handler will run for a slightly different amount of time.
   if (NS_FAILED(Preferences::AddIntVarCache(
                                    &sDefaultJSSettings.content.maxScriptRuntime,
                                    PREF_MAX_SCRIPT_RUN_TIME_CONTENT,
                                    MAX_SCRIPT_RUN_TIME_SEC)) ||
       NS_FAILED(Preferences::AddIntVarCache(