зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1382603 - Remove old-event-emitter usage from performance panel; r=gregtatum.
MozReview-Commit-ID: F7VCMbWwPRH --HG-- extra : rebase_source : 841f4a356e00a7cb6edcc4b7deca1a4cecec4ab0
This commit is contained in:
Родитель
10bbfadf8f
Коммит
4bf647e83a
|
@ -26,7 +26,7 @@ function PerformanceTelemetry(emitter) {
|
|||
this.onViewSelected = this.onViewSelected.bind(this);
|
||||
|
||||
for (let [event] of EVENT_MAP_FLAGS) {
|
||||
this._emitter.on(event, this.onFlagEvent);
|
||||
this._emitter.on(event, this.onFlagEvent.bind(this, event));
|
||||
}
|
||||
|
||||
this._emitter.on(EVENTS.RECORDING_STATE_CHANGE, this.onRecordingStateChange);
|
||||
|
@ -55,7 +55,7 @@ PerformanceTelemetry.prototype.onFlagEvent = function(eventName, ...data) {
|
|||
this._telemetry.log(EVENT_MAP_FLAGS.get(eventName), true);
|
||||
};
|
||||
|
||||
PerformanceTelemetry.prototype.onRecordingStateChange = function(_, status, model) {
|
||||
PerformanceTelemetry.prototype.onRecordingStateChange = function(status, model) {
|
||||
if (status != "recording-stopped") {
|
||||
return;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ PerformanceTelemetry.prototype.onRecordingStateChange = function(_, status, mode
|
|||
}
|
||||
};
|
||||
|
||||
PerformanceTelemetry.prototype.onViewSelected = function(_, viewName) {
|
||||
PerformanceTelemetry.prototype.onViewSelected = function(viewName) {
|
||||
if (this._previousView) {
|
||||
this._telemetry.stopTimer(SELECTED_VIEW_HISTOGRAM_NAME, this._previousView);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ const MountainGraphWidget = require("devtools/client/shared/widgets/MountainGrap
|
|||
const { CanvasGraphUtils } = require("devtools/client/shared/widgets/Graphs");
|
||||
|
||||
const defer = require("devtools/shared/defer");
|
||||
const EventEmitter = require("devtools/shared/old-event-emitter");
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
const { colorUtils } = require("devtools/shared/css/color");
|
||||
const { getColor } = require("devtools/client/shared/theme");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* This file contains the rendering code for the marker sidebar.
|
||||
*/
|
||||
|
||||
const EventEmitter = require("devtools/shared/old-event-emitter");
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
const { MarkerDOMUtils } = require("devtools/client/performance/modules/marker-dom-utils");
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
|
||||
const defer = require("devtools/shared/defer");
|
||||
|
||||
loader.lazyRequireGetter(this, "EventEmitter",
|
||||
"devtools/shared/old-event-emitter");
|
||||
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
|
||||
|
||||
function PerformancePanel(iframeWindow, toolbox) {
|
||||
this.panelWin = iframeWindow;
|
||||
|
|
|
@ -44,7 +44,7 @@ var RecordingListItem = React.createFactory(require("devtools/client/performance
|
|||
var Services = require("Services");
|
||||
var promise = require("promise");
|
||||
const defer = require("devtools/shared/defer");
|
||||
var EventEmitter = require("devtools/shared/old-event-emitter");
|
||||
var EventEmitter = require("devtools/shared/event-emitter");
|
||||
var DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||
var flags = require("devtools/shared/flags");
|
||||
var system = require("devtools/shared/system");
|
||||
|
@ -127,8 +127,14 @@ var PerformanceController = {
|
|||
this._onRecordingSelectFromView = this._onRecordingSelectFromView.bind(this);
|
||||
this._onPrefChanged = this._onPrefChanged.bind(this);
|
||||
this._onThemeChanged = this._onThemeChanged.bind(this);
|
||||
this._onFrontEvent = this._onFrontEvent.bind(this);
|
||||
this._pipe = this._pipe.bind(this);
|
||||
this._onDetailsViewSelected = this._onDetailsViewSelected.bind(this);
|
||||
this._onProfilerStatus = this._onProfilerStatus.bind(this);
|
||||
this._onRecordingStarted =
|
||||
this._emitRecordingStateChange.bind(this, "recording-started");
|
||||
this._onRecordingStopping =
|
||||
this._emitRecordingStateChange.bind(this, "recording-stopping");
|
||||
this._onRecordingStopped =
|
||||
this._emitRecordingStateChange.bind(this, "recording-stopped");
|
||||
|
||||
// Store data regarding if e10s is enabled.
|
||||
this._e10s = Services.appinfo.browserTabsRemoteAutostart;
|
||||
|
@ -145,7 +151,7 @@ var PerformanceController = {
|
|||
PerformanceView.on(EVENTS.UI_CLEAR_RECORDINGS, this.clearRecordings);
|
||||
RecordingsView.on(EVENTS.UI_EXPORT_RECORDING, this.exportRecording);
|
||||
RecordingsView.on(EVENTS.UI_RECORDING_SELECTED, this._onRecordingSelectFromView);
|
||||
DetailsView.on(EVENTS.UI_DETAILS_VIEW_SELECTED, this._pipe);
|
||||
DetailsView.on(EVENTS.UI_DETAILS_VIEW_SELECTED, this._onDetailsViewSelected);
|
||||
|
||||
this._prefObserver = new PrefObserver("devtools.");
|
||||
this._prefObserver.on("devtools.theme", this._onThemeChanged);
|
||||
|
@ -166,7 +172,7 @@ var PerformanceController = {
|
|||
PerformanceView.off(EVENTS.UI_CLEAR_RECORDINGS, this.clearRecordings);
|
||||
RecordingsView.off(EVENTS.UI_EXPORT_RECORDING, this.exportRecording);
|
||||
RecordingsView.off(EVENTS.UI_RECORDING_SELECTED, this._onRecordingSelectFromView);
|
||||
DetailsView.off(EVENTS.UI_DETAILS_VIEW_SELECTED, this._pipe);
|
||||
DetailsView.off(EVENTS.UI_DETAILS_VIEW_SELECTED, this._onDetailsViewSelected);
|
||||
|
||||
this._prefObserver.off("devtools.theme", this._onThemeChanged);
|
||||
this._prefObserver.destroy();
|
||||
|
@ -183,14 +189,20 @@ var PerformanceController = {
|
|||
* listeners are added too soon.
|
||||
*/
|
||||
enableFrontEventListeners: function() {
|
||||
gFront.on("*", this._onFrontEvent);
|
||||
gFront.on("profiler-status", this._onProfilerStatus);
|
||||
gFront.on("recording-started", this._onRecordingStarted);
|
||||
gFront.on("recording-stopping", this._onRecordingStopping);
|
||||
gFront.on("recording-stopped", this._onRecordingStopped);
|
||||
},
|
||||
|
||||
/**
|
||||
* Disables front event listeners.
|
||||
*/
|
||||
disableFrontEventListeners: function() {
|
||||
gFront.off("*", this._onFrontEvent);
|
||||
gFront.off("profiler-status", this._onProfilerStatus);
|
||||
gFront.off("recording-started", this._onRecordingStarted);
|
||||
gFront.off("recording-stopping", this._onRecordingStopping);
|
||||
gFront.off("recording-stopped", this._onRecordingStopped);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -298,7 +310,7 @@ var PerformanceController = {
|
|||
* @param nsIFile file
|
||||
* The file to stream the data into.
|
||||
*/
|
||||
async exportRecording(_, recording, file) {
|
||||
async exportRecording(recording, file) {
|
||||
await recording.exportRecording(file);
|
||||
this.emit(EVENTS.RECORDING_EXPORTED, recording, file);
|
||||
},
|
||||
|
@ -342,7 +354,7 @@ var PerformanceController = {
|
|||
* @param nsIFile file
|
||||
* The file to import the data from.
|
||||
*/
|
||||
async importRecording(_, file) {
|
||||
async importRecording(file) {
|
||||
let recording = await gFront.importRecording(file);
|
||||
this._addRecordingIfUnknown(recording);
|
||||
|
||||
|
@ -388,7 +400,7 @@ var PerformanceController = {
|
|||
* Fired from RecordingsView, we listen on the PerformanceController so we can
|
||||
* set it here and re-emit on the controller, where all views can listen.
|
||||
*/
|
||||
_onRecordingSelectFromView: function(_, recording) {
|
||||
_onRecordingSelectFromView: function(recording) {
|
||||
this.setCurrentRecording(recording);
|
||||
},
|
||||
|
||||
|
@ -396,7 +408,7 @@ var PerformanceController = {
|
|||
* Fired when the ToolbarView fires a PREF_CHANGED event.
|
||||
* with the value.
|
||||
*/
|
||||
_onPrefChanged: function(_, prefName, prefValue) {
|
||||
_onPrefChanged: function(prefName, prefValue) {
|
||||
this.emit(EVENTS.PREF_CHANGED, prefName, prefValue);
|
||||
},
|
||||
|
||||
|
@ -408,23 +420,13 @@ var PerformanceController = {
|
|||
this.emit(EVENTS.THEME_CHANGED, newValue);
|
||||
},
|
||||
|
||||
/**
|
||||
* Fired from the front on any event. Propagates to other handlers from here.
|
||||
*/
|
||||
_onFrontEvent: function(eventName, ...data) {
|
||||
switch (eventName) {
|
||||
case "profiler-status":
|
||||
let [profilerStatus] = data;
|
||||
this.emit(EVENTS.RECORDING_PROFILER_STATUS_UPDATE, profilerStatus);
|
||||
break;
|
||||
case "recording-started":
|
||||
case "recording-stopping":
|
||||
case "recording-stopped":
|
||||
let [recordingModel] = data;
|
||||
this._addRecordingIfUnknown(recordingModel);
|
||||
this.emit(EVENTS.RECORDING_STATE_CHANGE, eventName, recordingModel);
|
||||
break;
|
||||
}
|
||||
_onProfilerStatus: function(status) {
|
||||
this.emit(EVENTS.RECORDING_PROFILER_STATUS_UPDATE, status);
|
||||
},
|
||||
|
||||
_emitRecordingStateChange(eventName, recordingModel) {
|
||||
this._addRecordingIfUnknown(recordingModel);
|
||||
this.emit(EVENTS.RECORDING_STATE_CHANGE, eventName, recordingModel);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -561,10 +563,10 @@ var PerformanceController = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Pipes an event from some source to the PerformanceController.
|
||||
* Pipes EVENTS.UI_DETAILS_VIEW_SELECTED to the PerformanceController.
|
||||
*/
|
||||
_pipe: function(eventName, ...data) {
|
||||
this.emit(eventName, ...data);
|
||||
_onDetailsViewSelected: function(...data) {
|
||||
this.emit(EVENTS.UI_DETAILS_VIEW_SELECTED, ...data);
|
||||
},
|
||||
|
||||
toString: () => "[object PerformanceController]"
|
||||
|
|
|
@ -324,7 +324,7 @@ var PerformanceView = {
|
|||
/**
|
||||
* When starting a recording has failed.
|
||||
*/
|
||||
_onNewRecordingFailed: function(e) {
|
||||
_onNewRecordingFailed: function() {
|
||||
this._lockRecordButtons(false);
|
||||
this._toggleRecordButtons(false);
|
||||
},
|
||||
|
@ -369,7 +369,7 @@ var PerformanceView = {
|
|||
/**
|
||||
* Fired when a recording is selected. Used to toggle the profiler view state.
|
||||
*/
|
||||
_onRecordingSelected: function(_, recording) {
|
||||
_onRecordingSelected: function(recording) {
|
||||
if (!recording) {
|
||||
this.setState("empty");
|
||||
} else if (recording.isRecording() && recording.isConsole()) {
|
||||
|
@ -385,7 +385,7 @@ var PerformanceView = {
|
|||
* Fired when the controller has updated information on the buffer's status.
|
||||
* Update the buffer status display if shown.
|
||||
*/
|
||||
_onProfilerStatusUpdated: function(_, profilerStatus) {
|
||||
_onProfilerStatusUpdated: function(profilerStatus) {
|
||||
// We only care about buffer status here, so check to see
|
||||
// if it has position.
|
||||
if (!profilerStatus || profilerStatus.position === void 0) {
|
||||
|
|
|
@ -111,7 +111,7 @@ var DetailsSubview = {
|
|||
/**
|
||||
* Called when recording stops or is selected.
|
||||
*/
|
||||
_onRecordingStoppedOrSelected: function(_, state, recording) {
|
||||
_onRecordingStoppedOrSelected: function(state, recording) {
|
||||
if (typeof state !== "string") {
|
||||
recording = state;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ var DetailsSubview = {
|
|||
/**
|
||||
* Fired when a range is selected or cleared in the OverviewView.
|
||||
*/
|
||||
_onOverviewRangeChange: function(_, interval) {
|
||||
_onOverviewRangeChange: function(interval) {
|
||||
if (!this.requiresUpdateOnRangeChange) {
|
||||
return;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ var DetailsSubview = {
|
|||
/**
|
||||
* Fired when a preference in `devtools.performance.ui.` is changed.
|
||||
*/
|
||||
_onPrefChanged: function(_, prefName, prefValue) {
|
||||
_onPrefChanged: function(prefName, prefValue) {
|
||||
if (~this.observedPrefs.indexOf(prefName) && this._onObservedPrefChange) {
|
||||
this._onObservedPrefChange(prefName);
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ var JsCallTreeView = extend(DetailsSubview, {
|
|||
/**
|
||||
* Fired on the "link" event for the call tree in this container.
|
||||
*/
|
||||
_onLink: function(_, treeItem) {
|
||||
_onLink: function(treeItem) {
|
||||
let { url, line } = treeItem.frame.getInfo();
|
||||
gToolbox.viewSourceInDebugger(url, line).then(success => {
|
||||
if (success) {
|
||||
|
|
|
@ -114,7 +114,7 @@ var JsFlameGraphView = extend(DetailsSubview, {
|
|||
/**
|
||||
* Called when `devtools.theme` changes.
|
||||
*/
|
||||
_onThemeChanged: function(_, theme) {
|
||||
_onThemeChanged: function(theme) {
|
||||
this.graph.setTheme(theme);
|
||||
this.graph.refresh({ force: true });
|
||||
},
|
||||
|
|
|
@ -56,7 +56,7 @@ var MemoryCallTreeView = extend(DetailsSubview, {
|
|||
/**
|
||||
* Fired on the "link" event for the call tree in this container.
|
||||
*/
|
||||
_onLink: function(_, treeItem) {
|
||||
_onLink: function(treeItem) {
|
||||
let { url, line } = treeItem.frame.getInfo();
|
||||
gToolbox.viewSourceInDebugger(url, line).then(success => {
|
||||
if (success) {
|
||||
|
|
|
@ -111,7 +111,7 @@ var MemoryFlameGraphView = extend(DetailsSubview, {
|
|||
/**
|
||||
* Called when `devtools.theme` changes.
|
||||
*/
|
||||
_onThemeChanged: function(_, theme) {
|
||||
_onThemeChanged: function(theme) {
|
||||
this.graph.setTheme(theme);
|
||||
this.graph.refresh({ force: true });
|
||||
},
|
||||
|
|
|
@ -145,14 +145,14 @@ var WaterfallView = extend(DetailsSubview, {
|
|||
/**
|
||||
* Called when MarkerDetails view emits an event to view source.
|
||||
*/
|
||||
_onViewSource: function(_, data) {
|
||||
_onViewSource: function(data) {
|
||||
gToolbox.viewSourceInDebugger(data.url, data.line);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when MarkerDetails view emits an event to snap to allocations.
|
||||
*/
|
||||
_onShowAllocations: function(_, data) {
|
||||
_onShowAllocations: function(data) {
|
||||
let { endTime } = data;
|
||||
let startTime = 0;
|
||||
let recording = PerformanceController.getCurrentRecording();
|
||||
|
|
|
@ -240,7 +240,7 @@ var DetailsView = {
|
|||
/**
|
||||
* Called when recording stops or is selected.
|
||||
*/
|
||||
_onRecordingStoppedOrSelected: function(_, state, recording) {
|
||||
_onRecordingStoppedOrSelected: function(state, recording) {
|
||||
if (typeof state === "string" && state !== "recording-stopped") {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -209,27 +209,26 @@ var OverviewView = {
|
|||
/**
|
||||
* Called when recording state changes.
|
||||
*/
|
||||
_onRecordingStateChange:
|
||||
OverviewViewOnStateChange(async function(_, state, recording) {
|
||||
if (state !== "recording-stopped") {
|
||||
return;
|
||||
}
|
||||
// Check to see if the recording that just stopped is the current recording.
|
||||
// If it is, render the high-res graphs. For manual recordings, it will also
|
||||
// be the current recording, but profiles generated by `console.profile` can stop
|
||||
// while having another profile selected -- in this case, OverviewView should keep
|
||||
// rendering the current recording.
|
||||
if (recording !== PerformanceController.getCurrentRecording()) {
|
||||
return;
|
||||
}
|
||||
this.render(FRAMERATE_GRAPH_HIGH_RES_INTERVAL);
|
||||
await this._checkSelection(recording);
|
||||
}),
|
||||
_onRecordingStateChange: OverviewViewOnStateChange(async function(state, recording) {
|
||||
if (state !== "recording-stopped") {
|
||||
return;
|
||||
}
|
||||
// Check to see if the recording that just stopped is the current recording.
|
||||
// If it is, render the high-res graphs. For manual recordings, it will also
|
||||
// be the current recording, but profiles generated by `console.profile` can stop
|
||||
// while having another profile selected -- in this case, OverviewView should keep
|
||||
// rendering the current recording.
|
||||
if (recording !== PerformanceController.getCurrentRecording()) {
|
||||
return;
|
||||
}
|
||||
this.render(FRAMERATE_GRAPH_HIGH_RES_INTERVAL);
|
||||
await this._checkSelection(recording);
|
||||
}),
|
||||
|
||||
/**
|
||||
* Called when a new recording is selected.
|
||||
*/
|
||||
_onRecordingSelected: OverviewViewOnStateChange(async function(_, recording) {
|
||||
_onRecordingSelected: OverviewViewOnStateChange(async function(recording) {
|
||||
this._setGraphVisibilityFromRecordingFeatures(recording);
|
||||
|
||||
// If this recording is complete, render the high res graph
|
||||
|
@ -283,7 +282,7 @@ var OverviewView = {
|
|||
this.emit(EVENTS.UI_OVERVIEW_RANGE_SELECTED, this.getTimeInterval());
|
||||
},
|
||||
|
||||
_onGraphRendered: function(_, graphName) {
|
||||
_onGraphRendered: function(graphName) {
|
||||
switch (graphName) {
|
||||
case "timeline":
|
||||
this.emit(EVENTS.UI_MARKERS_GRAPH_RENDERED);
|
||||
|
@ -303,7 +302,7 @@ var OverviewView = {
|
|||
* because those will set values on a recording model, and
|
||||
* the graphs will render based on the existence.
|
||||
*/
|
||||
async _onPrefChanged(_, prefName, prefValue) {
|
||||
async _onPrefChanged(prefName, prefValue) {
|
||||
switch (prefName) {
|
||||
case "hidden-markers": {
|
||||
let graph = await this.graphs.isAvailable("timeline");
|
||||
|
@ -356,7 +355,7 @@ var OverviewView = {
|
|||
/**
|
||||
* Called when `devtools.theme` changes.
|
||||
*/
|
||||
_onThemeChanged: function(_, theme) {
|
||||
_onThemeChanged: function(theme) {
|
||||
this.graphs.setTheme({ theme, redraw: true });
|
||||
},
|
||||
|
||||
|
@ -374,11 +373,11 @@ var OverviewView = {
|
|||
* @return {function}
|
||||
*/
|
||||
function OverviewViewOnStateChange(fn) {
|
||||
return function _onRecordingStateChange(eventName, recording) {
|
||||
return function _onRecordingStateChange(recording) {
|
||||
// Normalize arguments for the RECORDING_STATE_CHANGE event,
|
||||
// as it also has a `state` argument.
|
||||
if (typeof recording === "string") {
|
||||
recording = arguments[2];
|
||||
recording = arguments[1];
|
||||
}
|
||||
|
||||
let currentRecording = PerformanceController.getCurrentRecording();
|
||||
|
|
|
@ -109,8 +109,8 @@ var RecordingsView = {
|
|||
* before the tool is loaded) or imported. In normal manual recording cases,
|
||||
* this will also be fired.
|
||||
*/
|
||||
_onNewRecording: function(_, recording) {
|
||||
this._onRecordingStateChange(_, null, recording);
|
||||
_onNewRecording: function(recording) {
|
||||
this._onRecordingStateChange(null, recording);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -121,7 +121,7 @@ var RecordingsView = {
|
|||
* @param RecordingModel recording
|
||||
* Model of the recording that was started.
|
||||
*/
|
||||
_onRecordingStateChange: function(_, state, recording) {
|
||||
_onRecordingStateChange: function(state, recording) {
|
||||
const { recordings, labels } = this._listState;
|
||||
|
||||
if (!recordings.includes(recording)) {
|
||||
|
@ -148,7 +148,7 @@ var RecordingsView = {
|
|||
/**
|
||||
* Clears out all non-console recordings.
|
||||
*/
|
||||
_onRecordingDeleted: function(_, recording) {
|
||||
_onRecordingDeleted: function(recording) {
|
||||
const { recordings } = this._listState;
|
||||
const index = recordings.indexOf(recording);
|
||||
if (index === -1) {
|
||||
|
@ -186,7 +186,7 @@ var RecordingsView = {
|
|||
}});
|
||||
},
|
||||
|
||||
_onRecordingExported: function(_, recording, file) {
|
||||
_onRecordingExported: function(recording, file) {
|
||||
if (recording.isConsole()) {
|
||||
return;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче