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

Unified Diff: Source/devtools/front_end/TimelineModel.js

Issue 24027002: DevTools: implement console.timeline/timelineEnd. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review comments addressed. Created 7 years, 3 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: Source/devtools/front_end/TimelineModel.js
diff --git a/Source/devtools/front_end/TimelineModel.js b/Source/devtools/front_end/TimelineModel.js
index bc2821265295df0a39afdc8afa9dfb072d32c958..019b6c01bf56761ff8b4aac8c0d2ab95632aa5b8 100644
--- a/Source/devtools/front_end/TimelineModel.js
+++ b/Source/devtools/front_end/TimelineModel.js
@@ -38,9 +38,10 @@ WebInspector.TimelineModel = function()
this._stringPool = new StringPool();
this._minimumRecordTime = -1;
this._maximumRecordTime = -1;
- this._collectionEnabled = false;
WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onRecordAdded, this);
+ WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted, this._onStarted, this);
+ WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStopped, this._onStopped, this);
}
WebInspector.TimelineModel.TransferChunkLengthBytes = 5000000;
@@ -101,7 +102,9 @@ WebInspector.TimelineModel.RecordType = {
WebInspector.TimelineModel.Events = {
RecordAdded: "RecordAdded",
- RecordsCleared: "RecordsCleared"
+ RecordsCleared: "RecordsCleared",
+ RecordingStarted: "RecordingStarted",
+ RecordingStopped: "RecordingStopped"
}
WebInspector.TimelineModel.startTimeInSeconds = function(record)
@@ -150,22 +153,29 @@ WebInspector.TimelineModel.prototype = {
/**
* @param {boolean=} includeDomCounters
*/
- startRecord: function(includeDomCounters)
+ startRecording: function(includeDomCounters)
{
- if (this._collectionEnabled)
- return;
+ this._clientInitiatedRecording = true;
this.reset();
var maxStackFrames = WebInspector.settings.timelineLimitStackFramesFlag.get() ? WebInspector.settings.timelineStackFramesToCapture.get() : 30;
- WebInspector.timelineManager.start(maxStackFrames, includeDomCounters);
- this._collectionEnabled = true;
+ WebInspector.timelineManager.start(maxStackFrames, includeDomCounters, false, this._fireRecordingStarted.bind(this));
},
- stopRecord: function()
+ stopRecording: function()
{
- if (!this._collectionEnabled)
+ if (!this._clientInitiatedRecording) {
+ // Console started this one and we are just sniffing it. Initiate recording so that we
+ // could stop it.
+ function stopTimeline()
+ {
+ WebInspector.timelineManager.stop(this._fireRecordingStopped.bind(this));
+ }
+
+ WebInspector.timelineManager.start(undefined, undefined, undefined, stopTimeline.bind(this));
return;
- WebInspector.timelineManager.stop();
- this._collectionEnabled = false;
+ }
+ this._clientInitiatedRecording = false;
+ WebInspector.timelineManager.stop(this._fireRecordingStopped.bind(this));
},
get records()
@@ -173,12 +183,52 @@ WebInspector.TimelineModel.prototype = {
return this._records;
},
+ /**
+ * @param {WebInspector.Event} event
+ */
_onRecordAdded: function(event)
{
if (this._collectionEnabled)
- this._addRecord(event.data);
+ this._addRecord(/** @type {TimelineAgent.TimelineEvent} */(event.data));
},
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _onStarted: function(event)
+ {
+ if (event.data) {
+ // Started from console.
+ this._fireRecordingStarted();
+ }
+ },
+
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _onStopped: function(event)
+ {
+ if (event.data) {
+ // Stopped from console.
+ this._fireRecordingStopped();
+ }
+ },
+
+ _fireRecordingStarted: function()
+ {
+ this._collectionEnabled = true;
+ this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStarted);
+ },
+
+ _fireRecordingStopped: function()
+ {
+ this._collectionEnabled = false;
+ this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStopped);
+ },
+
+ /**
+ * @param {TimelineAgent.TimelineEvent} record
+ */
_addRecord: function(record)
{
this._stringPool.internObjectStrings(record);
@@ -252,6 +302,9 @@ WebInspector.TimelineModel.prototype = {
return this._maximumRecordTime;
},
+ /**
+ * @param {TimelineAgent.TimelineEvent} record
+ */
_updateBoundaries: function(record)
{
var startTime = WebInspector.TimelineModel.startTimeInSeconds(record);

Powered by Google App Engine
This is Rietveld 408576698