Bug 1702406 - [remote] Rename targets to targetList in remote codebase r=remote-protocol-reviewers,jgraham

Differential Revision: https://phabricator.services.mozilla.com/D110514
This commit is contained in:
Julian Descottes 2021-04-01 12:27:25 +00:00
Родитель 4958e37ada
Коммит 3382fe303e
9 изменённых файлов: 41 добавлений и 41 удалений

Просмотреть файл

@ -31,7 +31,7 @@ class JSONHandler {
}
getVersion() {
const mainProcessTarget = this.agent.targets.getMainProcessTarget();
const mainProcessTarget = this.agent.targetList.getMainProcessTarget();
const { userAgent } = Cc[
"@mozilla.org/network/protocol;1?name=http"
@ -52,7 +52,7 @@ class JSONHandler {
}
getTargetList() {
return [...this.agent.targets];
return [...this.agent.targetList];
}
// nsIHttpRequestHandler

Просмотреть файл

@ -58,10 +58,10 @@ class Target extends Domain {
}
getTargets() {
const { targets } = this.session.target;
const { targetList } = this.session.target;
const targetInfos = [];
for (const target of targets) {
for (const target of targetList) {
if (target instanceof MainProcessTarget) {
continue;
}
@ -73,22 +73,22 @@ class Target extends Domain {
}
setDiscoverTargets({ discover }) {
const { targets } = this.session.target;
const { targetList } = this.session.target;
if (discover) {
targets.on("target-created", this._onTargetCreated);
targets.on("target-destroyed", this._onTargetDestroyed);
targetList.on("target-created", this._onTargetCreated);
targetList.on("target-destroyed", this._onTargetDestroyed);
} else {
targets.off("target-created", this._onTargetCreated);
targets.off("target-destroyed", this._onTargetDestroyed);
targetList.off("target-created", this._onTargetCreated);
targetList.off("target-destroyed", this._onTargetDestroyed);
}
for (const target of targets) {
for (const target of targetList) {
this._onTargetCreated("target-created", target);
}
}
async createTarget({ browserContextId }) {
const { targets } = this.session.target;
const onTarget = targets.once("target-created");
const { targetList } = this.session.target;
const onTarget = targetList.once("target-created");
const tab = TabManager.addTab({ userContextId: browserContextId });
const target = await onTarget;
if (tab.linkedBrowser != target.browser) {
@ -100,8 +100,8 @@ class Target extends Domain {
}
closeTarget({ targetId }) {
const { targets } = this.session.target;
const target = targets.getById(targetId);
const { targetList } = this.session.target;
const target = targetList.getById(targetId);
if (!target) {
throw new Error(`Unable to find target with id '${targetId}'`);
@ -111,8 +111,8 @@ class Target extends Domain {
}
async activateTarget({ targetId }) {
const { targets, window } = this.session.target;
const target = targets.getById(targetId);
const { targetList, window } = this.session.target;
const target = targetList.getById(targetId);
if (!target) {
throw new Error(`Unable to find target with id '${targetId}'`);
@ -124,8 +124,8 @@ class Target extends Domain {
}
attachToTarget({ targetId }) {
const { targets } = this.session.target;
const target = targets.getById(targetId);
const { targetList } = this.session.target;
const target = targetList.getById(targetId);
if (!target) {
throw new Error(`Unable to find target with id '${targetId}'`);

Просмотреть файл

@ -25,10 +25,10 @@ XPCOMUtils.defineLazyModuleGetters(this, {
*/
class MainProcessTarget extends Target {
/*
* @param Targets targets
* @param TargetList targetList
*/
constructor(targets) {
super(targets, MainProcessSession);
constructor(targetList) {
super(targetList, MainProcessSession);
this.type = "browser";

Просмотреть файл

@ -29,11 +29,11 @@ XPCOMUtils.defineLazyServiceGetter(
*/
class TabTarget extends Target {
/**
* @param Targets targets
* @param TargetList targetList
* @param BrowserElement browser
*/
constructor(targets, browser) {
super(targets, TabSession);
constructor(targetList, browser) {
super(targetList, TabSession);
this.browser = browser;

Просмотреть файл

@ -24,17 +24,17 @@ XPCOMUtils.defineLazyServiceGetter(
);
/**
* Base class for all the Targets.
* Base class for all the targets.
*/
class Target {
/**
* @param Targets targets
* @param TargetList targetList
* @param Class sessionClass
*/
constructor(targets, sessionClass) {
// Save a reference to Targets instance in order to expose it to:
constructor(targetList, sessionClass) {
// Save a reference to TargetList instance in order to expose it to:
// domains/parent/Target.jsm
this.targets = targets;
this.targetList = targetList;
// When a new connection is made to this target,
// we will instantiate a new session based on this given class.

Просмотреть файл

@ -22,7 +22,7 @@ add_task(async function json_version() {
is(json["WebKit-Version"], "1.0", "Webkit version found");
is(
json.webSocketDebuggerUrl,
RemoteAgent.targets.getMainProcessTarget().wsDebuggerURL,
RemoteAgent.targetList.getMainProcessTarget().wsDebuggerURL,
"Websocket URL for main process target found"
);
});

Просмотреть файл

@ -6,7 +6,7 @@
// Test very basic CDP features.
add_task(async function({ CDP }) {
const { mainProcessTarget } = RemoteAgent.targets;
const { mainProcessTarget } = RemoteAgent.targetList;
ok(
mainProcessTarget,
"The main process target is instantiated after the call to `listen`"

Просмотреть файл

@ -91,11 +91,11 @@ class RemoteAgentClass {
this.server = new HttpServer();
this.server.registerPrefixHandler("/json/", new JSONHandler(this));
this.targets = new TargetList();
this.targets.on("target-created", (eventName, target) => {
this.targetList = new TargetList();
this.targetList.on("target-created", (eventName, target) => {
this.server.registerPathHandler(target.path, target);
});
this.targets.on("target-destroyed", (eventName, target) => {
this.targetList.on("target-destroyed", (eventName, target) => {
this.server.registerPathHandler(target.path, null);
});
@ -104,11 +104,11 @@ class RemoteAgentClass {
async asyncListen(host, port) {
try {
await this.targets.watchForTargets();
await this.targetList.watchForTargets();
// Immediatly instantiate the main process target in order
// to be accessible via HTTP endpoint on startup
const mainTarget = this.targets.getMainProcessTarget();
const mainTarget = this.targetList.getMainProcessTarget();
this.server._start(port, host);
Services.obs.notifyObservers(
@ -130,10 +130,10 @@ class RemoteAgentClass {
}
this.alteredPrefs.clear();
// destroy targets before stopping server,
// destroy targetList before stopping server,
// otherwise the HTTP will fail to stop
if (this.targets) {
this.targets.destructor();
if (this.targetList) {
this.targetList.destructor();
}
if (this.listening) {
@ -144,7 +144,7 @@ class RemoteAgentClass {
log.error("unable to stop listener", e);
} finally {
this.server = null;
this.targets = null;
this.targetList = null;
}
return Promise.resolve();

Просмотреть файл

@ -76,7 +76,7 @@ This is what it looks like all put together:
info("Current URL: " + tab.linkedBrowser.currentURI.spec);
// manually connect to a specific target
const { mainProcessTarget } = RemoteAgent.targets;
const { mainProcessTarget } = RemoteAgent.targetList;
const target = mainProcessTarget.wsDebuggerURL;
const client = await CDP({ target });