Bug 1473513 - remove other instances of ActorPool from browsingContext and root; r=ochameau

MozReview-Commit-ID: GxkLzvxJgdY

Depends on D6471

Differential Revision: https://phabricator.services.mozilla.com/D6472

--HG--
extra : moz-landing-system : lando
This commit is contained in:
yulia 2018-09-25 08:04:41 +00:00
parent de5a5707d6
commit 54d3f62aa0
6 changed files with 26 additions and 72 deletions

View File

@ -8,26 +8,6 @@
const { method } = require("devtools/shared/protocol");
/**
* Append the extra actors in |this._extraActors|, constructed by a prior call
* to CommonCreateExtraActors, to |object|.
*
* @param object
* The object to which the extra actors should be added, under the
* property names given in the |factories| table passed to
* CommonCreateExtraActors.
*
* @param this
* The RootActor or BrowsingContextTargetActor whose |_extraActors| table we
* should use; see above.
*/
exports.appendExtraActors = function appendExtraActors(object) {
for (const name in this._extraActors) {
const actor = this._extraActors[name];
object[name] = actor.actorID;
}
};
/**
* Construct an ActorPool.
*

View File

@ -8,7 +8,6 @@
const { Cu } = require("chrome");
const Services = require("Services");
const { ActorPool, appendExtraActors } = require("devtools/server/actors/common");
const { Pool } = require("devtools/shared/protocol");
const { LazyPool, createExtraActors } = require("devtools/shared/protocol/lazy-pool");
const { DebuggerServer } = require("devtools/server/main");
@ -234,20 +233,17 @@ RootActor.prototype = {
* and didn't actually care about tabs.
*/
onGetRoot: function() {
const reply = {
from: this.actorID,
};
// Create global actors
if (!this._globalActorPool) {
this._globalActorPool = new LazyPool(this.conn);
}
createExtraActors(this._parameters.globalActorFactories, this._globalActorPool, this);
const actors = createExtraActors(
this._parameters.globalActorFactories,
this._globalActorPool,
this
);
// List the global actors
this._appendExtraActors(reply);
return reply;
return actors;
},
/* The 'listTabs' request and the 'tabListChanged' notification. */
@ -274,10 +270,10 @@ RootActor.prototype = {
tabList.onListChanged = this._onTabListChanged;
// Walk the tab list, accumulating the array of target actors for the reply, and
// moving all the actors to a new ActorPool. We'll replace the old tab target actor
// moving all the actors to a new Pool. We'll replace the old tab target actor
// pool with the one we build here, thus retiring any actors that didn't get listed
// again, and preparing any new actors to receive packets.
const newActorPool = new ActorPool(this.conn);
const newActorPool = new Pool(this.conn);
const targetActorList = [];
let selected;
@ -292,7 +288,7 @@ RootActor.prototype = {
selected = targetActorList.length;
}
targetActor.parentID = this.actorID;
newActorPool.addActor(targetActor);
newActorPool.manage(targetActor);
targetActorList.push(targetActor);
}
@ -302,10 +298,9 @@ RootActor.prototype = {
// Drop the old actorID -> actor map. Actors that still mattered were added to the
// new map; others will go away.
if (this._tabTargetActorPool) {
this.conn.removeActorPool(this._tabTargetActorPool);
this._tabTargetActorPool.destroy();
}
this._tabTargetActorPool = newActorPool;
this.conn.addActorPool(this._tabTargetActorPool);
// We'll extend the reply here to also mention all the tabs.
Object.assign(reply, {
@ -323,8 +318,7 @@ RootActor.prototype = {
message: "This root actor has no browser tabs." };
}
if (!this._tabTargetActorPool) {
this._tabTargetActorPool = new ActorPool(this.conn);
this.conn.addActorPool(this._tabTargetActorPool);
this._tabTargetActorPool = new Pool(this.conn);
}
let targetActor;
@ -342,7 +336,7 @@ RootActor.prototype = {
}
targetActor.parentID = this.actorID;
this._tabTargetActorPool.addActor(targetActor);
this._tabTargetActorPool.manage(targetActor);
return { tab: targetActor.form() };
},
@ -365,13 +359,12 @@ RootActor.prototype = {
}
if (!this._chromeWindowActorPool) {
this._chromeWindowActorPool = new ActorPool(this.conn);
this.conn.addActorPool(this._chromeWindowActorPool);
this._chromeWindowActorPool = new Pool(this.conn);
}
const actor = new ChromeWindowTargetActor(this.conn, window);
actor.parentID = this.actorID;
this._chromeWindowActorPool.addActor(actor);
this._chromeWindowActorPool.manage(actor);
return {
from: this.actorID,
@ -396,16 +389,15 @@ RootActor.prototype = {
addonList.onListChanged = this._onAddonListChanged;
return addonList.getList().then((addonTargetActors) => {
const addonTargetActorPool = new ActorPool(this.conn);
const addonTargetActorPool = new Pool(this.conn);
for (const addonTargetActor of addonTargetActors) {
addonTargetActorPool.addActor(addonTargetActor);
addonTargetActorPool.manage(addonTargetActor);
}
if (this._addonTargetActorPool) {
this.conn.removeActorPool(this._addonTargetActorPool);
this._addonTargetActorPool.destroy();
}
this._addonTargetActorPool = addonTargetActorPool;
this.conn.addActorPool(this._addonTargetActorPool);
return {
"from": this.actorID,
@ -466,14 +458,15 @@ RootActor.prototype = {
registrationList.onListChanged = this._onServiceWorkerRegistrationListChanged;
return registrationList.getList().then(actors => {
const pool = new ActorPool(this.conn);
const pool = new Pool(this.conn);
for (const actor of actors) {
pool.addActor(actor);
pool.manage(actor);
}
this.conn.removeActorPool(this._serviceWorkerRegistrationActorPool);
if (this._serviceWorkerRegistrationActorPool) {
this._serviceWorkerRegistrationActorPool.destroy();
}
this._serviceWorkerRegistrationActorPool = pool;
this.conn.addActorPool(this._serviceWorkerRegistrationActorPool);
return {
"from": this.actorID,
@ -563,9 +556,6 @@ RootActor.prototype = {
return require("devtools/shared/protocol").dumpProtocolSpec();
},
/* Support for DebuggerServer.addGlobalActor. */
_appendExtraActors: appendExtraActors,
/**
* Remove the extra actor (added by DebuggerServer.addGlobalActor or
* DebuggerServer.addTargetScopedActor) name |name|.
@ -579,9 +569,9 @@ RootActor.prototype = {
if (this._tabTargetActorPool) {
// Iterate over BrowsingContextTargetActor instances to also remove target-scoped
// actors created during listTabs for each document.
this._tabTargetActorPool.forEach(tab => {
for (const tab in this._tabTargetActorPool.poolChildren()) {
tab.removeActorByName(name);
});
}
}
delete this._extraActors[name];
}

View File

@ -23,7 +23,6 @@
var { Ci, Cu, Cr, Cc } = require("chrome");
var Services = require("Services");
const ChromeUtils = require("ChromeUtils");
var { appendExtraActors } = require("devtools/server/actors/common");
var { DebuggerServer } = require("devtools/server/main");
var DevToolsUtils = require("devtools/shared/DevToolsUtils");
var { assert } = DevToolsUtils;
@ -562,9 +561,6 @@ const browsingContextTargetPrototype = {
return false;
},
/* Support for DebuggerServer.addTargetScopedActor. */
_appendExtraActors: appendExtraActors,
/**
* Does the actual work of attaching to a browsing context.
*/

View File

@ -3,7 +3,6 @@
"use strict";
const { appendExtraActors } = require("devtools/server/actors/common");
const { LazyPool, createExtraActors } = require("devtools/shared/protocol/lazy-pool");
const { RootActor } = require("devtools/server/actors/root");
const { ThreadActor } = require("devtools/server/actors/thread");
@ -152,9 +151,6 @@ TestTargetActor.prototype = {
}
delete this._extraActors[name];
},
/* Support for DebuggerServer.addTargetScopedActor. */
_appendExtraActors: appendExtraActors
};
TestTargetActor.prototype.requestTypes = {

View File

@ -3,7 +3,6 @@
"use strict";
const { appendExtraActors } = require("devtools/server/actors/common");
const { LazyPool, createExtraActors } = require("devtools/shared/protocol/lazy-pool");
const { RootActor } = require("devtools/server/actors/root");
const { ThreadActor } = require("devtools/server/actors/thread");
@ -109,10 +108,7 @@ TestTargetActor.prototype = {
return { "error": "wrongState" };
}
return { type: "detached" };
},
/* Support for DebuggerServer.addTargetScopedActor. */
_appendExtraActors: appendExtraActors
}
};
TestTargetActor.prototype.requestTypes = {

View File

@ -2,7 +2,6 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { appendExtraActors } = require("devtools/server/actors/common");
const { LazyPool, createExtraActors } = require("devtools/shared/protocol/lazy-pool");
const { RootActor } = require("devtools/server/actors/root");
const { ThreadActor } = require("devtools/server/actors/thread");
@ -107,10 +106,7 @@ TestTargetActor.prototype = {
return { "error": "wrongState" };
}
return { type: "detached" };
},
/* Support for DebuggerServer.addTargetScopedActor. */
_appendExtraActors: appendExtraActors
}
};
TestTargetActor.prototype.requestTypes = {