Bug 1357287 - [1.1] Add multiprocess GeckoView setting. r=snorp
☠☠ backed out by 24f6ba02de71 ☠ ☠
authorEugen Sawin <esawin@mozilla.com>
Tue, 18 Apr 2017 23:32:07 +0200
changeset 353980 07e9e794d4ff2ff9b1c2734c3373aebf138ed4ca
parent 353959 18f4ab471d1699f03d90a23bda5c94ae443b9908
child 353981 24f6ba02de71fc14e50bc3a27800990f39414529
push id31684
push usercbook@mozilla.com
push dateThu, 20 Apr 2017 09:13:26 +0000
treeherdermozilla-central@27311156637f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1357287
milestone55.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 1357287 - [1.1] Add multiprocess GeckoView setting. r=snorp
mobile/android/chrome/geckoview/geckoview.xul
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoViewSettings.java
mobile/android/modules/geckoview/GeckoViewSettings.jsm
--- a/mobile/android/chrome/geckoview/geckoview.xul
+++ b/mobile/android/chrome/geckoview/geckoview.xul
@@ -5,12 +5,12 @@
 
 <?xml-stylesheet href="chrome://browser/content/browser.css" type="text/css"?>
 
 <window id="main-window"
         onload="startup();"
         windowtype="navigator:browser"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
-  <browser id="content" type="content" primary="true" src="about:blank" flex="1" remote="true"/>
+  <browser id="content" type="content" primary="true" src="about:blank" flex="1"/>
 
   <script type="application/javascript" src="chrome://geckoview/content/geckoview.js"/>
 </window>
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoViewSettings.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoViewSettings.java
@@ -17,34 +17,48 @@ public final class GeckoViewSettings {
     private static class Key<T> {
         private final String text;
 
         public Key(final String text) {
             this.text = text;
         }
     }
 
+    /*
+     * Key to enabled and disable tracking protection.
+     */
     public static final Key<Boolean> USE_TRACKING_PROTECTION =
         new Key<Boolean>("useTrackingProtection");
+    /*
+     * Key to enabled and disable private mode browsing.
+     */
     public static final Key<Boolean> USE_PRIVATE_MODE =
         new Key<Boolean>("usePrivateMode");
+    /*
+     * Key to enabled and disable multiprocess browsing (e10s).
+     * Note: can only be set during GeckoView initialization, changes during an
+     * active GeckoView session will be ignored.
+     */
+    public static final Key<Boolean> USE_MULTIPROCESS =
+        new Key<Boolean>("useMultiprocess");
 
     private final EventDispatcher mEventDispatcher;
     private final GeckoBundle mBundle;
 
     public GeckoViewSettings() {
         this(null);
     }
 
     /* package */ GeckoViewSettings(EventDispatcher eventDispatcher) {
         mEventDispatcher = eventDispatcher;
         mBundle = new GeckoBundle();
 
         setBoolean(USE_TRACKING_PROTECTION, false);
         setBoolean(USE_PRIVATE_MODE, false);
+        setBoolean(USE_MULTIPROCESS, true);
     }
 
     /* package */ GeckoViewSettings(GeckoViewSettings settings, EventDispatcher eventDispatcher) {
         mBundle = new GeckoBundle(settings.mBundle);
         mEventDispatcher = eventDispatcher;
     }
 
     public void setBoolean(final Key<Boolean> key, boolean value) {
--- a/mobile/android/modules/geckoview/GeckoViewSettings.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewSettings.jsm
@@ -18,20 +18,25 @@ var dump = Cu.import("resource://gre/mod
            .AndroidLog.d.bind(null, "ViewSettings");
 
 function debug(aMsg) {
   // dump(aMsg);
 }
 
 // Handles GeckoView settings including:
 // * tracking protection
+// * multiprocess
 class GeckoViewSettings extends GeckoViewModule {
   init() {
     this._isSafeBrowsingInit = false;
     this._useTrackingProtection = false;
+
+    // We only allow to set this setting during initialization, further updates
+    // will be ignored.
+    this.useMultiprocess = !!this.settings.useMultiprocess;
   }
 
   onSettingsUpdate() {
     debug("onSettingsUpdate: " + JSON.stringify(this.settings));
 
     this.useTrackingProtection = !!this.settings.useTrackingProtection;
   }
 
@@ -47,9 +52,28 @@ class GeckoViewSettings extends GeckoVie
     if (aUse != this._useTrackingProtection) {
       this.messageManager.loadFrameScript('data:,' +
         'docShell.useTrackingProtection = ' + aUse,
         true
       );
       this._useTrackingProtection = aUse;
     }
   }
+
+  get useMultiprocess() {
+    return this.browser.getAttribute("remote") == "true";
+  }
+
+  set useMultiprocess(aUse) {
+    if (aUse == this.useMultiprocess) {
+      return;
+    }
+    let parentNode = this.browser.parentNode;
+    parentNode.removeChild(this.browser);
+
+    if (aUse) {
+      this.browser.setAttribute("remote", "true");
+    } else {
+      this.browser.removeAttribute("remote");
+    }
+    parentNode.appendChild(this.browser);
+  }
 }