diff --git a/devtools/server/actors/root.js b/devtools/server/actors/root.js index 60970a290619..7bf54c1483f2 100644 --- a/devtools/server/actors/root.js +++ b/devtools/server/actors/root.js @@ -9,7 +9,6 @@ const { Cu } = require("chrome"); const Services = require("Services"); const { ActorPool, appendExtraActors, createExtraActors } = require("devtools/server/actors/common"); -const { Pool } = require("devtools/shared/protocol"); const { DebuggerServer } = require("devtools/server/main"); loader.lazyRequireGetter(this, "ChromeWindowTargetActor", @@ -431,18 +430,14 @@ RootActor.prototype = { workerList.onListChanged = this._onWorkerListChanged; return workerList.getList().then(actors => { - const pool = new Pool(this.conn); + const pool = new ActorPool(this.conn); for (const actor of actors) { - pool.manage(actor); - } - - // Do not destroy the pool before transfering ownership to the newly created - // pool, so that we do not accidently destroy actors that are still in use. - if (this._workerTargetActorPool) { - this._workerTargetActorPool.destroy(); + pool.addActor(actor); } + this.conn.removeActorPool(this._workerTargetActorPool); this._workerTargetActorPool = pool; + this.conn.addActorPool(this._workerTargetActorPool); return { "from": this.actorID, diff --git a/devtools/server/actors/targets/browsing-context.js b/devtools/server/actors/targets/browsing-context.js index 79f1c36c6b3a..dbaf2ded0401 100644 --- a/devtools/server/actors/targets/browsing-context.js +++ b/devtools/server/actors/targets/browsing-context.js @@ -41,7 +41,7 @@ const { LocalizationHelper } = require("devtools/shared/l10n"); const STRINGS_URI = "devtools/shared/locales/browsing-context.properties"; const L10N = new LocalizationHelper(STRINGS_URI); -const { ActorClassWithSpec, Actor, Pool } = require("devtools/shared/protocol"); +const { ActorClassWithSpec, Actor } = require("devtools/shared/protocol"); const { browsingContextTargetSpec } = require("devtools/shared/specs/targets/browsing-context"); loader.lazyRequireGetter(this, "ThreadActor", "devtools/server/actors/thread", true); @@ -651,18 +651,15 @@ const browsingContextTargetPrototype = { } return this._workerTargetActorList.getList().then((actors) => { - const pool = new Pool(this.conn); + const pool = new ActorPool(this.conn); for (const actor of actors) { - pool.manage(actor); - } - - // Do not destroy the pool before transfering ownership to the newly created - // pool, so that we do not accidently destroy actors that are still in use. - if (this._workerTargetActorPool) { - this._workerTargetActorPool.destroy(); + pool.addActor(actor); } + this.conn.removeActorPool(this._workerTargetActorPool); this._workerTargetActorPool = pool; + this.conn.addActorPool(this._workerTargetActorPool); + this._workerTargetActorList.onListChanged = this._onWorkerTargetActorListChanged; return { @@ -902,7 +899,7 @@ const browsingContextTargetPrototype = { } if (this._workerTargetActorPool !== null) { - this._workerTargetActorPool.destroy(); + this.conn.removeActorPool(this._workerTargetActorPool); this._workerTargetActorPool = null; } diff --git a/devtools/server/actors/targets/content-process.js b/devtools/server/actors/targets/content-process.js index a3661e37f569..1a14ea471815 100644 --- a/devtools/server/actors/targets/content-process.js +++ b/devtools/server/actors/targets/content-process.js @@ -18,7 +18,6 @@ const { ChromeDebuggerActor } = require("devtools/server/actors/thread"); const { WebConsoleActor } = require("devtools/server/actors/webconsole"); const makeDebugger = require("devtools/server/actors/utils/make-debugger"); const { ActorPool } = require("devtools/server/actors/common"); -const { Pool } = require("devtools/shared/protocol"); const { assert } = require("devtools/shared/DevToolsUtils"); const { TabSources } = require("devtools/server/actors/utils/TabSources"); @@ -121,18 +120,15 @@ ContentProcessTargetActor.prototype = { this._workerList = new WorkerTargetActorList(this.conn, {}); } return this._workerList.getList().then(actors => { - const pool = new Pool(this.conn); + const pool = new ActorPool(this.conn); for (const actor of actors) { - pool.manage(actor); - } - - // Do not destroy the pool before transfering ownership to the newly created - // pool, so that we do not accidently destroy actors that are still in use. - if (this._workerTargetActorPool) { - this._workerTargetActorPool.destroy(); + pool.addActor(actor); } + this.conn.removeActorPool(this._workerTargetActorPool); this._workerTargetActorPool = pool; + this.conn.addActorPool(this._workerTargetActorPool); + this._workerList.onListChanged = this._onWorkerListChanged; return { diff --git a/devtools/shared/protocol.js b/devtools/shared/protocol.js index a61ca78bb38a..8d0e87304e0a 100644 --- a/devtools/shared/protocol.js +++ b/devtools/shared/protocol.js @@ -857,12 +857,6 @@ Pool.prototype = extend(EventEmitter.prototype, { actor.actorID = this.conn.allocID(actor.actorPrefix || actor.typeName); } - // If the actor is already in a pool, remove it without destroying it. - const parent = actor.parent(); - if (parent) { - parent.unmanage(actor); - } - this._poolMap.set(actor.actorID, actor); return actor; },