зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1671676 - [devtools] Remove setupInChild from DevTools codebase r=ochameau
Depends on D93820 This is no longer used, except in one test which will be cleaned up in the next changeset. Differential Revision: https://phabricator.services.mozilla.com/D93821
This commit is contained in:
Родитель
998b2a78f6
Коммит
aef14fc3b4
|
@ -60,7 +60,6 @@ function connectToFrame(connection, frame, onDestroy, { addonId } = {}) {
|
||||||
if (!actor) {
|
if (!actor) {
|
||||||
mm.addMessageListener("debug:actor", onActorCreated);
|
mm.addMessageListener("debug:actor", onActorCreated);
|
||||||
}
|
}
|
||||||
DevToolsServer._childMessageManagers.add(mm);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const untrackMessageManager = () => {
|
const untrackMessageManager = () => {
|
||||||
|
@ -72,7 +71,6 @@ function connectToFrame(connection, frame, onDestroy, { addonId } = {}) {
|
||||||
if (!actor) {
|
if (!actor) {
|
||||||
mm.removeMessageListener("debug:actor", onActorCreated);
|
mm.removeMessageListener("debug:actor", onActorCreated);
|
||||||
}
|
}
|
||||||
DevToolsServer._childMessageManagers.delete(mm);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let actor, childTransport;
|
let actor, childTransport;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var { Ci, Cc } = require("chrome");
|
var { Ci } = require("chrome");
|
||||||
var Services = require("Services");
|
var Services = require("Services");
|
||||||
var { ActorRegistry } = require("devtools/server/actors/utils/actor-registry");
|
var { ActorRegistry } = require("devtools/server/actors/utils/actor-registry");
|
||||||
var DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
var DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||||
|
@ -46,14 +46,6 @@ loader.lazyRequireGetter(
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
loader.lazyGetter(this, "generateUUID", () => {
|
|
||||||
// eslint-disable-next-line no-shadow
|
|
||||||
const { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService(
|
|
||||||
Ci.nsIUUIDGenerator
|
|
||||||
);
|
|
||||||
return generateUUID;
|
|
||||||
});
|
|
||||||
|
|
||||||
const CONTENT_PROCESS_SERVER_STARTUP_SCRIPT =
|
const CONTENT_PROCESS_SERVER_STARTUP_SCRIPT =
|
||||||
"resource://devtools/server/startup/content-process.js";
|
"resource://devtools/server/startup/content-process.js";
|
||||||
|
|
||||||
|
@ -364,68 +356,6 @@ var DevToolsServer = {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* In a chrome parent process, ask all content child processes
|
|
||||||
* to execute a given module setup helper.
|
|
||||||
*
|
|
||||||
* @param module
|
|
||||||
* The module to be required
|
|
||||||
* @param setupChild
|
|
||||||
* The name of the setup helper exported by the above module
|
|
||||||
* (setup helper signature: function ({mm}) { ... })
|
|
||||||
* @param waitForEval (optional)
|
|
||||||
* If true, the returned promise only resolves once code in child
|
|
||||||
* is evaluated
|
|
||||||
*/
|
|
||||||
setupInChild({ module, setupChild, args, waitForEval }) {
|
|
||||||
if (this._childMessageManagers.size == 0) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
return new Promise(done => {
|
|
||||||
// If waitForEval is set, pass a unique id and expect child.js to send
|
|
||||||
// a message back once the code in child is evaluated.
|
|
||||||
if (typeof waitForEval != "boolean") {
|
|
||||||
waitForEval = false;
|
|
||||||
}
|
|
||||||
let count = this._childMessageManagers.size;
|
|
||||||
const id = waitForEval ? generateUUID().toString() : null;
|
|
||||||
|
|
||||||
this._childMessageManagers.forEach(mm => {
|
|
||||||
if (waitForEval) {
|
|
||||||
// Listen for the end of each child execution
|
|
||||||
const evalListener = msg => {
|
|
||||||
if (msg.data.id !== id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mm.removeMessageListener(
|
|
||||||
"debug:setup-in-child-response",
|
|
||||||
evalListener
|
|
||||||
);
|
|
||||||
if (--count === 0) {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
mm.addMessageListener("debug:setup-in-child-response", evalListener);
|
|
||||||
}
|
|
||||||
mm.sendAsyncMessage("debug:setup-in-child", {
|
|
||||||
module: module,
|
|
||||||
setupChild: setupChild,
|
|
||||||
args: args,
|
|
||||||
id: id,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!waitForEval) {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Live list of all currently attached child's message managers.
|
|
||||||
*/
|
|
||||||
_childMessageManagers: new Set(),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new debugger connection for the given transport. Called after
|
* Create a new debugger connection for the given transport. Called after
|
||||||
* connectPipe(), from connectToParent, or from an incoming socket
|
* connectPipe(), from connectToParent, or from an incoming socket
|
||||||
|
|
|
@ -90,40 +90,6 @@ try {
|
||||||
|
|
||||||
addMessageListener("debug:connect", onConnect);
|
addMessageListener("debug:connect", onConnect);
|
||||||
|
|
||||||
// Allows executing module setup helper from the parent process.
|
|
||||||
// See also: DevToolsServer.setupInChild()
|
|
||||||
const onSetupInChild = DevToolsUtils.makeInfallible(msg => {
|
|
||||||
const { module, setupChild, args } = msg.data;
|
|
||||||
let m;
|
|
||||||
|
|
||||||
try {
|
|
||||||
m = require(module);
|
|
||||||
|
|
||||||
if (!(setupChild in m)) {
|
|
||||||
dumpn(`ERROR: module '${module}' does not export '${setupChild}'`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m[setupChild].apply(m, args);
|
|
||||||
} catch (e) {
|
|
||||||
const errorMessage =
|
|
||||||
"Exception during actor module setup running in the child process: ";
|
|
||||||
DevToolsUtils.reportException(errorMessage + e);
|
|
||||||
dumpn(
|
|
||||||
`ERROR: ${errorMessage}\n\t module: '${module}'\n\t ` +
|
|
||||||
`setupChild: '${setupChild}'\n${DevToolsUtils.safeErrorString(e)}`
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (msg.data.id) {
|
|
||||||
// Send a message back to know when it is processed
|
|
||||||
sendAsyncMessage("debug:setup-in-child-response", { id: msg.data.id });
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
addMessageListener("debug:setup-in-child", onSetupInChild);
|
|
||||||
|
|
||||||
const onDisconnect = DevToolsUtils.makeInfallible(function(msg) {
|
const onDisconnect = DevToolsUtils.makeInfallible(function(msg) {
|
||||||
const prefix = msg.data.prefix;
|
const prefix = msg.data.prefix;
|
||||||
const conn = connections.get(prefix);
|
const conn = connections.get(prefix);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче