Bug 998500 - Add command line argument for turning on OOP in B2G Desktop; r=fabrice
authorKyle Machulis <kyle@nonpolynomial.com>
Thu, 24 Apr 2014 11:06:57 -0700
changeset 180498 bb23e8d8d194f15464a27773fbd3c930d09ab90b
parent 180497 bcac06afafe4c9331de48db38c086d96ac4c4b90
child 180499 cdbefb7a040456dfee1108753e8b4667c4035dff
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersfabrice
bugs998500
milestone31.0a1
Bug 998500 - Add command line argument for turning on OOP in B2G Desktop; r=fabrice
b2g/components/B2GComponents.manifest
b2g/components/OopCommandLine.js
b2g/components/moz.build
b2g/installer/package-manifest.in
--- a/b2g/components/B2GComponents.manifest
+++ b/b2g/components/B2GComponents.manifest
@@ -81,9 +81,14 @@ contract @mozilla.org/fxaccounts/fxaccou
 # HelperAppDialog.js
 component {710322af-e6ae-4b0c-b2c9-1474a87b077e} HelperAppDialog.js
 contract @mozilla.org/helperapplauncherdialog;1 {710322af-e6ae-4b0c-b2c9-1474a87b077e}
 
 #ifndef MOZ_WIDGET_GONK
 component {c83c02c0-5d43-4e3e-987f-9173b313e880} SimulatorScreen.js
 contract @mozilla.org/simulator-screen;1 {c83c02c0-5d43-4e3e-987f-9173b313e880}
 category profile-after-change SimulatorScreen @mozilla.org/simulator-screen;1
+
+component {e30b0e13-2d12-4cb0-bc4c-4e617a1bf76e} OopCommandLine.js
+contract @mozilla.org/commandlinehandler/general-startup;1?type=b2goop {e30b0e13-2d12-4cb0-bc4c-4e617a1bf76e}
+category command-line-handler m-b2goop @mozilla.org/commandlinehandler/general-startup;1?type=b2goop
 #endif
+
new file mode 100644
--- /dev/null
+++ b/b2g/components/OopCommandLine.js
@@ -0,0 +1,47 @@
+/* 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/. */
+
+const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
+
+function oopCommandlineHandler() {
+}
+
+oopCommandlineHandler.prototype = {
+    handle: function(cmdLine) {
+        let oopFlag = cmdLine.handleFlag("oop", false);
+        if (oopFlag) {
+            /**
+             * Manipulate preferences by adding to the *default* branch.  Adding
+             * to the default branch means the changes we make won"t get written
+             * back to user preferences.
+             */
+            let prefs = Services.prefs
+            let branch = prefs.getDefaultBranch("");
+
+            try {
+                // Turn on all OOP services, making desktop run similar to phone
+                // environment
+                branch.setBoolPref("dom.ipc.tabs.disabled", false);
+                branch.setBoolPref("layers.acceleration.disabled", false);
+                branch.setBoolPref("layers.offmainthreadcomposition.enabled", true);
+                branch.setBoolPref("layers.offmainthreadcomposition.async-animations", true);
+                branch.setBoolPref("layers.async-video.enabled", true);
+                branch.setBoolPref("layers.async-pan-zoom.enabled", true);
+                branch.setCharPref("gfx.content.azure.backends", "cairo");
+            } catch (e) { }
+
+        }
+        if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) {
+            cmdLine.preventDefault = true;
+        }
+    },
+
+    helpInfo: "  -oop         Use out-of-process model in B2G\n",
+    classID: Components.ID("{e30b0e13-2d12-4cb0-bc4c-4e617a1bf76e}"),
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
+};
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([oopCommandlineHandler]);
--- a/b2g/components/moz.build
+++ b/b2g/components/moz.build
@@ -20,16 +20,17 @@ EXTRA_COMPONENTS += [
     'SmsProtocolHandler.js',
     'TelProtocolHandler.js',
     'WebappsUpdateTimer.js',
     'YoutubeProtocolHandler.js',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
     EXTRA_COMPONENTS += [
+      'OopCommandLine.js',
       'SimulatorScreen.js'
     ]
 
 EXTRA_PP_COMPONENTS += [
     'B2GComponents.manifest',
     'DirectoryProvider.js',
     'RecoveryService.js',
 ]
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -427,16 +427,17 @@
 #endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL
 
 #ifndef MOZ_WIDGET_GONK
 @BINPATH@/components/extensions.manifest
 @BINPATH@/components/addonManager.js
 @BINPATH@/components/amContentHandler.js
 @BINPATH@/components/amWebInstallListener.js
 @BINPATH@/components/nsBlocklistService.js
+@BINPATH@/components/OopCommandLine.js
 #endif
 
 #ifdef MOZ_UPDATER
 @BINPATH@/components/nsUpdateService.manifest
 @BINPATH@/components/nsUpdateService.js
 @BINPATH@/components/nsUpdateServiceStub.js
 #endif
 @BINPATH@/components/nsUpdateTimerManager.manifest