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

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

Issue 1755123003: Timeline: quit using Progress, introduce TimelineLifecycleDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cb89855c97d72e69893874a888e8fe6005ec1fc9..e5274443bc00d18a2b3a3c1b7a7cd918cd334f10 100644
--- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js
+++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js
@@ -32,6 +32,7 @@
/**
* @constructor
* @extends {WebInspector.Panel}
+ * @implements {WebInspector.TimelineLifecycleDelegate}
* @implements {WebInspector.TimelineModeViewDelegate}
* @implements {WebInspector.Searchable}
*/
@@ -388,7 +389,7 @@ WebInspector.TimelinePanel.prototype = {
this._updateTimelineControls();
var clearButton = new WebInspector.ToolbarButton(WebInspector.UIString("Clear recording"), "clear-toolbar-item");
- clearButton.addEventListener("click", this._onClearButtonClick, this);
+ clearButton.addEventListener("click", this._clear, this);
this._panelToolbar.appendToolbarItem(clearButton);
this._panelToolbar.appendSeparator();
@@ -444,33 +445,12 @@ WebInspector.TimelinePanel.prototype = {
addGroupingOption.call(this, WebInspector.UIString("%fx slowdown", rate), rate);
this._panelToolbar.appendToolbarItem(this._cpuThrottlingCombobox);
}
-
- this._progressToolbarItem = new WebInspector.ToolbarItem(createElement("div"));
- this._progressToolbarItem.setVisible(false);
- this._panelToolbar.appendToolbarItem(this._progressToolbarItem);
},
- /**
- * @return {!WebInspector.Progress}
- */
_prepareToLoadTimeline: function()
{
- /**
- * @this {!WebInspector.TimelinePanel}
- */
- function finishLoading()
- {
- this._setState(WebInspector.TimelinePanel.State.Idle);
- this._progressToolbarItem.setVisible(false);
- this._progressToolbarItem.element.removeChildren();
- this._hideRecordingHelpMessage();
- }
- console.assert(this._state === WebInspector.TimelinePanel.State.Idle);
- this._setState(WebInspector.TimelinePanel.State.Loading);
- var progressIndicator = new WebInspector.ProgressIndicator();
- this._progressToolbarItem.setVisible(true);
- this._progressToolbarItem.element.appendChild(progressIndicator.element);
- return new WebInspector.ProgressProxy(progressIndicator, finishLoading.bind(this));
+ console.assert(this._state === WebInspector.TimelinePanel.State.Idle);
+ this._setState(WebInspector.TimelinePanel.State.Loading);
},
_createFileSelector: function()
@@ -536,7 +516,8 @@ WebInspector.TimelinePanel.prototype = {
{
if (this._state !== WebInspector.TimelinePanel.State.Idle)
return;
- WebInspector.TimelineLoader.loadFromFile(this._model, file, this._prepareToLoadTimeline());
+ this._prepareToLoadTimeline();
+ this._loader = WebInspector.TimelineLoader.loadFromFile(this._tracingModel, file, this);
this._createFileSelector();
},
@@ -547,7 +528,8 @@ WebInspector.TimelinePanel.prototype = {
{
if (this._state !== WebInspector.TimelinePanel.State.Idle)
return;
- WebInspector.TimelineLoader.loadFromURL(this._model, url, this._prepareToLoadTimeline());
+ this._prepareToLoadTimeline();
+ this._loader = WebInspector.TimelineLoader.loadFromURL(this._tracingModel, url, this);
},
_refreshViews: function()
@@ -637,8 +619,7 @@ WebInspector.TimelinePanel.prototype = {
{
console.assert(!this._statusPane, "Status pane is already opened.");
this._setState(WebInspector.TimelinePanel.State.StartPending);
- this._statusPane = new WebInspector.TimelinePanel.StatusPane();
- this._statusPane.addEventListener(WebInspector.TimelinePanel.StatusPane.Events.Finish, this._stopRecording, this);
+ this._statusPane = new WebInspector.TimelinePanel.StatusPane(true, this._stopRecording.bind(this));
this._statusPane.showPane(this._statusPaneContainer);
this._statusPane.updateStatus(WebInspector.UIString("Initializing recording\u2026"));
@@ -698,7 +679,7 @@ WebInspector.TimelinePanel.prototype = {
targets[i].heapProfilerAgent().collectGarbage();
},
- _onClearButtonClick: function()
+ _clear: function()
{
this._tracingModel.reset();
this._model.reset();
@@ -816,6 +797,53 @@ WebInspector.TimelinePanel.prototype = {
this._detailsSplitWidget.showBoth();
},
+ /**
+ * @override
+ */
+ loadingStarted: function()
+ {
+ this._hideRecordingHelpMessage();
+ this._model.startCollectingTraceEvents(true);
+
+ if (this._statusPane)
+ this._statusPane.hide();
+ this._statusPane = new WebInspector.TimelinePanel.StatusPane(false, this._cancelLoading.bind(this));
+ this._statusPane.showPane(this._statusPaneContainer);
+ this._statusPane.updateStatus(WebInspector.UIString("Loading timeline\u2026"));
+ this.loadingProgress(0);
+ },
+
+ /**
+ * @override
+ * @param {number=} progress
+ */
+ loadingProgress: function(progress)
+ {
+ if (typeof progress === "number")
+ this._statusPane.updateProgressBar(WebInspector.UIString("Received"), progress * 100);
+ },
+
+ /**
+ * @override
+ * @param {boolean} success
+ */
+ loadingComplete: function(success)
+ {
+ if (!success) {
+ this._onRecordingStopped();
+ this._clear();
+ } else {
+ this._model.tracingComplete();
+ }
+ delete this._loader;
+ },
+
+ _cancelLoading: function()
+ {
+ if (this._loader)
+ this._loader.cancel();
+ },
+
_setMarkers: function()
{
var markers = new Map();
@@ -1245,6 +1273,28 @@ WebInspector.TimelinePanel.prototype = {
}
/**
+ * @interface
+ */
+WebInspector.TimelineLifecycleDelegate = function()
+{
+}
+
+WebInspector.TimelineLifecycleDelegate.prototype = {
+ loadingStarted: function() {},
+
+ /**
+ * @param {number=} progress
+ */
+ loadingProgress: function(progress) {},
+
+ /**
+ * @param {boolean} success
+ */
+ loadingComplete: function(success) {},
+};
+
+
+/**
* @constructor
* @extends {WebInspector.VBox}
* @implements {WebInspector.TimelineModeView}
@@ -1740,8 +1790,10 @@ WebInspector.TimelineStaticFilter.prototype = {
/**
* @constructor
* @extends {WebInspector.VBox}
+ * @param {boolean} showTimer
+ * @param {function()} stopCallback
*/
-WebInspector.TimelinePanel.StatusPane = function()
+WebInspector.TimelinePanel.StatusPane = function(showTimer, stopCallback)
{
WebInspector.VBox.call(this, true);
this.registerRequiredCSS("timeline/timelineStatusDialog.css");
@@ -1751,22 +1803,19 @@ WebInspector.TimelinePanel.StatusPane = function()
statusLine.createChild("div", "label").textContent = WebInspector.UIString("Status");
this._status = statusLine.createChild("div", "content");
- var timeLine = this.contentElement.createChild("div", "status-dialog-line time");
- timeLine.createChild("div", "label").textContent = WebInspector.UIString("Time");
- this._time = timeLine.createChild("div", "content");
-
+ if (showTimer) {
+ var timeLine = this.contentElement.createChild("div", "status-dialog-line time");
+ timeLine.createChild("div", "label").textContent = WebInspector.UIString("Time");
+ this._time = timeLine.createChild("div", "content");
+ }
var progressLine = this.contentElement.createChild("div", "status-dialog-line progress");
this._progressLabel = progressLine.createChild("div", "label");
this._progressBar = progressLine.createChild("div", "indicator-container").createChild("div", "indicator");
- this._stopButton = createTextButton(WebInspector.UIString("Finish"), this._onFinish.bind(this));
+ this._stopButton = createTextButton(WebInspector.UIString("Stop"), stopCallback);
this.contentElement.createChild("div", "stop-button").appendChild(this._stopButton);
}
-WebInspector.TimelinePanel.StatusPane.Events = {
- Finish: "Finish"
-}
-
WebInspector.TimelinePanel.StatusPane.prototype = {
finish: function()
{
@@ -1808,11 +1857,6 @@ WebInspector.TimelinePanel.StatusPane.prototype = {
this._updateTimer();
},
- _onFinish: function()
- {
- this.dispatchEventToListeners(WebInspector.TimelinePanel.StatusPane.Events.Finish);
- },
-
startTimer: function()
{
this._startTime = Date.now();
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698