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

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: 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..7a0b98dfb8037fbbd3d375a98279ae44a5934236 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,21 +153,21 @@ WebInspector.TimelineModel.prototype = {
/**
* @param {boolean=} includeDomCounters
*/
- startRecord: function(includeDomCounters)
+ startRecording: function(includeDomCounters)
{
if (this._collectionEnabled)
return;
this.reset();
var maxStackFrames = WebInspector.settings.timelineLimitStackFramesFlag.get() ? WebInspector.settings.timelineStackFramesToCapture.get() : 30;
- WebInspector.timelineManager.start(maxStackFrames, includeDomCounters);
+ WebInspector.timelineManager.start(maxStackFrames, includeDomCounters, false, this._fireRecordingStarted.bind(this));
this._collectionEnabled = true;
},
- stopRecord: function()
+ stopRecording: function()
{
if (!this._collectionEnabled)
return;
- WebInspector.timelineManager.stop();
+ WebInspector.timelineManager.stop(this._fireRecordingStopped.bind(this));
this._collectionEnabled = false;
},
@@ -173,12 +176,51 @@ 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._collectionEnabled = true;
+ this._fireRecordingStarted();
+ }
+ },
+
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _onStopped: function(event)
+ {
+ if (event.data) {
+ this._collectionEnabled = false;
+ this._fireRecordingStopped();
+ }
+ },
+
+ _fireRecordingStarted: function()
+ {
+ this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStarted);
+ },
+
+ _fireRecordingStopped: function()
+ {
+ this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStopped);
},
+ /**
+ * @param {TimelineAgent.TimelineEvent} record
+ */
_addRecord: function(record)
{
this._stringPool.internObjectStrings(record);
@@ -252,6 +294,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