Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Unified Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js

Issue 2883143003: Timeline: do not start timeline on regular page reloads (Closed)
Patch Set: minor tweaks Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js
index cdba648ce0c9c98d246f6a7fc0c2f69f8c83593c..3a766bb7a4a08e365b4288bb85fb6da7cea6327f 100644
--- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js
+++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js
@@ -46,6 +46,7 @@ Timeline.TimelinePanel = class extends UI.Panel {
/** @type {!Array<!UI.ToolbarItem>} */
this._recordingOptionUIControls = [];
this._state = Timeline.TimelinePanel.State.Idle;
+ this._recordingPageReload = false;
this._windowStartTime = 0;
this._windowEndTime = Infinity;
this._millisecondsToRecordAfterLoadEvent = 3000;
@@ -105,8 +106,6 @@ Timeline.TimelinePanel = class extends UI.Panel {
this._createFileSelector();
SDK.targetManager.addModelListener(
- SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.PageReloadRequested, this._pageReloadRequested, this);
- SDK.targetManager.addModelListener(
SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.Load, this._loadEventFired, this);
if (Runtime.experiments.isEnabled('timelineMultipleMainViews')) {
@@ -217,7 +216,7 @@ Timeline.TimelinePanel = class extends UI.Panel {
_populateToolbar() {
// Record
this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._toggleRecordAction));
- this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButtonForId('main.reload'));
+ this._panelToolbar.appendToolbarItem(UI.Toolbar.createActionButtonForId('timeline.record-reload'));
this._clearButton = new UI.ToolbarButton(Common.UIString('Clear'), 'largeicon-clear');
this._clearButton.addEventListener(UI.ToolbarButton.Events.Click, () => this._clear());
this._panelToolbar.appendToolbarItem(this._clearButton);
@@ -507,16 +506,17 @@ Timeline.TimelinePanel = class extends UI.Panel {
}
/**
- * @param {!SDK.TracingManager} tracingManager
- * @param {boolean} userInitiated
* @return {!Promise}
*/
- _startRecording(tracingManager, userInitiated) {
+ _startRecording() {
+ var tracingManagers = SDK.targetManager.models(SDK.TracingManager);
+ if (!tracingManagers.length)
+ return Promise.resolve();
+
console.assert(!this._statusPane, 'Status pane is already opened.');
this._setState(Timeline.TimelinePanel.State.StartPending);
this._showRecordingStarted();
- this._autoRecordGeneration = userInitiated ? null : {tracingManager: tracingManager};
var enabledTraceProviders = Extensions.extensionServer.traceProviders().filter(
provider => Timeline.TimelinePanel._settingForTraceProvider(provider).get());
@@ -527,9 +527,8 @@ Timeline.TimelinePanel = class extends UI.Panel {
};
this._pendingPerformanceModel = new Timeline.PerformanceModel();
- this._controller = new Timeline.TimelineController(tracingManager, this._pendingPerformanceModel, this);
- Host.userMetrics.actionTaken(
- userInitiated ? Host.UserMetrics.Action.TimelineStarted : Host.UserMetrics.Action.TimelinePageReloadStarted);
+ this._controller = new Timeline.TimelineController(tracingManagers[0], this._pendingPerformanceModel, this);
+ Host.userMetrics.actionTaken(Host.UserMetrics.Action.TimelineStarted);
this._setUIControlsEnabled(false);
this._hideLandingPage();
return this._controller.startRecording(recordingOptions, enabledTraceProviders)
@@ -543,7 +542,6 @@ Timeline.TimelinePanel = class extends UI.Panel {
this._statusPane.updateProgressBar(Common.UIString('Received'), 0);
}
this._setState(Timeline.TimelinePanel.State.StopPending);
- this._autoRecordGeneration = null;
this._controller.stopRecording();
this._controller = null;
this._setUIControlsEnabled(true);
@@ -564,14 +562,20 @@ Timeline.TimelinePanel = class extends UI.Panel {
_toggleRecording() {
if (this._state === Timeline.TimelinePanel.State.Idle) {
- var tracingManagers = SDK.targetManager.models(SDK.TracingManager);
- if (tracingManagers.length)
- this._startRecording(tracingManagers[0], true);
+ this._recordingPageReload = false;
+ this._startRecording();
} else if (this._state === Timeline.TimelinePanel.State.Recording) {
this._stopRecording();
}
}
+ _recordReload() {
+ if (this._state !== Timeline.TimelinePanel.State.Idle)
+ return;
+ this._recordingPageReload = true;
+ this._startRecording();
+ }
+
_clear() {
this._showLandingPage();
this._reset();
@@ -617,6 +621,12 @@ Timeline.TimelinePanel = class extends UI.Panel {
}
_recordingStarted() {
+ if (this._recordingPageReload) {
+ var target = this._controller.mainTarget();
+ var resourceModel = target.model(SDK.ResourceTreeModel);
+ if (resourceModel)
+ resourceModel.reloadPage();
+ }
this._reset();
this._setState(Timeline.TimelinePanel.State.Recording);
this._showRecordingStarted();
@@ -667,7 +677,7 @@ Timeline.TimelinePanel = class extends UI.Panel {
var centered = this._landingPage.contentElement.createChild('div');
var recordButton = UI.createInlineButton(UI.Toolbar.createActionButton(this._toggleRecordAction));
- var reloadButton = UI.createInlineButton(UI.Toolbar.createActionButtonForId('main.reload'));
+ var reloadButton = UI.createInlineButton(UI.Toolbar.createActionButtonForId('timeline.record-reload'));
centered.createChild('p').appendChild(UI.formatLocalized(
'Click the record button %s or hit %s to capture a new recording.\n' +
@@ -793,35 +803,21 @@ Timeline.TimelinePanel = class extends UI.Panel {
/**
* @param {!Common.Event} event
*/
- _pageReloadRequested(event) {
- if (this._state !== Timeline.TimelinePanel.State.Idle || !this.isShowing())
- return;
- var resourceTreeModel = /** @type {!SDK.ResourceTreeModel} */ (event.data);
- var tracingManager = resourceTreeModel.target().model(SDK.TracingManager);
- if (resourceTreeModel.target() !== SDK.targetManager.mainTarget() || !tracingManager)
- return;
-
- resourceTreeModel.suspendReload();
- this._startRecording(tracingManager, false).then(() => resourceTreeModel.resumeReload());
- }
-
- /**
- * @param {!Common.Event} event
- */
_loadEventFired(event) {
- if (this._state !== Timeline.TimelinePanel.State.Recording || !this._autoRecordGeneration ||
- this._autoRecordGeneration.tracingManager.target() !== event.data.resourceTreeModel.target())
+ if (this._state !== Timeline.TimelinePanel.State.Recording || !this._recordingPageReload ||
+ this._controller.mainTarget() !== event.data.resourceTreeModel.target())
return;
- setTimeout(stopRecordingOnReload.bind(this, this._autoRecordGeneration), this._millisecondsToRecordAfterLoadEvent);
+ setTimeout(stopRecordingOnReload.bind(this, this._controller), this._millisecondsToRecordAfterLoadEvent);
alph 2017/05/15 23:56:45 await sleep(...)
/**
+ * @param {!Timeline.TimelineController} controller
* @this {Timeline.TimelinePanel}
- * @param {!Object} recordGeneration
*/
- function stopRecordingOnReload(recordGeneration) {
+ function stopRecordingOnReload(controller) {
// Check if we're still in the same recording session.
- if (this._state !== Timeline.TimelinePanel.State.Recording || this._autoRecordGeneration !== recordGeneration)
+ if (controller !== this._controller)
return;
+ this._recordingPageReload = false;
this._stopRecording();
}
}
@@ -1294,6 +1290,9 @@ Timeline.TimelinePanel.ActionDelegate = class {
case 'timeline.toggle-recording':
panel._toggleRecording();
return true;
+ case 'timeline.record-reload':
+ panel._recordReload();
+ return true;
case 'timeline.save-to-file':
panel._saveToFile();
return true;

Powered by Google App Engine
This is Rietveld 408576698