mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-07-20 22:18:29 +00:00
a7bc0406ee
- Bug 1155006: Fix unified build sensitivities in js/src/jit. r=shu (6e24e1af1) - Bug 1162766 - Fix more bad implicit constructors in js. r=evilpie (39961b06d) - Bug 1151606 - Stream atoms instead of raw pointers for native functions in tracked optimizations. (r=djvj) (7641ee9d6) - pointer style (540728104) - Bug 1154997 - Deal with self-hosted builtins when stringifying tracked optimization type info. (r=djvj) (92f9a54e6) - pointer style (45742d820) - Bug 1154115 - Rewrite the JSAPI profiling API to use a FrameHandle, as to avoid multiple lookups in JitcodeGlobalTable. (r=djvj) (4d202ba9e) - Bug 1119023 - Timeline in new perf tool should filter out markers, r=jsantell (6fc1a8bbe) - Bug 1132755 - Allocations tree has a bunch of columns that don't make sense, r=jsantell (1ae9ee7e2) - Bug 1142744 - Fix tests broken by bug 1132755, r=me (cc495f72d) - Bug 1133058 - OptionsView button, when clicked, should have an 'open' attribute. r=vp (65a78d896) - Bug 1132765 - Pass through performance memory options for 'probability' and 'maxLogLength' from the front to the memory actor. r=vp (f9bbbe098) - Bug 1141817 - Fix yield statement to correctly return memory actor state so that the performance tool can poll for allocations during recording. r=vp (2ddf7d528) - Bug 1141817 - Followup to fix additional intermittents like bug 1132370, r=vp (eab962f01) - Bug 1142748 - Use a single configuration for starting/stopping recordings, r=jsantell (0181b319a) - bit of Bug 879008 - New UI for the sampling Profiler (32c4d0fe8) - Bug 1123815 - Merge gum into fx-team to enable the Performance++ tool, r=me (84aabbd61) - Bug 1143933 - Expose raw JIT optimization information in performance front end. r=vp,shu (f68a6df50) - Bug 1143915 - Allow multiple calls to memory and timeline actor's start methods, to return the local start time from the actor. r=vp (028ac4187) - Bug 978948 - Add animation generator support for setTimeout in the canvas debugger. r=vp (42d623452) - Bug 985488 - Allow canvas debugger to time out and stop recording frames. Canvas debugger 'wait' style now matches other media styles. Update labels in canvas debugger to explicitly state that it's waiting for rAF cycles, rather than appearing as if something went wrong. r=vporof (b4670d843) - Bug 1144163 - Add a rulers highlighter; added unit test. r=pbrosset (5811a67d0) - Bug 1144163 - Add a rulers highlighter; added highlighter. r=pbrosset (779f88bdd) - Bug 1144163 - Add a rulers highlighter; added gcli command and button. r=pbrosset (d0d13da51) - Bug 1110550 - Enable performance overview graphs to rerender and change on devtools theme switch. r=vp (bd91ca7cf) - Bug 1149630 - Performance graphs should inherit from a common graph and be similarly styled. r=vporof (481c841f1) - Bug 1150733 - Correctly internationalize jit samples label. r=vporof, r=flod (b5612d1a6) - Bug 1137518 - FlameGraph's destroy function should be async, r=jsantell (f103e4c15) - Bug 1137503 - Avoid potential infinite loops in `findOptimalTickInterval` functions, r=jsantell (95df6c04a) - Bug 1121194 - Support vertical panning for the flamegraph in the new performance tool, r=jsantell (06241b5b2) - Bug 1121180 - Support dark theme in flamecharts for the performance tool. r=vp (c76abe237) - Bug 1059308 - Add Target.isTabActor to tell if the remote tab actor supports attach/detach requests. r=jryans (e03dcef93) - Bug 1132370 - Wrong State: Expected 'attached', but current state is 'detached', r=jsantell (e884e8db9) - No Bug - Fix documentation for _startMemory and _stopMemory in performance/modules/front.js, r=me DONTBUILD (d79090b31) - Bug 1147656 - Remove duplicate profiler defaults from the front end and just use on the server. r=vp (35c015dd0) - Bug 1046234 - Add more DevTools Telemetry measures (display size etc) r=pbrosset, r=gijs (a235681b4) - actually package telemetry.js (e8f3a58a4) - Bug 1077464 - Wire console.profile/profileEnd to the new performance tool. Move most of the recording-model logic from the front end into the PerformanceFront and PerformanceActorConnection so it can manage recordings without the front end being viewed. r=vp,jryans,pbrosset (eef8e18c3) - Bug 1144363 - Fix this._telemetry is undefined in gDevTools. r=bgrins (ba7d02902) - init telemetry, missing parts of Bug 866642 (1e70df975) - do not use sysctl.h on Linux anymore, since it is not provided by recent glibc (b2467d7ce) - clean up some telemetry issues of histogram, parts of Bug 974171 (d30c8d0ad) - move devtools to browser - part 1 (9a856f452) - Bug 1291423: Explicitly qualify the destructor call that we invoke in Maybe::reset. r=Waldo (944904a7d) - Bug 1148075 - Dynamically add XUL commands for the debugger frontend. r=vporof (60bc91f8f) - Bug 1147945 - Let the profiler's buffer size and sample rate be configurable via prefs. r=vp (acebcbdd9) - Bug 1124326 - Improve packageDir support for Cordova. r=ochameau (4b736580a) - Bug 1124326 - Support Cordova w/o build file. r=ochameau (d4b50aeae) - Bug 1134029 - Fix 'Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIURI.host]' timeouts, r=jsantell (18d16a5d0) - Bug 1147806 - Content frame filtering is confused when profiling FxOS, r=jsantell (b3c62c552) - Bug 1108843 - Generalize platform data in call tree view when platform data is hidden. r=vporof (354553ed7) - Bug 1138928 - Display only function name and file, instead of full url, in flame graphs. r=vp (4169689c1) - Bug 1152605 - Should not show host names for chrome URIs. r=vporof (c6dcf9e78) - Bug 1147604 - Inverted call trees should list (root) as leaves. r=jsantell (01768267f) - Bug 1075450 - Disable some Awesomebar actions for private windows r=mak (21d5586e7) - Bug 1120616 - Part 1: Implement filter styles in rule view r=bgrins (b66ee0282) - Bug 1120616 - Part 2: Add unit tests for filter styles in rule view r=bgrins (2892503d8) - Bug 1120616 - Part 3: Adjust the styles in the computed view's filter style search r=bgrins (41f8fae1b) - Bug 1120616 - Part 4: Add textbox context menu for rule and computed view r=bgrins (ff3f868ad) - Bug 1120616 - Part 5: Refactor style inspector tests to use synthesizeKeys r=bgrins (41db021d7) - Bug 1102219 - Part 5: Replace more `String.prototype.contains` with `String.prototype.includes` in chrome code. r=till (86ed03588) - Bug 1154018 - Check to see that nsIURI's host exists when parsing location for framenodes, and cache failures. r=vp (9494d52e7) - Bug 1160691 - Optimize FrameUtils.isContent and FrameUtils.parseLocation. (r=jsantell) (09118fd5d) - Bug 1154115 - Make the performance devtool handle the new profiler JSON format. (r=jsantell,vporof) (e3e5be7a4) - Bug 1059308 - Make frame selection button to work in browser toolbox. r=jryans,past (30fe6e61e) - Bug 1059308 - Fix tests to support chrome actor. r=jryans (01cf3926c) - Bug 1147042 - Rename attachProcess to getProcess. r=ochameau (0393ffb80) - Bug 1145824 - Profiler actor and performance tools now handle passing in a startTime to filter out SPS profiles on platform rather than client. r=vp,fitzgen (f225116ba) - Bug 1157718 - Do not use Array.prototype.includes in production code that leaves nightly in performance tool. r=fitzgen (ff06d284e) - Bug 1140728 - Rename 'Memory' to 'Allocations' in the new performance tool. r=jsantell (f584e720f) - Bug 1137500 - Always wait for the overview to be rendered in tests after a recording finishes, unless otherwise specified, r=jsantell (59825e179) - Bug 1137487 - AbstractCanvasGraph's destroy function should be async, r=jsantell (a17ae00b5) - Bug 1132758 - Performance feature visibility now based on a per recording-basis, dependent on features enabled and server support. r=vp (0d080a7c2) - Bug 1147035 - Make DeveloperToolbar.jsm use the gBrowser.contentDocumentAsCPOW shortcut. r=past. (251eff125) - Bug 1151168 - Don't flush profiled threads that are pending deletion on JS shutdown and don't delete expired markers when resetting the profile buffer. (r=djvj) (90721313a)
521 lines
19 KiB
JavaScript
521 lines
19 KiB
JavaScript
/* 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 { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
|
|
|
Cu.import("resource://gre/modules/Task.jsm");
|
|
Cu.import("resource://gre/modules/devtools/Loader.jsm");
|
|
Cu.import("resource://gre/modules/devtools/Console.jsm");
|
|
Cu.import("resource://gre/modules/devtools/ViewHelpers.jsm");
|
|
|
|
devtools.lazyRequireGetter(this, "Services");
|
|
devtools.lazyRequireGetter(this, "promise");
|
|
devtools.lazyRequireGetter(this, "EventEmitter",
|
|
"devtools/toolkit/event-emitter");
|
|
devtools.lazyRequireGetter(this, "DevToolsUtils",
|
|
"devtools/toolkit/DevToolsUtils");
|
|
|
|
devtools.lazyRequireGetter(this, "TreeWidget",
|
|
"devtools/shared/widgets/TreeWidget", true);
|
|
devtools.lazyRequireGetter(this, "TIMELINE_BLUEPRINT",
|
|
"devtools/shared/timeline/global", true);
|
|
devtools.lazyRequireGetter(this, "L10N",
|
|
"devtools/shared/profiler/global", true);
|
|
devtools.lazyRequireGetter(this, "RecordingUtils",
|
|
"devtools/performance/recording-utils", true);
|
|
devtools.lazyRequireGetter(this, "RecordingModel",
|
|
"devtools/performance/recording-model", true);
|
|
devtools.lazyRequireGetter(this, "GraphsController",
|
|
"devtools/performance/graphs", true);
|
|
devtools.lazyRequireGetter(this, "Waterfall",
|
|
"devtools/shared/timeline/waterfall", true);
|
|
devtools.lazyRequireGetter(this, "MarkerDetails",
|
|
"devtools/shared/timeline/marker-details", true);
|
|
devtools.lazyRequireGetter(this, "CallView",
|
|
"devtools/shared/profiler/tree-view", true);
|
|
devtools.lazyRequireGetter(this, "ThreadNode",
|
|
"devtools/shared/profiler/tree-model", true);
|
|
devtools.lazyRequireGetter(this, "FrameNode",
|
|
"devtools/shared/profiler/tree-model", true);
|
|
devtools.lazyRequireGetter(this, "JITOptimizations",
|
|
"devtools/shared/profiler/jit", true);
|
|
devtools.lazyRequireGetter(this, "OptionsView",
|
|
"devtools/shared/options-view", true);
|
|
devtools.lazyRequireGetter(this, "FlameGraphUtils",
|
|
"devtools/shared/widgets/FlameGraph", true);
|
|
devtools.lazyRequireGetter(this, "FlameGraph",
|
|
"devtools/shared/widgets/FlameGraph", true);
|
|
|
|
devtools.lazyImporter(this, "SideMenuWidget",
|
|
"resource://gre/modules/devtools/SideMenuWidget.jsm");
|
|
devtools.lazyImporter(this, "PluralForm",
|
|
"resource://gre/modules/PluralForm.jsm");
|
|
|
|
const BRANCH_NAME = "devtools.performance.ui.";
|
|
|
|
// Events emitted by various objects in the panel.
|
|
const EVENTS = {
|
|
// Fired by the PerformanceController and OptionsView when a pref changes.
|
|
PREF_CHANGED: "Performance:PrefChanged",
|
|
|
|
// Fired by the PerformanceController when the devtools theme changes.
|
|
THEME_CHANGED: "Performance:ThemeChanged",
|
|
|
|
// When the SharedPerformanceConnection handles profiles created via `console.profile()`,
|
|
// the controller handles those events and emits the below events for consumption
|
|
// by other views.
|
|
CONSOLE_RECORDING_STARTED: "Performance:ConsoleRecordingStarted",
|
|
CONSOLE_RECORDING_WILL_STOP: "Performance:ConsoleRecordingWillStop",
|
|
CONSOLE_RECORDING_STOPPED: "Performance:ConsoleRecordingStopped",
|
|
|
|
// Emitted by the PerformanceView when the state (display mode) changes,
|
|
// for example when switching between "empty", "recording" or "recorded".
|
|
// This causes certain panels to be hidden or visible.
|
|
UI_STATE_CHANGED: "Performance:UI:StateChanged",
|
|
|
|
// Emitted by the PerformanceView on clear button click
|
|
UI_CLEAR_RECORDINGS: "Performance:UI:ClearRecordings",
|
|
|
|
// Emitted by the PerformanceView on record button click
|
|
UI_START_RECORDING: "Performance:UI:StartRecording",
|
|
UI_STOP_RECORDING: "Performance:UI:StopRecording",
|
|
|
|
// Emitted by the PerformanceView on import button click
|
|
UI_IMPORT_RECORDING: "Performance:UI:ImportRecording",
|
|
// Emitted by the RecordingsView on export button click
|
|
UI_EXPORT_RECORDING: "Performance:UI:ExportRecording",
|
|
|
|
// When a recording is started or stopped via the PerformanceController
|
|
RECORDING_STARTED: "Performance:RecordingStarted",
|
|
RECORDING_STOPPED: "Performance:RecordingStopped",
|
|
RECORDING_WILL_START: "Performance:RecordingWillStart",
|
|
RECORDING_WILL_STOP: "Performance:RecordingWillStop",
|
|
|
|
// Emitted by the PerformanceController or RecordingView
|
|
// when a recording model is selected
|
|
RECORDING_SELECTED: "Performance:RecordingSelected",
|
|
|
|
// When recordings have been cleared out
|
|
RECORDINGS_CLEARED: "Performance:RecordingsCleared",
|
|
|
|
// When a recording is imported or exported via the PerformanceController
|
|
RECORDING_IMPORTED: "Performance:RecordingImported",
|
|
RECORDING_EXPORTED: "Performance:RecordingExported",
|
|
|
|
|
|
// Emitted by the JITOptimizationsView when it renders new optimization
|
|
// data and clears the optimization data
|
|
OPTIMIZATIONS_RESET: "Performance:UI:OptimizationsReset",
|
|
OPTIMIZATIONS_RENDERED: "Performance:UI:OptimizationsRendered",
|
|
|
|
// Emitted by the OverviewView when more data has been rendered
|
|
OVERVIEW_RENDERED: "Performance:UI:OverviewRendered",
|
|
FRAMERATE_GRAPH_RENDERED: "Performance:UI:OverviewFramerateRendered",
|
|
MARKERS_GRAPH_RENDERED: "Performance:UI:OverviewMarkersRendered",
|
|
MEMORY_GRAPH_RENDERED: "Performance:UI:OverviewMemoryRendered",
|
|
|
|
// Emitted by the OverviewView when a range has been selected in the graphs
|
|
OVERVIEW_RANGE_SELECTED: "Performance:UI:OverviewRangeSelected",
|
|
// Emitted by the OverviewView when a selection range has been removed
|
|
OVERVIEW_RANGE_CLEARED: "Performance:UI:OverviewRangeCleared",
|
|
|
|
// Emitted by the DetailsView when a subview is selected
|
|
DETAILS_VIEW_SELECTED: "Performance:UI:DetailsViewSelected",
|
|
|
|
// Emitted by the WaterfallView when it has been rendered
|
|
WATERFALL_RENDERED: "Performance:UI:WaterfallRendered",
|
|
|
|
// Emitted by the JsCallTreeView when a call tree has been rendered
|
|
JS_CALL_TREE_RENDERED: "Performance:UI:JsCallTreeRendered",
|
|
|
|
// Emitted by the JsFlameGraphView when it has been rendered
|
|
JS_FLAMEGRAPH_RENDERED: "Performance:UI:JsFlameGraphRendered",
|
|
|
|
// Emitted by the MemoryCallTreeView when a call tree has been rendered
|
|
MEMORY_CALL_TREE_RENDERED: "Performance:UI:MemoryCallTreeRendered",
|
|
|
|
// Emitted by the MemoryFlameGraphView when it has been rendered
|
|
MEMORY_FLAMEGRAPH_RENDERED: "Performance:UI:MemoryFlameGraphRendered",
|
|
|
|
// When a source is shown in the JavaScript Debugger at a specific location.
|
|
SOURCE_SHOWN_IN_JS_DEBUGGER: "Performance:UI:SourceShownInJsDebugger",
|
|
SOURCE_NOT_FOUND_IN_JS_DEBUGGER: "Performance:UI:SourceNotFoundInJsDebugger"
|
|
};
|
|
|
|
/**
|
|
* The current target and the profiler connection, set by this tool's host.
|
|
*/
|
|
let gToolbox, gTarget, gFront;
|
|
|
|
/**
|
|
* Initializes the profiler controller and views.
|
|
*/
|
|
let startupPerformance = Task.async(function*() {
|
|
yield promise.all([
|
|
PerformanceController.initialize(),
|
|
PerformanceView.initialize()
|
|
]);
|
|
});
|
|
|
|
/**
|
|
* Destroys the profiler controller and views.
|
|
*/
|
|
let shutdownPerformance = Task.async(function*() {
|
|
yield promise.all([
|
|
PerformanceController.destroy(),
|
|
PerformanceView.destroy()
|
|
]);
|
|
});
|
|
|
|
/**
|
|
* Functions handling target-related lifetime events and
|
|
* UI interaction.
|
|
*/
|
|
let PerformanceController = {
|
|
_recordings: [],
|
|
_currentRecording: null,
|
|
|
|
/**
|
|
* Listen for events emitted by the current tab target and
|
|
* main UI events.
|
|
*/
|
|
initialize: Task.async(function* () {
|
|
this.startRecording = this.startRecording.bind(this);
|
|
this.stopRecording = this.stopRecording.bind(this);
|
|
this.importRecording = this.importRecording.bind(this);
|
|
this.exportRecording = this.exportRecording.bind(this);
|
|
this.clearRecordings = this.clearRecordings.bind(this);
|
|
this._onRecordingSelectFromView = this._onRecordingSelectFromView.bind(this);
|
|
this._onPrefChanged = this._onPrefChanged.bind(this);
|
|
this._onThemeChanged = this._onThemeChanged.bind(this);
|
|
this._onConsoleProfileStart = this._onConsoleProfileStart.bind(this);
|
|
this._onConsoleProfileEnd = this._onConsoleProfileEnd.bind(this);
|
|
this._onConsoleProfileEnding = this._onConsoleProfileEnding.bind(this);
|
|
|
|
// All boolean prefs should be handled via the OptionsView in the
|
|
// ToolbarView, so that they may be accessible via the "gear" menu.
|
|
// Every other pref should be registered here.
|
|
this._nonBooleanPrefs = new ViewHelpers.Prefs("devtools.performance", {
|
|
"hidden-markers": ["Json", "timeline.hidden-markers"],
|
|
"memory-sample-probability": ["Float", "memory.sample-probability"],
|
|
"memory-max-log-length": ["Int", "memory.max-log-length"],
|
|
"profiler-buffer-size": ["Int", "profiler.buffer-size"],
|
|
"profiler-sample-frequency": ["Int", "profiler.sample-frequency-khz"],
|
|
});
|
|
|
|
this._nonBooleanPrefs.registerObserver();
|
|
this._nonBooleanPrefs.on("pref-changed", this._onPrefChanged);
|
|
|
|
gFront.on("console-profile-start", this._onConsoleProfileStart);
|
|
gFront.on("console-profile-ending", this._onConsoleProfileEnding);
|
|
gFront.on("console-profile-end", this._onConsoleProfileEnd);
|
|
ToolbarView.on(EVENTS.PREF_CHANGED, this._onPrefChanged);
|
|
PerformanceView.on(EVENTS.UI_START_RECORDING, this.startRecording);
|
|
PerformanceView.on(EVENTS.UI_STOP_RECORDING, this.stopRecording);
|
|
PerformanceView.on(EVENTS.UI_IMPORT_RECORDING, this.importRecording);
|
|
PerformanceView.on(EVENTS.UI_CLEAR_RECORDINGS, this.clearRecordings);
|
|
RecordingsView.on(EVENTS.UI_EXPORT_RECORDING, this.exportRecording);
|
|
RecordingsView.on(EVENTS.RECORDING_SELECTED, this._onRecordingSelectFromView);
|
|
|
|
gDevTools.on("pref-changed", this._onThemeChanged);
|
|
}),
|
|
|
|
/**
|
|
* Remove events handled by the PerformanceController
|
|
*/
|
|
destroy: function() {
|
|
this._nonBooleanPrefs.unregisterObserver();
|
|
this._nonBooleanPrefs.off("pref-changed", this._onPrefChanged);
|
|
|
|
gFront.off("console-profile-start", this._onConsoleProfileStart);
|
|
gFront.off("console-profile-ending", this._onConsoleProfileEnding);
|
|
gFront.off("console-profile-end", this._onConsoleProfileEnd);
|
|
ToolbarView.off(EVENTS.PREF_CHANGED, this._onPrefChanged);
|
|
PerformanceView.off(EVENTS.UI_START_RECORDING, this.startRecording);
|
|
PerformanceView.off(EVENTS.UI_STOP_RECORDING, this.stopRecording);
|
|
PerformanceView.off(EVENTS.UI_IMPORT_RECORDING, this.importRecording);
|
|
PerformanceView.off(EVENTS.UI_CLEAR_RECORDINGS, this.clearRecordings);
|
|
RecordingsView.off(EVENTS.UI_EXPORT_RECORDING, this.exportRecording);
|
|
RecordingsView.off(EVENTS.RECORDING_SELECTED, this._onRecordingSelectFromView);
|
|
|
|
gDevTools.off("pref-changed", this._onThemeChanged);
|
|
},
|
|
|
|
/**
|
|
* Returns the current devtools theme.
|
|
*/
|
|
getTheme: function () {
|
|
return Services.prefs.getCharPref("devtools.theme");
|
|
},
|
|
|
|
/**
|
|
* Get a boolean preference setting from `prefName` via the underlying
|
|
* OptionsView in the ToolbarView.
|
|
*
|
|
* @param string prefName
|
|
* @return boolean
|
|
*/
|
|
getOption: function (prefName) {
|
|
return ToolbarView.optionsView.getPref(prefName);
|
|
},
|
|
|
|
/**
|
|
* Get a preference setting from `prefName`.
|
|
* @param string prefName
|
|
* @return object
|
|
*/
|
|
getPref: function (prefName) {
|
|
return this._nonBooleanPrefs[prefName];
|
|
},
|
|
|
|
/**
|
|
* Set a preference setting from `prefName`.
|
|
* @param string prefName
|
|
* @param object prefValue
|
|
*/
|
|
setPref: function (prefName, prefValue) {
|
|
this._nonBooleanPrefs[prefName] = prefValue;
|
|
},
|
|
|
|
/**
|
|
* Starts recording with the PerformanceFront. Emits `EVENTS.RECORDING_STARTED`
|
|
* when the front has started to record.
|
|
*/
|
|
startRecording: Task.async(function *() {
|
|
let options = {
|
|
withMarkers: true,
|
|
withMemory: this.getOption("enable-memory"),
|
|
withTicks: this.getOption("enable-framerate"),
|
|
withAllocations: this.getOption("enable-memory"),
|
|
allocationsSampleProbability: this.getPref("memory-sample-probability"),
|
|
allocationsMaxLogLength: this.getPref("memory-max-log-length"),
|
|
bufferSize: this.getPref("profiler-buffer-size"),
|
|
sampleFrequency: this.getPref("profiler-sample-frequency")
|
|
};
|
|
|
|
this.emit(EVENTS.RECORDING_WILL_START);
|
|
|
|
let recording = yield gFront.startRecording(options);
|
|
this._recordings.push(recording);
|
|
|
|
this.emit(EVENTS.RECORDING_STARTED, recording);
|
|
}),
|
|
|
|
/**
|
|
* Stops recording with the PerformanceFront. Emits `EVENTS.RECORDING_STOPPED`
|
|
* when the front has stopped recording.
|
|
*/
|
|
stopRecording: Task.async(function *() {
|
|
let recording = this.getLatestManualRecording();
|
|
|
|
this.emit(EVENTS.RECORDING_WILL_STOP, recording);
|
|
yield gFront.stopRecording(recording);
|
|
this.emit(EVENTS.RECORDING_STOPPED, recording);
|
|
}),
|
|
|
|
/**
|
|
* Saves the given recording to a file. Emits `EVENTS.RECORDING_EXPORTED`
|
|
* when the file was saved.
|
|
*
|
|
* @param RecordingModel recording
|
|
* The model that holds the recording data.
|
|
* @param nsILocalFile file
|
|
* The file to stream the data into.
|
|
*/
|
|
exportRecording: Task.async(function*(_, recording, file) {
|
|
yield recording.exportRecording(file);
|
|
this.emit(EVENTS.RECORDING_EXPORTED, recording);
|
|
}),
|
|
|
|
/**
|
|
* Clears all recordings from the list as well as the current recording.
|
|
* Emits `EVENTS.RECORDINGS_CLEARED` when complete so other components can clean up.
|
|
*/
|
|
clearRecordings: Task.async(function* () {
|
|
let latest = this.getLatestManualRecording();
|
|
|
|
if (latest && latest.isRecording()) {
|
|
yield this.stopRecording();
|
|
}
|
|
|
|
this._recordings.length = 0;
|
|
this.setCurrentRecording(null);
|
|
this.emit(EVENTS.RECORDINGS_CLEARED);
|
|
}),
|
|
|
|
/**
|
|
* Loads a recording from a file, adding it to the recordings list. Emits
|
|
* `EVENTS.RECORDING_IMPORTED` when the file was loaded.
|
|
*
|
|
* @param nsILocalFile file
|
|
* The file to import the data from.
|
|
*/
|
|
importRecording: Task.async(function*(_, file) {
|
|
let recording = new RecordingModel();
|
|
this._recordings.push(recording);
|
|
yield recording.importRecording(file);
|
|
|
|
this.emit(EVENTS.RECORDING_IMPORTED, recording);
|
|
}),
|
|
|
|
/**
|
|
* Sets the currently active RecordingModel. Should rarely be called directly,
|
|
* as RecordingsView handles this when manually selected a recording item. Exceptions
|
|
* are when clearing the view.
|
|
* @param RecordingModel recording
|
|
*/
|
|
setCurrentRecording: function (recording) {
|
|
if (this._currentRecording !== recording) {
|
|
this._currentRecording = recording;
|
|
this.emit(EVENTS.RECORDING_SELECTED, recording);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Gets the currently active RecordingModel.
|
|
* @return RecordingModel
|
|
*/
|
|
getCurrentRecording: function () {
|
|
return this._currentRecording;
|
|
},
|
|
|
|
/**
|
|
* Get most recently added recording that was triggered manually (via UI).
|
|
* @return RecordingModel
|
|
*/
|
|
getLatestManualRecording: function () {
|
|
for (let i = this._recordings.length - 1; i >= 0; i--) {
|
|
let model = this._recordings[i];
|
|
if (!model.isConsole() && !model.isImported()) {
|
|
return this._recordings[i];
|
|
}
|
|
}
|
|
return null;
|
|
},
|
|
|
|
/**
|
|
* Gets the current timeline blueprint without the hidden markers.
|
|
* @return object
|
|
*/
|
|
getTimelineBlueprint: function() {
|
|
let blueprint = TIMELINE_BLUEPRINT;
|
|
let hiddenMarkers = this.getPref("hidden-markers");
|
|
return RecordingUtils.getFilteredBlueprint({ blueprint, hiddenMarkers });
|
|
},
|
|
|
|
/**
|
|
* 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) {
|
|
this.setCurrentRecording(recording);
|
|
},
|
|
|
|
/**
|
|
* Fired when the ToolbarView fires a PREF_CHANGED event.
|
|
* with the value.
|
|
*/
|
|
_onPrefChanged: function (_, prefName, prefValue) {
|
|
this.emit(EVENTS.PREF_CHANGED, prefName, prefValue);
|
|
},
|
|
|
|
/*
|
|
* Called when the developer tools theme changes.
|
|
*/
|
|
_onThemeChanged: function (_, data) {
|
|
// Right now, gDevTools only emits `pref-changed` for the theme,
|
|
// but this could change in the future.
|
|
if (data.pref !== "devtools.theme") {
|
|
return;
|
|
}
|
|
|
|
this.emit(EVENTS.THEME_CHANGED, data.newValue);
|
|
},
|
|
|
|
/**
|
|
* Fired when `console.profile()` is executed.
|
|
*/
|
|
_onConsoleProfileStart: function (_, recording) {
|
|
this._recordings.push(recording);
|
|
this.emit(EVENTS.CONSOLE_RECORDING_STARTED, recording);
|
|
},
|
|
|
|
/**
|
|
* Fired when `console.profileEnd()` is executed, and the profile
|
|
* is stopping soon, as it fetches profiler data.
|
|
*/
|
|
_onConsoleProfileEnding: function (_, recording) {
|
|
this.emit(EVENTS.CONSOLE_RECORDING_WILL_STOP, recording);
|
|
},
|
|
|
|
/**
|
|
* Fired when `console.profileEnd()` is executed, and
|
|
* has a corresponding `console.profile()` session.
|
|
*/
|
|
_onConsoleProfileEnd: function (_, recording) {
|
|
this.emit(EVENTS.CONSOLE_RECORDING_STOPPED, recording);
|
|
},
|
|
|
|
/**
|
|
* Returns the internal store of recording models.
|
|
*/
|
|
getRecordings: function () {
|
|
return this._recordings;
|
|
},
|
|
|
|
/**
|
|
* Utility method taking the currently selected recording item's features, or optionally passed
|
|
* in recording item, as well as the actor support on the server, returning a boolean
|
|
* indicating if the requirements pass or not. Used to toggle features' visibility mostly.
|
|
*
|
|
* @option {Array<string>} features
|
|
* An array of strings indicating what configuration is needed on the recording
|
|
* model, like `withTicks`, or `withMemory`.
|
|
* @option {Array<string>} actors
|
|
* An array of strings indicating what actors must exist.
|
|
* @option {boolean} isRecording
|
|
* A boolean indicating whether the recording must be either recording or not
|
|
* recording. Setting to undefined will allow either state.
|
|
* @param {RecordingModel} recording
|
|
* An optional recording model to use instead of the currently selected.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
isFeatureSupported: function ({ features, actors, isRecording: shouldBeRecording }, recording) {
|
|
recording = recording || this.getCurrentRecording();
|
|
let recordingConfig = recording ? recording.getConfiguration() : {};
|
|
let currentRecordingState = recording ? recording.isRecording() : void 0;
|
|
let actorsSupported = gFront.getActorSupport();
|
|
|
|
if (shouldBeRecording != null && shouldBeRecording !== currentRecordingState) {
|
|
return false;
|
|
}
|
|
if (actors && !actors.every(a => actorsSupported[a])) {
|
|
return false;
|
|
}
|
|
if (features && !features.every(f => recordingConfig[f])) {
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
|
|
toString: () => "[object PerformanceController]"
|
|
};
|
|
|
|
/**
|
|
* Convenient way of emitting events from the controller.
|
|
*/
|
|
EventEmitter.decorate(PerformanceController);
|
|
|
|
/**
|
|
* DOM query helpers.
|
|
*/
|
|
function $(selector, target = document) {
|
|
return target.querySelector(selector);
|
|
}
|
|
function $$(selector, target = document) {
|
|
return target.querySelectorAll(selector);
|
|
}
|