Bug 937172 - Add RemoteBrowserTabActor for e10s debugging (r=past)
authorBill McCloskey <wmccloskey@mozilla.com>
Mon, 10 Mar 2014 09:38:34 -0700
changeset 191039 8f90256a56e8850f3edd7935f6f6fb49febecdd2
parent 191038 bdc2b431ba226faa86c3159e0ba1ea2efe18d89d
child 191040 cb89890bd6c72656c7ec889f9484dadadad8b823
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs937172
milestone30.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 937172 - Add RemoteBrowserTabActor for e10s debugging (r=past)
toolkit/devtools/server/actors/webbrowser.js
--- a/toolkit/devtools/server/actors/webbrowser.js
+++ b/toolkit/devtools/server/actors/webbrowser.js
@@ -212,49 +212,61 @@ BrowserTabList.prototype.getList = funct
   let initialMapSize = this._actorByBrowser.size;
   let foundCount = 0;
 
   // To avoid mysterious behavior if tabs are closed or opened mid-iteration,
   // we update the map first, and then make a second pass over it to yield
   // the actors. Thus, the sequence yielded is always a snapshot of the
   // actors that were live when we began the iteration.
 
+  let actorPromises = [];
+
   // Iterate over all navigator:browser XUL windows.
   for (let win of allAppShellDOMWindows(DebuggerServer.chromeWindowType)) {
     let selectedBrowser = this._getSelectedBrowser(win);
     if (!selectedBrowser) {
       continue;
     }
 
     // For each tab in this XUL window, ensure that we have an actor for
     // it, reusing existing actors where possible. We actually iterate
     // over 'browser' XUL elements, and BrowserTabActor uses
     // browser.contentWindow.wrappedJSObject as the debuggee global.
     for (let browser of this._getChildren(win)) {
       // Do we have an existing actor for this browser? If not, create one.
       let actor = this._actorByBrowser.get(browser);
       if (actor) {
+        actorPromises.push(promise.resolve(actor));
         foundCount++;
+      } else if (browser.isRemoteBrowser) {
+        actor = new RemoteBrowserTabActor(this._connection, browser);
+        this._actorByBrowser.set(browser, actor);
+        let promise = actor.connect().then((form) => {
+          actor._form = form;
+          return actor;
+        });
+        actorPromises.push(promise);
       } else {
         actor = new BrowserTabActor(this._connection, browser, win.gBrowser);
         this._actorByBrowser.set(browser, actor);
+        actorPromises.push(promise.resolve(actor));
       }
 
       // Set the 'selected' properties on all actors correctly.
       actor.selected = (win === topXULWindow && browser === selectedBrowser);
     }
   }
 
   if (this._testing && initialMapSize !== foundCount)
     throw Error("_actorByBrowser map contained actors for dead tabs");
 
   this._mustNotify = true;
   this._checkListening();
 
-  return promise.resolve([actor for ([_, actor] of this._actorByBrowser)]);
+  return promise.all(actorPromises);
 };
 
 Object.defineProperty(BrowserTabList.prototype, 'onListChanged', {
   enumerable: true, configurable:true,
   get: function() { return this._onListChanged; },
   set: function(v) {
     if (v !== null && typeof v !== 'function') {
       throw Error("onListChanged property may only be set to 'null' or a function");
@@ -988,16 +1000,45 @@ Object.defineProperty(BrowserTabActor.pr
 });
 
 BrowserTabActor.prototype.exit = function() {
   TabActor.prototype.exit.call(this);
   this._browser = null;
   this._tabbrowser = null;
 };
 
+/**
+ * This actor is a shim that connects to a ContentActor in a remote
+ * browser process. All RDP packets get forwarded using the message
+ * manager.
+ *
+ * @param aConnection The main RDP connection.
+ * @param aBrowser XUL <browser> element to connect to.
+ */
+function RemoteBrowserTabActor(aConnection, aBrowser)
+{
+  this._conn = aConnection;
+  this._browser = aBrowser;
+  this._form = null;
+}
+
+RemoteBrowserTabActor.prototype = {
+  connect: function() {
+    return DebuggerServer.connectToChild(this._conn, this._browser.messageManager);
+  },
+
+  form: function() {
+    return this._form;
+  },
+
+  exit: function() {
+    this._browser = null;
+  },
+};
+
 function BrowserAddonList(aConnection)
 {
   this._connection = aConnection;
   this._actorByAddonId = new Map();
   this._onListChanged = null;
 }
 
 BrowserAddonList.prototype.getList = function() {