Bug 1473513 - use Protocol.js pools for workerTargetActorPool in browsingContextTargetActor; r=ochameau draft
authoryulia <ystartsev@mozilla.com>
Tue, 10 Jul 2018 17:07:54 +0200
changeset 816067 136d9ab6413d04126c98aadd8cea24edb4ecc40d
parent 815812 9f03501341bf35bc502f69f870746ffac73992ae
push id115742
push userbmo:ystartsev@mozilla.com
push dateTue, 10 Jul 2018 15:12:16 +0000
reviewersochameau
bugs1473513
milestone63.0a1
Bug 1473513 - use Protocol.js pools for workerTargetActorPool in browsingContextTargetActor; r=ochameau MozReview-Commit-ID: 5uIWwOR7CHp
devtools/server/actors/targets/browsing-context.js
--- a/devtools/server/actors/targets/browsing-context.js
+++ b/devtools/server/actors/targets/browsing-context.js
@@ -34,17 +34,17 @@ var makeDebugger = require("devtools/ser
 const InspectorUtils = require("InspectorUtils");
 
 const EXTENSION_CONTENT_JSM = "resource://gre/modules/ExtensionContent.jsm";
 
 const { LocalizationHelper } = require("devtools/shared/l10n");
 const STRINGS_URI = "devtools/shared/locales/browsing-context.properties";
 const L10N = new LocalizationHelper(STRINGS_URI);
 
-const { ActorClassWithSpec, Actor } = require("devtools/shared/protocol");
+const { ActorClassWithSpec, Actor, Pool } = require("devtools/shared/protocol");
 const { browsingContextTargetSpec } = require("devtools/shared/specs/targets/browsing-context");
 
 loader.lazyRequireGetter(this, "ThreadActor", "devtools/server/actors/thread", true);
 loader.lazyRequireGetter(this, "unwrapDebuggerObjectGlobal", "devtools/server/actors/thread", true);
 loader.lazyRequireGetter(this, "WorkerTargetActorList", "devtools/server/actors/worker/worker-list", true);
 loader.lazyImporter(this, "ExtensionContent", EXTENSION_CONTENT_JSM);
 
 loader.lazyRequireGetter(this, "StyleSheetActor", "devtools/server/actors/stylesheets", true);
@@ -651,25 +651,25 @@ const browsingContextTargetPrototype = {
     if (this._workerTargetActorList === null) {
       this._workerTargetActorList = new WorkerTargetActorList(this.conn, {
         type: Ci.nsIWorkerDebugger.TYPE_DEDICATED,
         window: this.window
       });
     }
 
     return this._workerTargetActorList.getList().then((actors) => {
-      const pool = new ActorPool(this.conn);
+      if (this._workerTargetActorPool) {
+        this._workerTargetActorPool.destroy();
+      }
+      const pool = new Pool(this.conn);
       for (const actor of actors) {
-        pool.addActor(actor);
+        pool.manage(actor);
       }
 
-      this.conn.removeActorPool(this._workerTargetActorPool);
       this._workerTargetActorPool = pool;
-      this.conn.addActorPool(this._workerTargetActorPool);
-
       this._workerTargetActorList.onListChanged = this._onWorkerTargetActorListChanged;
 
       return {
         "from": this.actorID,
         "workers": actors.map((actor) => actor.form())
       };
     });
   },
@@ -916,17 +916,17 @@ const browsingContextTargetPrototype = {
 
     // Make sure that no more workerListChanged notifications are sent.
     if (this._workerTargetActorList !== null) {
       this._workerTargetActorList.onListChanged = null;
       this._workerTargetActorList = null;
     }
 
     if (this._workerTargetActorPool !== null) {
-      this.conn.removeActorPool(this._workerTargetActorPool);
+      this._workerTargetActorPool.destroy();
       this._workerTargetActorPool = null;
     }
 
     this._attached = false;
 
     this.emit("tabDetached");
 
     return true;