Bug 1473513 - refactor main.js to use protocol.js pools; r=ochameau
☠☠ backed out by 98b5ff9533ee ☠ ☠
authoryulia <ystartsev@mozilla.com>
Thu, 09 Aug 2018 11:45:00 +0200
changeset 487949 5bf38cfa04f93fbf001a1625735f9787d232e760
parent 487948 6e157bea362acd8a51fdf4863ebb38dbe6e74df6
child 487950 deb8812556ef956417c81f6db7df15ff04dbbe9f
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1473513
milestone63.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 1473513 - refactor main.js to use protocol.js pools; r=ochameau MozReview-Commit-ID: FNMK4f553yI
devtools/client/debugger/test/mochitest/browser_dbg_globalactor.js
devtools/server/main.js
devtools/server/tests/unit/test_protocol_children.js
--- a/devtools/client/debugger/test/mochitest/browser_dbg_globalactor.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_globalactor.js
@@ -39,19 +39,21 @@ add_task(async function() {
   is(response.pong, "pong", "Actor should respond to requests.");
 
   // Make sure that lazily-created actors are created only once.
   let count = 0;
   for (const connID of Object.getOwnPropertyNames(DebuggerServer._connections)) {
     const conn = DebuggerServer._connections[connID];
     const actorPrefix = conn._prefix + "testOne";
     for (let pool of conn._extraPools) {
-      count += Object.keys(pool._actors).filter(e => {
-        return e.startsWith(actorPrefix);
-      }).length;
+      for (const actor of pool.poolChildren()) {
+        if (actor.actorID.startsWith(actorPrefix)) {
+          count++;
+        }
+      }
     }
   }
 
   is(count, 1,
     "Only one actor exists in all pools. One global actor.");
 
   await client.close();
 });
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -5,17 +5,17 @@
 "use strict";
 
 /**
  * Toolkit glue for the remote debugging protocol, loaded into the
  * debugging global.
  */
 var { Ci, Cc } = require("chrome");
 var Services = require("Services");
-var { ActorPool } = require("devtools/server/actors/common");
+var { Pool } = require("devtools/shared/protocol");
 var { ActorRegistry } = require("devtools/server/actor-registry");
 var DevToolsUtils = require("devtools/shared/DevToolsUtils");
 var { dumpn } = DevToolsUtils;
 
 loader.lazyRequireGetter(this, "DebuggerSocket", "devtools/shared/security/socket", true);
 loader.lazyRequireGetter(this, "Authentication", "devtools/shared/security/auth");
 loader.lazyRequireGetter(this, "LocalDebuggerTransport", "devtools/shared/transport/local-transport", true);
 loader.lazyRequireGetter(this, "ChildDebuggerTransport", "devtools/shared/transport/child-transport", true);
@@ -966,17 +966,17 @@ exports.DebuggerServer = DebuggerServer;
  *        Packet transport for the debugging protocol.
  */
 function DebuggerServerConnection(prefix, transport) {
   this._prefix = prefix;
   this._transport = transport;
   this._transport.hooks = this;
   this._nextID = 1;
 
-  this._actorPool = new ActorPool(this);
+  this._actorPool = new Pool(this);
   this._extraPools = [this._actorPool];
 
   // Responses to a given actor must be returned the the client
   // in the same order as the requests that they're replying to, but
   // Implementations might finish serving requests in a different
   // order.  To keep things in order we generate a promise for each
   // request, chained to the promise for the request before it.
   // This map stores the latest request promise in the chain, keyed
@@ -1078,24 +1078,24 @@ DebuggerServerConnection.prototype = {
       }
     }
   },
 
   /**
    * Add an actor to the default actor pool for this connection.
    */
   addActor(actor) {
-    this._actorPool.addActor(actor);
+    this._actorPool.manage(actor);
   },
 
   /**
    * Remove an actor to the default actor pool for this connection.
    */
   removeActor(actor) {
-    this._actorPool.removeActor(actor);
+    this._actorPool.unmanage(actor);
   },
 
   /**
    * Match the api expected by the protocol library.
    */
   unmanage(actor) {
     return this.removeActor(actor);
   },
--- a/devtools/server/tests/unit/test_protocol_children.js
+++ b/devtools/server/tests/unit/test_protocol_children.js
@@ -243,18 +243,16 @@ var RootActor = protocol.ActorClassWithS
     return "[root actor]";
   },
 
   initialize: function(conn) {
     rootActor = this;
     this.actorID = "root";
     this._children = {};
     protocol.Actor.prototype.initialize.call(this, conn);
-    // Root actor owns itself.
-    this.manage(this);
   },
 
   sayHello: simpleHello,
 
   getChild: function(id) {
     if (id in this._children) {
       return this._children[id];
     }
@@ -349,17 +347,17 @@ function run_test() {
                          "applicationType": "xpcshell-tests",
                          "traits": []});
     Assert.equal(applicationType, "xpcshell-tests");
 
     const rootFront = RootFront(client);
     let childFront = null;
 
     const expectRootChildren = size => {
-      Assert.equal(rootActor._poolMap.size, size + 1);
+      Assert.equal(rootActor._poolMap.size, size);
       Assert.equal(rootFront._poolMap.size, size + 1);
       if (childFront) {
         Assert.equal(childFront._poolMap.size, 0);
       }
     };
 
     rootFront.getChild("child1").then(ret => {
       trace.expectSend({"type": "getChild", "str": "child1", "to": "<actorid>"});