зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1818080 - [remote] Add profile markers for CDP, Marionette and WebDriver BiDi commands and events. r=webdriver-reviewers,canaltinova,jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D174211
This commit is contained in:
Родитель
3cc6661196
Коммит
9d12970ac8
|
@ -292,3 +292,10 @@
|
|||
subcategories:
|
||||
- name: TIMER
|
||||
label: Other
|
||||
|
||||
- name: REMOTE_PROTOCOL
|
||||
label: Remote-Protocol
|
||||
color: grey
|
||||
subcategories:
|
||||
- name: REMOTE_PROTOCOL
|
||||
label: Other
|
||||
|
|
|
@ -95,13 +95,21 @@ export class CDPConnection extends WebSocketConnection {
|
|||
* followed by the event name, e.g. `Target.targetCreated`.
|
||||
* @param {Object} params
|
||||
* A JSON-serializable object, which is the payload of this event.
|
||||
* @param {Sting=} sessionId
|
||||
* @param {String=} sessionId
|
||||
* The sessionId from which this packet is emitted. Falls back to the
|
||||
* default session if not specified.
|
||||
*/
|
||||
sendEvent(method, params, sessionId) {
|
||||
this.send({ method, params, sessionId });
|
||||
|
||||
if (Services.profiler?.IsActive()) {
|
||||
ChromeUtils.addProfilerMarker(
|
||||
"CDP: Event",
|
||||
{ category: "Remote-Protocol" },
|
||||
method
|
||||
);
|
||||
}
|
||||
|
||||
// When a client attaches to a secondary target via
|
||||
// `Target.attachToTarget`, we should emit an event back with the
|
||||
// result including the `sessionId` attribute of this secondary target's
|
||||
|
@ -206,9 +214,10 @@ export class CDPConnection extends WebSocketConnection {
|
|||
async onPacket(packet) {
|
||||
super.onPacket(packet);
|
||||
|
||||
try {
|
||||
const { id, method, params, sessionId } = packet;
|
||||
const { id, method, params, sessionId } = packet;
|
||||
const startTime = Cu.now();
|
||||
|
||||
try {
|
||||
// First check for mandatory field in the packets
|
||||
if (typeof id == "undefined") {
|
||||
throw new TypeError("Message missing 'id' field");
|
||||
|
@ -244,7 +253,15 @@ export class CDPConnection extends WebSocketConnection {
|
|||
const result = await session.execute(id, domain, command, params);
|
||||
this.sendResult(id, result, sessionId);
|
||||
} catch (e) {
|
||||
this.sendError(packet.id, e, packet.sessionId);
|
||||
this.sendError(id, e, packet.sessionId);
|
||||
}
|
||||
|
||||
if (Services.profiler?.IsActive()) {
|
||||
ChromeUtils.addProfilerMarker(
|
||||
"CDP: Command",
|
||||
{ startTime, category: "Remote-Protocol" },
|
||||
`${method} (${id})`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -290,6 +290,8 @@ export class TCPConnection {
|
|||
* A command's implementation may throw at any time.
|
||||
*/
|
||||
async despatch(cmd, resp) {
|
||||
const startTime = Cu.now();
|
||||
|
||||
let fn = this.driver.commands[cmd.name];
|
||||
if (typeof fn == "undefined") {
|
||||
throw new lazy.error.UnknownCommandError(cmd.name);
|
||||
|
@ -335,6 +337,14 @@ export class TCPConnection {
|
|||
resp.body.value = rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (Services.profiler?.IsActive()) {
|
||||
ChromeUtils.addProfilerMarker(
|
||||
"Marionette: Command",
|
||||
{ startTime, category: "Remote-Protocol" },
|
||||
`${cmd.name} (${cmd.id})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -97,6 +97,14 @@ export class WebDriverBiDiConnection extends WebSocketConnection {
|
|||
*/
|
||||
sendEvent(method, params) {
|
||||
this.send({ method, params });
|
||||
|
||||
if (Services.profiler?.IsActive()) {
|
||||
ChromeUtils.addProfilerMarker(
|
||||
"BiDi: Event",
|
||||
{ category: "Remote-Protocol" },
|
||||
method
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,6 +145,7 @@ export class WebDriverBiDiConnection extends WebSocketConnection {
|
|||
super.onPacket(packet);
|
||||
|
||||
const { id, method, params } = packet;
|
||||
const startTime = Cu.now();
|
||||
|
||||
try {
|
||||
// First check for mandatory field in the command packet
|
||||
|
@ -171,7 +180,15 @@ export class WebDriverBiDiConnection extends WebSocketConnection {
|
|||
|
||||
this.sendResult(id, result);
|
||||
} catch (e) {
|
||||
this.sendError(packet.id, e);
|
||||
this.sendError(id, e);
|
||||
}
|
||||
|
||||
if (Services.profiler?.IsActive()) {
|
||||
ChromeUtils.addProfilerMarker(
|
||||
"BiDi: Command",
|
||||
{ startTime, category: "Remote-Protocol" },
|
||||
`${method} (${id})`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче