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

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

Issue 557013005: DevTools: extract TracingManager from TracingModel (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments addressed Created 6 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
« no previous file with comments | « Source/devtools/front_end/timeline/TimelinePanel.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/timeline/TracingTimelineModel.js
diff --git a/Source/devtools/front_end/timeline/TracingTimelineModel.js b/Source/devtools/front_end/timeline/TracingTimelineModel.js
index 7284b459a7adaebb9cbfb8240d6949d8ea35a66b..44d9ad2360028945e298a159ee180028b7a89ccc 100644
--- a/Source/devtools/front_end/timeline/TracingTimelineModel.js
+++ b/Source/devtools/front_end/timeline/TracingTimelineModel.js
@@ -4,17 +4,21 @@
/**
* @constructor
+ * @param {!WebInspector.TracingManager} tracingManager
* @param {!WebInspector.TracingModel} tracingModel
* @param {!WebInspector.TimelineModel.Filter} recordFilter
* @extends {WebInspector.TimelineModel}
*/
-WebInspector.TracingTimelineModel = function(tracingModel, recordFilter)
+WebInspector.TracingTimelineModel = function(tracingManager, tracingModel, recordFilter)
{
WebInspector.TimelineModel.call(this);
+
+ this._tracingManager = tracingManager;
this._tracingModel = tracingModel;
this._recordFilter = recordFilter;
- this._tracingModel.addEventListener(WebInspector.TracingModel.Events.TracingStarted, this._onTracingStarted, this);
- this._tracingModel.addEventListener(WebInspector.TracingModel.Events.TracingComplete, this._onTracingComplete, this);
+ this._tracingManager.addEventListener(WebInspector.TracingManager.Events.TracingStarted, this._onTracingStarted, this);
+ this._tracingManager.addEventListener(WebInspector.TracingManager.Events.EventsCollected, this._onEventsCollected, this);
+ this._tracingManager.addEventListener(WebInspector.TracingManager.Events.TracingComplete, this._onTracingComplete, this);
this.reset();
}
@@ -155,15 +159,17 @@ WebInspector.TracingTimelineModel.prototype = {
this._currentTarget.profilerAgent().stop(this._stopCallbackBarrier.createCallback(this._didStopRecordingJSSamples.bind(this)));
this._jsProfilerStarted = false;
}
- this._tracingModel.stop();
+ this._tracingManager.stop();
},
/**
- * @param {!Array.<!WebInspector.TracingModel.EventPayload>} events
+ * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
*/
setEventsForTest: function(events)
{
- this._tracingModel.setEventsForTest(events);
+ this._onTracingStarted();
+ this._tracingModel.addEvents(events);
+ this._onTracingComplete();
},
_configureCpuProfilerSamplingInterval: function()
@@ -183,18 +189,28 @@ WebInspector.TracingTimelineModel.prototype = {
*/
_startRecordingWithCategories: function(categories)
{
- this.reset();
- this._tracingModel.start(categories, "");
+ this._tracingManager.start(categories, "");
},
_onTracingStarted: function()
{
this.reset();
+ this._tracingModel.reset();
this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStarted);
},
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _onEventsCollected: function(event)
+ {
+ var traceEvents = /** @type {!Array.<!WebInspector.TracingManager.EventPayload>} */ (event.data);
+ this._tracingModel.addEvents(traceEvents);
+ },
+
_onTracingComplete: function()
{
+ this._tracingModel.tracingComplete();
if (this._stopCallbackBarrier)
this._stopCallbackBarrier.callWhenDone(this._didStopRecordingTraceEvents.bind(this));
else
@@ -947,7 +963,7 @@ WebInspector.TracingModelLoader.prototype = {
return;
if (this._firstChunk) {
- this._model.reset();
+ this._model._onTracingStarted();
} else {
var commaIndex = json.indexOf(",");
if (commaIndex !== -1)
@@ -957,7 +973,7 @@ WebInspector.TracingModelLoader.prototype = {
var items;
try {
- items = /** @type {!Array.<!WebInspector.TracingModel.EventPayload>} */ (JSON.parse(json));
+ items = /** @type {!Array.<!WebInspector.TracingManager.EventPayload>} */ (JSON.parse(json));
} catch (e) {
this._reportErrorAndCancelLoading("Malformed timeline data: " + e);
return;
@@ -982,6 +998,7 @@ WebInspector.TracingModelLoader.prototype = {
_reportErrorAndCancelLoading: function(messsage)
{
WebInspector.console.error(messsage);
+ this._model._onTracingComplete();
this._model.reset();
this._reader.cancel();
this._progress.done();
@@ -995,6 +1012,7 @@ WebInspector.TracingModelLoader.prototype = {
close: function()
{
this._loader.finish();
+ this._model._onTracingComplete();
}
}
« no previous file with comments | « Source/devtools/front_end/timeline/TimelinePanel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698