From dd29e366ea4eda0aee80792acf4c99c9ec570b01 Mon Sep 17 00:00:00 2001 From: yulia Date: Wed, 26 Sep 2018 10:07:27 +0200 Subject: [PATCH] Bug 1473513 - refactor main.js to use protocol.js pools; r=ochameau Summary: MozReview-Commit-ID: FNMK4f553yI Depends on D6474 Reviewers: ochameau Reviewed By: ochameau Bug #: 1473513 Differential Revision: https://phabricator.services.mozilla.com/D6475 --HG-- extra : rebase_source : c61d394da0a20991def49968f01ee563fea9afde --- .../debugger/test/mochitest/browser_dbg_globalactor.js | 8 +++++--- devtools/server/main.js | 8 ++++---- devtools/server/tests/unit/test_protocol_children.js | 4 +--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_globalactor.js b/devtools/client/debugger/test/mochitest/browser_dbg_globalactor.js index ffb36a827984..9ec53d7bd11d 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_globalactor.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_globalactor.js @@ -44,9 +44,11 @@ add_task(async function() { 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++; + } + } } } diff --git a/devtools/server/main.js b/devtools/server/main.js index 1963872701a7..0e5a9ccc7ac4 100644 --- a/devtools/server/main.js +++ b/devtools/server/main.js @@ -10,7 +10,7 @@ */ 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; @@ -981,7 +981,7 @@ function DebuggerServerConnection(prefix, 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 @@ -1093,14 +1093,14 @@ 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); }, /** diff --git a/devtools/server/tests/unit/test_protocol_children.js b/devtools/server/tests/unit/test_protocol_children.js index d9f694bf8b39..55ff49a69732 100644 --- a/devtools/server/tests/unit/test_protocol_children.js +++ b/devtools/server/tests/unit/test_protocol_children.js @@ -248,8 +248,6 @@ var RootActor = protocol.ActorClassWithSpec(rootSpec, { this.actorID = "root"; this._children = {}; protocol.Actor.prototype.initialize.call(this, conn); - // Root actor owns itself. - this.manage(this); }, sayHello: simpleHello, @@ -354,7 +352,7 @@ function run_test() { 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);