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

Unified Diff: Source/devtools/front_end/timeline/TimelineModelImpl.js

Issue 397823003: DevTools: Support multiple target in TimelineModelImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix tests Created 6 years, 5 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/timeline/TimelineModelImpl.js
diff --git a/Source/devtools/front_end/timeline/TimelineModelImpl.js b/Source/devtools/front_end/timeline/TimelineModelImpl.js
index 2525bd0c4e7cb9360efb62186ee0842c73f2298e..ee6450fb8fd8a4b65eefa1a458e95fda7f186968 100644
--- a/Source/devtools/front_end/timeline/TimelineModelImpl.js
+++ b/Source/devtools/front_end/timeline/TimelineModelImpl.js
@@ -5,33 +5,40 @@
/**
* @constructor
* @extends {WebInspector.TimelineModel}
- * @param {!WebInspector.TimelineManager} timelineManager
+ * @implements {WebInspector.TargetManager.Observer}
*/
-WebInspector.TimelineModelImpl = function(timelineManager)
+WebInspector.TimelineModelImpl = function()
{
WebInspector.TimelineModel.call(this);
- this._target = timelineManager.target();
- this._timelineManager = timelineManager;
+ /** @type {?WebInspector.Target} */
+ this._currentTarget = null;
this._filters = [];
this._bindings = new WebInspector.TimelineModelImpl.InterRecordBindings();
this.reset();
- this._timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onRecordAdded, this);
- this._timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStarted, this._onStarted, this);
- this._timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineStopped, this._onStopped, this);
- this._timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineProgress, this._onProgress, this);
+ WebInspector.targetManager.addModelListener(WebInspector.TimelineManager, WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, this._onRecordAdded, this);
+ WebInspector.targetManager.addModelListener(WebInspector.TimelineManager, WebInspector.TimelineManager.EventTypes.TimelineStarted, this._onStarted, this);
+ WebInspector.targetManager.addModelListener(WebInspector.TimelineManager, WebInspector.TimelineManager.EventTypes.TimelineStopped, this._onStopped, this);
+ WebInspector.targetManager.addModelListener(WebInspector.TimelineManager, WebInspector.TimelineManager.EventTypes.TimelineProgress, this._onProgress, this);
+ WebInspector.targetManager.observeTargets(this);
}
WebInspector.TimelineModelImpl.TransferChunkLengthBytes = 5000000;
WebInspector.TimelineModelImpl.prototype = {
/**
- * @return {boolean}
+ * @param {!WebInspector.Target} target
*/
- loadedFromFile: function()
+ targetAdded: function(target) { },
+
+ /**
+ * @param {!WebInspector.Target} target
+ */
+ targetRemoved: function(target)
{
- return this._loadedFromFile;
+ if (this._currentTarget === target)
+ this._currentTarget = null;
},
/**
@@ -42,21 +49,27 @@ WebInspector.TimelineModelImpl.prototype = {
startRecording: function(captureStacks, captureMemory, capturePictures)
{
console.assert(!capturePictures, "Legacy timeline does not support capturing pictures");
- this._clientInitiatedRecording = true;
this.reset();
+ this._currentTarget = WebInspector.context.flavor(WebInspector.Target);
+ console.assert(this._currentTarget);
+
+ this._clientInitiatedRecording = true;
var maxStackFrames = captureStacks ? 30 : 0;
var includeGPUEvents = WebInspector.experimentsSettings.gpuTimeline.isEnabled();
var liveEvents = [ WebInspector.TimelineModel.RecordType.BeginFrame,
WebInspector.TimelineModel.RecordType.DrawFrame,
WebInspector.TimelineModel.RecordType.RequestMainThreadFrame,
WebInspector.TimelineModel.RecordType.ActivateLayerTree ];
- this._timelineManager.start(maxStackFrames, WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled(), liveEvents.join(","), captureMemory, includeGPUEvents, this._fireRecordingStarted.bind(this));
+ this._currentTarget.timelineManager.start(maxStackFrames, WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled(), liveEvents.join(","), captureMemory, includeGPUEvents, this._fireRecordingStarted.bind(this));
},
stopRecording: function()
{
+ if (!this._currentTarget)
+ return;
+
if (!this._clientInitiatedRecording) {
- this._timelineManager.start(undefined, undefined, undefined, undefined, undefined, stopTimeline.bind(this));
+ this._currentTarget.timelineManager.start(undefined, undefined, undefined, undefined, undefined, stopTimeline.bind(this));
return;
}
@@ -67,11 +80,11 @@ WebInspector.TimelineModelImpl.prototype = {
*/
function stopTimeline()
{
- this._timelineManager.stop(this._fireRecordingStopped.bind(this));
+ this._currentTarget.timelineManager.stop(this._fireRecordingStopped.bind(this));
}
this._clientInitiatedRecording = false;
- this._timelineManager.stop(this._fireRecordingStopped.bind(this));
+ this._currentTarget.timelineManager.stop(this._fireRecordingStopped.bind(this));
},
/**
@@ -87,7 +100,8 @@ WebInspector.TimelineModelImpl.prototype = {
*/
_onRecordAdded: function(event)
{
- if (this._collectionEnabled)
+ var timelineManager = /** @type {!WebInspector.TimelineManager} */ (event.target);
+ if (this._collectionEnabled && timelineManager.target() === this._currentTarget)
this._addRecord(/** @type {!TimelineAgent.TimelineEvent} */(event.data));
},
@@ -96,10 +110,15 @@ WebInspector.TimelineModelImpl.prototype = {
*/
_onStarted: function(event)
{
- if (event.data) {
- // Started from console.
- this._fireRecordingStarted();
+ if (!event.data || this._collectionEnabled)
+ return;
+ // Started from console.
+ var timelineManager = /** @type {!WebInspector.TimelineManager} */ (event.target);
+ if (this._currentTarget !== timelineManager.target()) {
+ this.reset();
+ this._currentTarget = timelineManager.target();
}
+ this._fireRecordingStarted();
},
/**
@@ -107,9 +126,14 @@ WebInspector.TimelineModelImpl.prototype = {
*/
_onStopped: function(event)
{
+ var timelineManager = /** @type {!WebInspector.TimelineManager} */ (event.target);
+ if (timelineManager.target() !== this._currentTarget)
+ return;
// If we were buffering events, discard those that got through, the real ones are coming!
- if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled())
+ if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled()) {
this.reset();
+ this._currentTarget = timelineManager.target();
+ }
if (event.data) {
// Stopped from console.
this._fireRecordingStopped(null, null);
@@ -121,7 +145,9 @@ WebInspector.TimelineModelImpl.prototype = {
*/
_onProgress: function(event)
{
- this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingProgress, event.data);
+ var timelineManager = /** @type {!WebInspector.TimelineManager} */ (event.target);
+ if (timelineManager.target() === this._currentTarget)
+ this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingProgress, event.data);
},
_fireRecordingStarted: function()
@@ -236,7 +262,7 @@ WebInspector.TimelineModelImpl.prototype = {
reset: function()
{
- this._loadedFromFile = false;
+ this._currentTarget = null;
this._payloads = [];
this._stringPool = {};
this._bindings._reset();
@@ -396,7 +422,7 @@ WebInspector.TimelineModel.RecordImpl.prototype = {
*/
target: function()
{
- return this._model._target;
+ return this._model._currentTarget;
},
/**
@@ -586,7 +612,6 @@ WebInspector.TimelineModelLoader.prototype = {
close: function()
{
- this._model._loadedFromFile = true;
}
}
« no previous file with comments | « Source/devtools/front_end/timeline/TimelineModel.js ('k') | Source/devtools/front_end/timeline/TimelinePanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698