зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1265727 - Decouple PerformanceFront from PerformanceActor;r=fitzgen
This commit is contained in:
Родитель
7487272df9
Коммит
ba21a67524
|
@ -59,7 +59,7 @@ loader.lazyRequireGetter(this, "DevToolsUtils",
|
|||
loader.lazyRequireGetter(this, "showDoorhanger",
|
||||
"devtools/client/shared/doorhanger", true);
|
||||
loader.lazyRequireGetter(this, "createPerformanceFront",
|
||||
"devtools/server/actors/performance", true);
|
||||
"devtools/shared/fronts/performance", true);
|
||||
loader.lazyRequireGetter(this, "system",
|
||||
"devtools/shared/system");
|
||||
loader.lazyRequireGetter(this, "getPreferenceFront",
|
||||
|
|
|
@ -5,25 +5,18 @@
|
|||
"use strict";
|
||||
|
||||
const { Cu } = require("chrome");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const { Task } = require("devtools/shared/task");
|
||||
const { Actor, custom, method, RetVal, Arg, Option, types, preEvent } = protocol;
|
||||
const { actorBridge } = require("devtools/server/actors/common");
|
||||
const { PerformanceRecordingActor, PerformanceRecordingFront } = require("devtools/server/actors/performance-recording");
|
||||
const { Actor, ActorClassWithSpec } = require("devtools/shared/protocol");
|
||||
const { actorBridgeWithSpec } = require("devtools/server/actors/common");
|
||||
const { performanceSpec } = require("devtools/shared/specs/performance");
|
||||
|
||||
loader.lazyRequireGetter(this, "events", "sdk/event/core");
|
||||
loader.lazyRequireGetter(this, "extend", "sdk/util/object", true);
|
||||
|
||||
loader.lazyRequireGetter(this, "PerformanceRecorder",
|
||||
"devtools/server/performance/recorder", true);
|
||||
loader.lazyRequireGetter(this, "PerformanceIO",
|
||||
"devtools/client/performance/modules/io");
|
||||
loader.lazyRequireGetter(this, "normalizePerformanceFeatures",
|
||||
"devtools/shared/performance/recording-utils", true);
|
||||
loader.lazyRequireGetter(this, "LegacyPerformanceFront",
|
||||
"devtools/client/performance/legacy/front", true);
|
||||
loader.lazyRequireGetter(this, "getSystemInfo",
|
||||
"devtools/shared/system", true);
|
||||
|
||||
const PIPE_TO_FRONT_EVENTS = new Set([
|
||||
"recording-started", "recording-stopping", "recording-stopped",
|
||||
|
@ -40,9 +33,7 @@ const RECORDING_STATE_CHANGE_EVENTS = new Set([
|
|||
*
|
||||
* @see devtools/shared/shared/performance.js for documentation.
|
||||
*/
|
||||
var PerformanceActor = exports.PerformanceActor = protocol.ActorClass({
|
||||
typeName: "performance",
|
||||
|
||||
var PerformanceActor = ActorClassWithSpec(performanceSpec, {
|
||||
traits: {
|
||||
features: {
|
||||
withMarkers: true,
|
||||
|
@ -55,31 +46,6 @@ var PerformanceActor = exports.PerformanceActor = protocol.ActorClass({
|
|||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* The set of events the PerformanceActor emits over RDP.
|
||||
*/
|
||||
events: {
|
||||
"recording-started": {
|
||||
recording: Arg(0, "performance-recording"),
|
||||
},
|
||||
"recording-stopping": {
|
||||
recording: Arg(0, "performance-recording"),
|
||||
},
|
||||
"recording-stopped": {
|
||||
recording: Arg(0, "performance-recording"),
|
||||
data: Arg(1, "json"),
|
||||
},
|
||||
"profiler-status": {
|
||||
data: Arg(0, "json"),
|
||||
},
|
||||
"console-profile-start": {},
|
||||
"timeline-data": {
|
||||
name: Arg(0, "string"),
|
||||
data: Arg(1, "json"),
|
||||
recordings: Arg(2, "array:performance-recording"),
|
||||
},
|
||||
},
|
||||
|
||||
initialize: function (conn, tabActor) {
|
||||
Actor.prototype.initialize.call(this, conn);
|
||||
this._onRecorderEvent = this._onRecorderEvent.bind(this);
|
||||
|
@ -98,24 +64,19 @@ var PerformanceActor = exports.PerformanceActor = protocol.ActorClass({
|
|||
destroy: function () {
|
||||
events.off(this.bridge, "*", this._onRecorderEvent);
|
||||
this.bridge.destroy();
|
||||
protocol.Actor.prototype.destroy.call(this);
|
||||
Actor.prototype.destroy.call(this);
|
||||
},
|
||||
|
||||
connect: method(function (config) {
|
||||
connect: function (config) {
|
||||
this.bridge.connect({ systemClient: config.systemClient });
|
||||
return { traits: this.traits };
|
||||
}, {
|
||||
request: { options: Arg(0, "nullable:json") },
|
||||
response: RetVal("json")
|
||||
}),
|
||||
},
|
||||
|
||||
canCurrentlyRecord: method(function () {
|
||||
canCurrentlyRecord: function () {
|
||||
return this.bridge.canCurrentlyRecord();
|
||||
}, {
|
||||
response: { value: RetVal("json") }
|
||||
}),
|
||||
},
|
||||
|
||||
startRecording: method(Task.async(function* (options = {}) {
|
||||
startRecording: Task.async(function* (options = {}) {
|
||||
if (!this.bridge.canCurrentlyRecord().success) {
|
||||
return null;
|
||||
}
|
||||
|
@ -125,40 +86,13 @@ var PerformanceActor = exports.PerformanceActor = protocol.ActorClass({
|
|||
this.manage(recording);
|
||||
|
||||
return recording;
|
||||
}), {
|
||||
request: {
|
||||
options: Arg(0, "nullable:json"),
|
||||
},
|
||||
response: {
|
||||
recording: RetVal("nullable:performance-recording")
|
||||
}
|
||||
}),
|
||||
|
||||
stopRecording: actorBridge("stopRecording", {
|
||||
request: {
|
||||
options: Arg(0, "performance-recording"),
|
||||
},
|
||||
response: {
|
||||
recording: RetVal("performance-recording")
|
||||
}
|
||||
}),
|
||||
|
||||
isRecording: actorBridge("isRecording", {
|
||||
response: { isRecording: RetVal("boolean") }
|
||||
}),
|
||||
|
||||
getRecordings: actorBridge("getRecordings", {
|
||||
response: { recordings: RetVal("array:performance-recording") }
|
||||
}),
|
||||
|
||||
getConfiguration: actorBridge("getConfiguration", {
|
||||
response: { config: RetVal("json") }
|
||||
}),
|
||||
|
||||
setProfilerStatusInterval: actorBridge("setProfilerStatusInterval", {
|
||||
request: { interval: Arg(0, "number") },
|
||||
response: { oneway: true }
|
||||
}),
|
||||
stopRecording: actorBridgeWithSpec("stopRecording"),
|
||||
isRecording: actorBridgeWithSpec("isRecording"),
|
||||
getRecordings: actorBridgeWithSpec("getRecordings"),
|
||||
getConfiguration: actorBridgeWithSpec("getConfiguration"),
|
||||
setProfilerStatusInterval: actorBridgeWithSpec("setProfilerStatusInterval"),
|
||||
|
||||
/**
|
||||
* Filter which events get piped to the front.
|
||||
|
@ -179,116 +113,4 @@ var PerformanceActor = exports.PerformanceActor = protocol.ActorClass({
|
|||
},
|
||||
});
|
||||
|
||||
exports.createPerformanceFront = function createPerformanceFront(target) {
|
||||
// If we force legacy mode, or the server does not have a performance actor (< Fx42),
|
||||
// use our LegacyPerformanceFront which will handle
|
||||
// the communication over RDP to other underlying actors.
|
||||
if (target.TEST_PERFORMANCE_LEGACY_FRONT || !target.form.performanceActor) {
|
||||
return new LegacyPerformanceFront(target);
|
||||
}
|
||||
// If our server has a PerformanceActor implementation, set this
|
||||
// up like a normal front.
|
||||
return new PerformanceFront(target.client, target.form);
|
||||
};
|
||||
|
||||
const PerformanceFront = exports.PerformanceFront = protocol.FrontClass(PerformanceActor, {
|
||||
initialize: function (client, form) {
|
||||
protocol.Front.prototype.initialize.call(this, client, form);
|
||||
this.actorID = form.performanceActor;
|
||||
this.manage(this);
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
protocol.Front.prototype.destroy.call(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Conenct to the server, and handle once-off tasks like storing traits
|
||||
* or system info.
|
||||
*/
|
||||
connect: custom(Task.async(function* () {
|
||||
let systemClient = yield getSystemInfo();
|
||||
let { traits } = yield this._connect({ systemClient });
|
||||
this._traits = traits;
|
||||
|
||||
return this._traits;
|
||||
}), {
|
||||
impl: "_connect"
|
||||
}),
|
||||
|
||||
get traits() {
|
||||
if (!this._traits) {
|
||||
Cu.reportError("Cannot access traits of PerformanceFront before calling `connect()`.");
|
||||
}
|
||||
return this._traits;
|
||||
},
|
||||
|
||||
/**
|
||||
* Pass in a PerformanceRecording and get a normalized value from 0 to 1 of how much
|
||||
* of this recording's lifetime remains without being overwritten.
|
||||
*
|
||||
* @param {PerformanceRecording} recording
|
||||
* @return {number?}
|
||||
*/
|
||||
getBufferUsageForRecording: function (recording) {
|
||||
if (!recording.isRecording()) {
|
||||
return void 0;
|
||||
}
|
||||
let { position: currentPosition, totalSize, generation: currentGeneration } = this._currentBufferStatus;
|
||||
let { position: origPosition, generation: origGeneration } = recording.getStartingBufferStatus();
|
||||
|
||||
let normalizedCurrent = (totalSize * (currentGeneration - origGeneration)) + currentPosition;
|
||||
let percent = (normalizedCurrent - origPosition) / totalSize;
|
||||
|
||||
// Clamp between 0 and 1; can get negative percentage values when a new
|
||||
// recording starts and the currentBufferStatus has not yet been updated. Rather
|
||||
// than fetching another status update, just clamp to 0, and this will be updated
|
||||
// on the next profiler-status event.
|
||||
return percent > 1 ? 1 : percent < 0 ? 0 : percent;
|
||||
},
|
||||
|
||||
/**
|
||||
* Loads a recording from a file.
|
||||
*
|
||||
* @param {nsILocalFile} file
|
||||
* The file to import the data from.
|
||||
* @return {Promise<PerformanceRecordingFront>}
|
||||
*/
|
||||
importRecording: function (file) {
|
||||
return PerformanceIO.loadRecordingFromFile(file).then(recordingData => {
|
||||
let model = new PerformanceRecordingFront();
|
||||
model._imported = true;
|
||||
model._label = recordingData.label || "";
|
||||
model._duration = recordingData.duration;
|
||||
model._markers = recordingData.markers;
|
||||
model._frames = recordingData.frames;
|
||||
model._memory = recordingData.memory;
|
||||
model._ticks = recordingData.ticks;
|
||||
model._allocations = recordingData.allocations;
|
||||
model._profile = recordingData.profile;
|
||||
model._configuration = recordingData.configuration || {};
|
||||
model._systemHost = recordingData.systemHost;
|
||||
model._systemClient = recordingData.systemClient;
|
||||
return model;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Store profiler status when the position has been update so we can
|
||||
* calculate recording's buffer percentage usage after emitting the event.
|
||||
*/
|
||||
_onProfilerStatus: preEvent("profiler-status", function (data) {
|
||||
this._currentBufferStatus = data;
|
||||
}),
|
||||
|
||||
/**
|
||||
* For all PerformanceRecordings that are recording, and needing realtime markers,
|
||||
* apply the timeline data to the front PerformanceRecording (so we only have one event
|
||||
* for each timeline data chunk as they could be shared amongst several recordings).
|
||||
*/
|
||||
_onTimelineEvent: preEvent("timeline-data", function (type, data, recordings) {
|
||||
for (let recording of recordings) {
|
||||
recording._addTimelineData(type, data);
|
||||
}
|
||||
}),
|
||||
});
|
||||
exports.PerformanceActor = PerformanceActor;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* "nsCycleCollector::ForgetSkippable" markers when we force cycle collection.
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
|
||||
add_task(function* () {
|
||||
// This test runs very slowly on linux32 debug EC2 instances.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Test that we get "GarbageCollection" markers.
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
const MARKER_NAME = "GarbageCollection";
|
||||
|
||||
add_task(function* () {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* objects.
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
|
||||
add_task(function* () {
|
||||
// This test runs very slowly on linux32 debug EC2 instances.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Test that we get "Parse HTML" markers.
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
const MARKER_NAME = "Parse HTML";
|
||||
|
||||
add_task(function* () {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Test that we get "Styles" markers with correct meta.
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
const MARKER_NAME = "Styles";
|
||||
|
||||
add_task(function* () {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Test that we get a "TimeStamp" marker.
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
const { PMM_consoleMethod, PMM_loadFrameScripts, PMM_clearFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
|
||||
const MARKER_NAME = "TimeStamp";
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Test that we have allocation data coming from the front.
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
|
||||
add_task(function* () {
|
||||
let browser = yield addTab(MAIN_DOMAIN + "doc_allocations.html");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* a recording is stopped.
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
const { PMM_isProfilerActive, PMM_stopProfiler, PMM_loadFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
|
||||
|
||||
add_task(function* () {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* is destroyed if there are other consumers using it.
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
const { PMM_isProfilerActive, PMM_stopProfiler, PMM_loadFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
|
||||
|
||||
add_task(function* () {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* addon was installed and automatically activated the profiler module).
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
const { PMM_isProfilerActive, PMM_startProfiler, PMM_stopProfiler, PMM_loadFrameScripts, PMM_clearFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
|
||||
|
||||
add_task(function* () {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Test functionality of real time markers.
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
|
||||
add_task(function* () {
|
||||
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* completed, and rec data.
|
||||
*/
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
|
||||
add_task(function* () {
|
||||
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
var BUFFER_SIZE = 20000;
|
||||
var config = { bufferSize: BUFFER_SIZE };
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
|
||||
add_task(function* () {
|
||||
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
const WAIT_TIME = 1000; // ms
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
|
||||
add_task(function* () {
|
||||
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
const WAIT_TIME = 1000; // ms
|
||||
|
||||
const { PerformanceFront } = require("devtools/server/actors/performance");
|
||||
const { PerformanceFront } = require("devtools/shared/fronts/performance");
|
||||
|
||||
add_task(function* () {
|
||||
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
|
||||
|
|
|
@ -20,6 +20,7 @@ DevToolsModules(
|
|||
'inspector.js',
|
||||
'layout.js',
|
||||
'memory.js',
|
||||
'performance.js',
|
||||
'preference.js',
|
||||
'promises.js',
|
||||
'settings.js',
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const { Cu } = require("chrome");
|
||||
const { Front, FrontClassWithSpec, custom, preEvent } = require("devtools/shared/protocol");
|
||||
const { PerformanceRecordingFront } = require("devtools/server/actors/performance-recording");
|
||||
const { performanceSpec } = require("devtools/shared/specs/performance");
|
||||
const { Task } = require("devtools/shared/task");
|
||||
|
||||
loader.lazyRequireGetter(this, "PerformanceIO",
|
||||
"devtools/client/performance/modules/io");
|
||||
loader.lazyRequireGetter(this, "LegacyPerformanceFront",
|
||||
"devtools/client/performance/legacy/front", true);
|
||||
loader.lazyRequireGetter(this, "getSystemInfo",
|
||||
"devtools/shared/system", true);
|
||||
|
||||
const PerformanceFront = FrontClassWithSpec(performanceSpec, {
|
||||
initialize: function (client, form) {
|
||||
Front.prototype.initialize.call(this, client, form);
|
||||
this.actorID = form.performanceActor;
|
||||
this.manage(this);
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
Front.prototype.destroy.call(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Conenct to the server, and handle once-off tasks like storing traits
|
||||
* or system info.
|
||||
*/
|
||||
connect: custom(Task.async(function* () {
|
||||
let systemClient = yield getSystemInfo();
|
||||
let { traits } = yield this._connect({ systemClient });
|
||||
this._traits = traits;
|
||||
|
||||
return this._traits;
|
||||
}), {
|
||||
impl: "_connect"
|
||||
}),
|
||||
|
||||
get traits() {
|
||||
if (!this._traits) {
|
||||
Cu.reportError("Cannot access traits of PerformanceFront before " +
|
||||
"calling `connect()`.");
|
||||
}
|
||||
return this._traits;
|
||||
},
|
||||
|
||||
/**
|
||||
* Pass in a PerformanceRecording and get a normalized value from 0 to 1 of how much
|
||||
* of this recording's lifetime remains without being overwritten.
|
||||
*
|
||||
* @param {PerformanceRecording} recording
|
||||
* @return {number?}
|
||||
*/
|
||||
getBufferUsageForRecording: function (recording) {
|
||||
if (!recording.isRecording()) {
|
||||
return void 0;
|
||||
}
|
||||
let {
|
||||
position: currentPosition,
|
||||
totalSize,
|
||||
generation: currentGeneration
|
||||
} = this._currentBufferStatus;
|
||||
let {
|
||||
position: origPosition,
|
||||
generation: origGeneration
|
||||
} = recording.getStartingBufferStatus();
|
||||
|
||||
let normalizedCurrent = (totalSize * (currentGeneration - origGeneration)) +
|
||||
currentPosition;
|
||||
let percent = (normalizedCurrent - origPosition) / totalSize;
|
||||
|
||||
// Clamp between 0 and 1; can get negative percentage values when a new
|
||||
// recording starts and the currentBufferStatus has not yet been updated. Rather
|
||||
// than fetching another status update, just clamp to 0, and this will be updated
|
||||
// on the next profiler-status event.
|
||||
if (percent < 0) {
|
||||
return 0;
|
||||
} else if (percent > 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return percent;
|
||||
},
|
||||
|
||||
/**
|
||||
* Loads a recording from a file.
|
||||
*
|
||||
* @param {nsILocalFile} file
|
||||
* The file to import the data from.
|
||||
* @return {Promise<PerformanceRecordingFront>}
|
||||
*/
|
||||
importRecording: function (file) {
|
||||
return PerformanceIO.loadRecordingFromFile(file).then(recordingData => {
|
||||
let model = new PerformanceRecordingFront();
|
||||
model._imported = true;
|
||||
model._label = recordingData.label || "";
|
||||
model._duration = recordingData.duration;
|
||||
model._markers = recordingData.markers;
|
||||
model._frames = recordingData.frames;
|
||||
model._memory = recordingData.memory;
|
||||
model._ticks = recordingData.ticks;
|
||||
model._allocations = recordingData.allocations;
|
||||
model._profile = recordingData.profile;
|
||||
model._configuration = recordingData.configuration || {};
|
||||
model._systemHost = recordingData.systemHost;
|
||||
model._systemClient = recordingData.systemClient;
|
||||
return model;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Store profiler status when the position has been update so we can
|
||||
* calculate recording's buffer percentage usage after emitting the event.
|
||||
*/
|
||||
_onProfilerStatus: preEvent("profiler-status", function (data) {
|
||||
this._currentBufferStatus = data;
|
||||
}),
|
||||
|
||||
/**
|
||||
* For all PerformanceRecordings that are recording, and needing realtime markers,
|
||||
* apply the timeline data to the front PerformanceRecording (so we only have one event
|
||||
* for each timeline data chunk as they could be shared amongst several recordings).
|
||||
*/
|
||||
_onTimelineEvent: preEvent("timeline-data", function (type, data, recordings) {
|
||||
for (let recording of recordings) {
|
||||
recording._addTimelineData(type, data);
|
||||
}
|
||||
}),
|
||||
});
|
||||
|
||||
exports.PerformanceFront = PerformanceFront;
|
||||
|
||||
exports.createPerformanceFront = function createPerformanceFront(target) {
|
||||
// If we force legacy mode, or the server does not have a performance actor (< Fx42),
|
||||
// use our LegacyPerformanceFront which will handle
|
||||
// the communication over RDP to other underlying actors.
|
||||
if (target.TEST_PERFORMANCE_LEGACY_FRONT || !target.form.performanceActor) {
|
||||
return new LegacyPerformanceFront(target);
|
||||
}
|
||||
// If our server has a PerformanceActor implementation, set this
|
||||
// up like a normal front.
|
||||
return new PerformanceFront(target.client, target.form);
|
||||
};
|
|
@ -25,6 +25,7 @@ DevToolsModules(
|
|||
'layout.js',
|
||||
'memory.js',
|
||||
'node.js',
|
||||
'performance.js',
|
||||
'preference.js',
|
||||
'promises.js',
|
||||
'script.js',
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const { Arg, RetVal, generateActorSpec } = require("devtools/shared/protocol");
|
||||
require("devtools/server/actors/performance-recording");
|
||||
|
||||
const performanceSpec = generateActorSpec({
|
||||
typeName: "performance",
|
||||
|
||||
/**
|
||||
* The set of events the PerformanceActor emits over RDP.
|
||||
*/
|
||||
events: {
|
||||
"recording-started": {
|
||||
recording: Arg(0, "performance-recording"),
|
||||
},
|
||||
"recording-stopping": {
|
||||
recording: Arg(0, "performance-recording"),
|
||||
},
|
||||
"recording-stopped": {
|
||||
recording: Arg(0, "performance-recording"),
|
||||
data: Arg(1, "json"),
|
||||
},
|
||||
"profiler-status": {
|
||||
data: Arg(0, "json"),
|
||||
},
|
||||
"console-profile-start": {},
|
||||
"timeline-data": {
|
||||
name: Arg(0, "string"),
|
||||
data: Arg(1, "json"),
|
||||
recordings: Arg(2, "array:performance-recording"),
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
connect: {
|
||||
request: { options: Arg(0, "nullable:json") },
|
||||
response: RetVal("json")
|
||||
},
|
||||
|
||||
canCurrentlyRecord: {
|
||||
request: {},
|
||||
response: { value: RetVal("json") }
|
||||
},
|
||||
|
||||
startRecording: {
|
||||
request: {
|
||||
options: Arg(0, "nullable:json"),
|
||||
},
|
||||
response: {
|
||||
recording: RetVal("nullable:performance-recording")
|
||||
}
|
||||
},
|
||||
|
||||
stopRecording: {
|
||||
request: {
|
||||
options: Arg(0, "performance-recording"),
|
||||
},
|
||||
response: {
|
||||
recording: RetVal("performance-recording")
|
||||
}
|
||||
},
|
||||
|
||||
isRecording: {
|
||||
request: {},
|
||||
response: { isRecording: RetVal("boolean") }
|
||||
},
|
||||
|
||||
getRecordings: {
|
||||
request: {},
|
||||
response: { recordings: RetVal("array:performance-recording") }
|
||||
},
|
||||
|
||||
getConfiguration: {
|
||||
request: {},
|
||||
response: { config: RetVal("json") }
|
||||
},
|
||||
|
||||
setProfilerStatusInterval: {
|
||||
request: { interval: Arg(0, "number") },
|
||||
response: { oneway: true }
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
exports.performanceSpec = performanceSpec;
|
Загрузка…
Ссылка в новой задаче