Bug 1187419 - Make sure SettingsRequestManager is only loaded in parent. r=gwagner
authorAlexandre Lissy <lissyx@lissyx.dyndns.org>
Fri, 24 Jul 2015 12:32:00 +0200
changeset 254933 ae9f773bab881a09cda1e2050c82e83a9d5a79ea
parent 254932 f1139a10e2c6238a71042fccf1964452a08a63b1
child 254934 ac04ab483fbae8b7cc049c5aa0144eb859088eb1
push id29124
push userryanvm@gmail.com
push dateTue, 28 Jul 2015 18:36:51 +0000
treeherdermozilla-central@42521959e9b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgwagner
bugs1187419
milestone42.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 1187419 - Make sure SettingsRequestManager is only loaded in parent. r=gwagner
dom/settings/SettingsRequestManager.jsm
--- a/dom/settings/SettingsRequestManager.jsm
+++ b/dom/settings/SettingsRequestManager.jsm
@@ -1,16 +1,17 @@
 /* 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/. */
 
 "use strict";
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
+const Cr = Components.results;
 const Cu = Components.utils;
 
 Cu.importGlobalProperties(['File']);
 
 this.EXPORTED_SYMBOLS = ["SettingsRequestManager"];
 
 Cu.import("resource://gre/modules/SettingsDB.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@@ -34,16 +35,19 @@ let allowForceReadOnly = false;
 try {
   allowForceReadOnly = Services.prefs.getBoolPref("dom.mozSettings.allowForceReadOnly");
 } catch (ex) { }
 
 function debug(s) {
   dump("-*- SettingsRequestManager: " + s + "\n");
 }
 
+let inParent = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
+                  .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
+
 const kXpcomShutdownObserverTopic      = "xpcom-shutdown";
 const kInnerWindowDestroyed            = "inner-window-destroyed";
 const kMozSettingsChangedObserverTopic = "mozsettings-changed";
 const kSettingsReadSuffix              = "-read";
 const kSettingsWriteSuffix             = "-write";
 const kSettingsClearPermission         = "settings-clear";
 const kAllSettingsReadPermission       = "settings" + kSettingsReadSuffix;
 const kAllSettingsWritePermission      = "settings" + kSettingsWriteSuffix;
@@ -1205,10 +1209,16 @@ let SettingsRequestManager = {
         this.startRunning(msg.lockID);
         break;
       default:
         if (DEBUG) debug("Wrong message: " + aMessage.name);
     }
   }
 };
 
-this.SettingsRequestManager = SettingsRequestManager;
-SettingsRequestManager.init();
+// This code should ALWAYS be living only on the parent side.
+if (!inParent) {
+  debug("SettingsRequestManager should be living on parent side.");
+  throw Cr.NS_ERROR_ABORT;
+} else {
+  this.SettingsRequestManager = SettingsRequestManager;
+  SettingsRequestManager.init();
+}