Commit 6c57bd08 authored by caseq@chromium.org's avatar caseq@chromium.org

DevTools: extract TracingManager from TracingModel

Let TracingManager handle back-end interactions while TracingModel
acts just as a container for trace events. The model will later be
moved out of sdk and this will allow introducing backing storage for
trace events (e.g. a file).

BUG=412709

Review URL: https://codereview.chromium.org/557013005

git-svn-id: svn://svn.chromium.org/blink/trunk@181741 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent caf030b0
...@@ -3,8 +3,9 @@ function initialize_TracingTest() ...@@ -3,8 +3,9 @@ function initialize_TracingTest()
// FIXME: remove when tracing is out of experimental // FIXME: remove when tracing is out of experimental
WebInspector.inspectorView.showPanel("timeline"); WebInspector.inspectorView.showPanel("timeline");
InspectorTest.tracingModel = new WebInspector.TracingModel(WebInspector.targetManager.mainTarget()); InspectorTest.tracingManager = WebInspector.panels.timeline._tracingManager || new WebInspector.TracingManager();
InspectorTest.tracingTimelineModel = new WebInspector.TracingTimelineModel(InspectorTest.tracingModel, new WebInspector.TimelineRecordHiddenTypeFilter([])); InspectorTest.tracingModel = new WebInspector.TracingModel();
InspectorTest.tracingTimelineModel = new WebInspector.TracingTimelineModel(InspectorTest.tracingManager, InspectorTest.tracingModel, new WebInspector.TimelineRecordHiddenTypeFilter([]));
InspectorTest.invokeWithTracing = function(functionName, callback, additionalCategories) InspectorTest.invokeWithTracing = function(functionName, callback, additionalCategories)
{ {
......
...@@ -21,6 +21,9 @@ function test() ...@@ -21,6 +21,9 @@ function test()
{ {
WebInspector.inspectorView.showPanel("timeline"); WebInspector.inspectorView.showPanel("timeline");
var tracingManager = new WebInspector.TracingManager();
var tracingModel = new WebInspector.TracingModel();
function runEventsSanityCheck() function runEventsSanityCheck()
{ {
var events = []; var events = [];
...@@ -61,22 +64,29 @@ function test() ...@@ -61,22 +64,29 @@ function test()
function onTracingComplete() function onTracingComplete()
{ {
tracingModel.removeEventListener(WebInspector.TracingModel.Events.TracingComplete, onTracingComplete); tracingManager.removeEventListener(WebInspector.TracingManager.Events.TracingComplete, onTracingComplete);
InspectorTest.addResult("Tracing complete"); InspectorTest.addResult("Tracing complete");
runEventsSanityCheck(); runEventsSanityCheck();
InspectorTest.completeTest(); InspectorTest.completeTest();
} }
var tracingModel = new WebInspector.TracingModel(WebInspector.targetManager.mainTarget()); tracingManager.start("", "", onTracingStarted);
tracingModel.start("", "", onTracingStarted); tracingManager.addEventListener(WebInspector.TracingManager.Events.EventsCollected, onEventsCollected);
function onTracingStarted(error) function onTracingStarted(error)
{ {
InspectorTest.addResult("Tracing started (error: " + JSON.stringify(error) + ")"); InspectorTest.addResult("Tracing started (error: " + JSON.stringify(error) + ")");
tracingModel.reset();
InspectorTest.evaluateInPage("doWork()", function() { InspectorTest.evaluateInPage("doWork()", function() {
tracingModel.addEventListener(WebInspector.TracingModel.Events.TracingComplete, onTracingComplete); tracingManager.addEventListener(WebInspector.TracingManager.Events.TracingComplete, onTracingComplete);
tracingModel.stop(onTracingComplete); tracingManager.stop();
}); });
} }
function onEventsCollected(event)
{
tracingModel.addEvents(event.data);
}
} }
</script> </script>
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
function test() function test()
{ {
InspectorTest.tracingModel.addEventListener(WebInspector.TracingModel.Events.BufferUsage, onBufferUsage, this); InspectorTest.tracingManager.addEventListener(WebInspector.TracingManager.Events.BufferUsage, onBufferUsage, this);
InspectorTest.tracingTimelineModel.startRecording(); InspectorTest.tracingTimelineModel.startRecording();
function onBufferUsage(event) function onBufferUsage(event)
{ {
InspectorTest.tracingModel.removeEventListener(WebInspector.TracingModel.Events.BufferUsage, onBufferUsage, this); InspectorTest.tracingManager.removeEventListener(WebInspector.TracingManager.Events.BufferUsage, onBufferUsage, this);
InspectorTest.tracingTimelineModel.stopRecording(); InspectorTest.tracingTimelineModel.stopRecording();
InspectorTest.addResult("SUCCESS: Received buffer usage update."); InspectorTest.addResult("SUCCESS: Received buffer usage update.");
InspectorTest.completeTest(); InspectorTest.completeTest();
......
...@@ -9,16 +9,17 @@ ...@@ -9,16 +9,17 @@
* @extends {WebInspector.Object} * @extends {WebInspector.Object}
* @implements {WebInspector.TargetManager.Observer} * @implements {WebInspector.TargetManager.Observer}
*/ */
WebInspector.TracingModel = function() WebInspector.TracingManager = function()
{ {
this.reset(); WebInspector.Object.call(this);
this._active = false; this._active = false;
WebInspector.targetManager.observeTargets(this); WebInspector.targetManager.observeTargets(this);
} }
WebInspector.TracingModel.Events = { WebInspector.TracingManager.Events = {
"BufferUsage": "BufferUsage", "BufferUsage": "BufferUsage",
"TracingStarted": "TracingStarted", "TracingStarted": "TracingStarted",
"EventsCollected": "EventsCollected",
"TracingStopped": "TracingStopped", "TracingStopped": "TracingStopped",
"TracingComplete": "TracingComplete" "TracingComplete": "TracingComplete"
} }
...@@ -36,7 +37,106 @@ WebInspector.TracingModel.Events = { ...@@ -36,7 +37,106 @@ WebInspector.TracingModel.Events = {
s: string s: string
}} }}
*/ */
WebInspector.TracingModel.EventPayload; WebInspector.TracingManager.EventPayload;
WebInspector.TracingManager.prototype = {
/**
* @param {!WebInspector.Target} target
*/
targetAdded: function(target)
{
if (this._target)
return;
this._target = target;
InspectorBackend.registerTracingDispatcher(new WebInspector.TracingDispatcher(this));
},
/**
* @param {!WebInspector.Target} target
*/
targetRemoved: function(target)
{
if (this._target !== target)
return;
delete this._target;
},
/**
* @param {number} usage
*/
_bufferUsage: function(usage)
{
this.dispatchEventToListeners(WebInspector.TracingManager.Events.BufferUsage, usage);
},
/**
* @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
*/
_eventsCollected: function(events)
{
this.dispatchEventToListeners(WebInspector.TracingManager.Events.EventsCollected, events);
},
_tracingComplete: function()
{
this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingComplete);
},
_tracingStarted: function()
{
if (this._active)
return;
this._active = true;
this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingStarted);
},
/**
* @param {string} categoryFilter
* @param {string} options
* @param {function(?string)=} callback
*/
start: function(categoryFilter, options, callback)
{
if (this._active)
return;
WebInspector.profilingLock().acquire();
this._shouldReleaseLock = true;
var bufferUsageReportingIntervalMs = 500;
TracingAgent.start(categoryFilter, options, bufferUsageReportingIntervalMs, callback);
this._tracingStarted();
this._active = true;
},
stop: function()
{
if (!this._active)
return;
TracingAgent.end(this._onStop.bind(this));
if (this._shouldReleaseLock) {
this._shouldReleaseLock = false;
WebInspector.profilingLock().release();
}
},
_onStop: function()
{
if (!this._active)
return;
this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingStopped);
this._active = false;
},
__proto__: WebInspector.Object.prototype
}
/**
* @constructor
*/
WebInspector.TracingModel = function()
{
this.reset();
}
/** /**
* @enum {string} * @enum {string}
...@@ -90,27 +190,6 @@ WebInspector.TracingModel.isAsyncPhase = function(phase) ...@@ -90,27 +190,6 @@ WebInspector.TracingModel.isAsyncPhase = function(phase)
} }
WebInspector.TracingModel.prototype = { WebInspector.TracingModel.prototype = {
/**
* @param {!WebInspector.Target} target
*/
targetAdded: function(target)
{
if (this._target)
return;
this._target = target;
InspectorBackend.registerTracingDispatcher(new WebInspector.TracingDispatcher(this));
},
/**
* @param {!WebInspector.Target} target
*/
targetRemoved: function(target)
{
if (this._target !== target)
return;
delete this._target;
},
/** /**
* @return {!Array.<!WebInspector.TracingModel.Event>} * @return {!Array.<!WebInspector.TracingModel.Event>}
*/ */
...@@ -127,32 +206,6 @@ WebInspector.TracingModel.prototype = { ...@@ -127,32 +206,6 @@ WebInspector.TracingModel.prototype = {
return this._devtoolsWorkerMetadataEvents; return this._devtoolsWorkerMetadataEvents;
}, },
/**
* @param {string} categoryFilter
* @param {string} options
* @param {function(?string)=} callback
*/
start: function(categoryFilter, options, callback)
{
WebInspector.profilingLock().acquire();
this._shouldReleaseLock = true;
this.reset();
var bufferUsageReportingIntervalMs = 500;
TracingAgent.start(categoryFilter, options, bufferUsageReportingIntervalMs, callback);
this._tracingStarted();
},
stop: function()
{
if (!this._active)
return;
TracingAgent.end(this._onStop.bind(this));
if (this._shouldReleaseLock) {
this._shouldReleaseLock = false;
WebInspector.profilingLock().release();
}
},
/** /**
* @return {?string} * @return {?string}
*/ */
...@@ -162,60 +215,31 @@ WebInspector.TracingModel.prototype = { ...@@ -162,60 +215,31 @@ WebInspector.TracingModel.prototype = {
}, },
/** /**
* @param {!Array.<!WebInspector.TracingModel.EventPayload>} events * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
*/ */
setEventsForTest: function(events) setEventsForTest: function(events)
{ {
this._tracingStarted(); this.reset();
this._eventsCollected(events); this.addEvents(events);
this._tracingComplete(); this.tracingComplete();
},
/**
* @param {number} usage
*/
_bufferUsage: function(usage)
{
this.dispatchEventToListeners(WebInspector.TracingModel.Events.BufferUsage, usage);
}, },
/** /**
* @param {!Array.<!WebInspector.TracingModel.EventPayload>} events * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
*/ */
_eventsCollected: function(events) addEvents: function(events)
{ {
this._onStop();
for (var i = 0; i < events.length; ++i) { for (var i = 0; i < events.length; ++i) {
this._addEvent(events[i]); this._addEvent(events[i]);
this._rawEvents.push(events[i]); this._rawEvents.push(events[i]);
} }
}, },
_tracingComplete: function() tracingComplete: function()
{ {
this._processMetadataEvents(); this._processMetadataEvents();
this._active = false;
for (var process in this._processById) for (var process in this._processById)
this._processById[process]._tracingComplete(this._maximumRecordTime); this._processById[process]._tracingComplete(this._maximumRecordTime);
this.dispatchEventToListeners(WebInspector.TracingModel.Events.TracingComplete);
},
_tracingStarted: function()
{
if (this._active)
return;
this.reset();
this._active = true;
this._sessionId = null;
this.dispatchEventToListeners(WebInspector.TracingModel.Events.TracingStarted);
},
_onStop: function()
{
if (!this._active)
return;
this.dispatchEventToListeners(WebInspector.TracingModel.Events.TracingStopped);
this._active = false;
}, },
reset: function() reset: function()
...@@ -230,7 +254,7 @@ WebInspector.TracingModel.prototype = { ...@@ -230,7 +254,7 @@ WebInspector.TracingModel.prototype = {
}, },
/** /**
* @return {!Array.<!WebInspector.TracingModel.EventPayload>} * @return {!Array.<!WebInspector.TracingManager.EventPayload>}
*/ */
rawEvents: function() rawEvents: function()
{ {
...@@ -238,7 +262,7 @@ WebInspector.TracingModel.prototype = { ...@@ -238,7 +262,7 @@ WebInspector.TracingModel.prototype = {
}, },
/** /**
* @param {!WebInspector.TracingModel.EventPayload} payload * @param {!WebInspector.TracingManager.EventPayload} payload
*/ */
_addEvent: function(payload) _addEvent: function(payload)
{ {
...@@ -331,9 +355,7 @@ WebInspector.TracingModel.prototype = { ...@@ -331,9 +355,7 @@ WebInspector.TracingModel.prototype = {
sortedProcesses: function() sortedProcesses: function()
{ {
return WebInspector.TracingModel.NamedObject._sort(Object.values(this._processById)); return WebInspector.TracingModel.NamedObject._sort(Object.values(this._processById));
}, }
__proto__: WebInspector.Object.prototype
} }
...@@ -349,20 +371,20 @@ WebInspector.TracingModel.Loader = function(tracingModel) ...@@ -349,20 +371,20 @@ WebInspector.TracingModel.Loader = function(tracingModel)
WebInspector.TracingModel.Loader.prototype = { WebInspector.TracingModel.Loader.prototype = {
/** /**
* @param {!Array.<!WebInspector.TracingModel.EventPayload>} events * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
*/ */
loadNextChunk: function(events) loadNextChunk: function(events)
{ {
if (!this._firstChunkReceived) { if (!this._firstChunkReceived) {
this._tracingModel._tracingStarted(); this._tracingModel.reset();
this._firstChunkReceived = true; this._firstChunkReceived = true;
} }
this._tracingModel._eventsCollected(events); this._tracingModel.addEvents(events);
}, },
finish: function() finish: function()
{ {
this._tracingModel._tracingComplete(); this._tracingModel.tracingComplete();
} }
} }
...@@ -402,7 +424,7 @@ WebInspector.TracingModel.Event = function(category, name, phase, startTime, thr ...@@ -402,7 +424,7 @@ WebInspector.TracingModel.Event = function(category, name, phase, startTime, thr
} }
/** /**
* @param {!WebInspector.TracingModel.EventPayload} payload * @param {!WebInspector.TracingManager.EventPayload} payload
* @param {?WebInspector.TracingModel.Thread} thread * @param {?WebInspector.TracingModel.Thread} thread
* @return {!WebInspector.TracingModel.Event} * @return {!WebInspector.TracingModel.Event}
*/ */
...@@ -448,7 +470,7 @@ WebInspector.TracingModel.Event.prototype = { ...@@ -448,7 +470,7 @@ WebInspector.TracingModel.Event.prototype = {
}, },
/** /**
* @param {!WebInspector.TracingModel.EventPayload} payload * @param {!WebInspector.TracingManager.EventPayload} payload
*/ */
_complete: function(payload) _complete: function(payload)
{ {
...@@ -544,7 +566,7 @@ WebInspector.TracingModel.Process = function(id) ...@@ -544,7 +566,7 @@ WebInspector.TracingModel.Process = function(id)
this._setName("Process " + id); this._setName("Process " + id);
this._threads = {}; this._threads = {};
this._objects = {}; this._objects = {};
/** @type {!Array.<!WebInspector.TracingModel.EventPayload>} */ /** @type {!Array.<!WebInspector.TracingManager.EventPayload>} */
this._asyncEvents = []; this._asyncEvents = [];
/** @type {!Object.<string, ?Array.<!WebInspector.TracingModel.Event>>} */ /** @type {!Object.<string, ?Array.<!WebInspector.TracingModel.Event>>} */
this._openAsyncEvents = []; this._openAsyncEvents = [];
...@@ -566,7 +588,7 @@ WebInspector.TracingModel.Process.prototype = { ...@@ -566,7 +588,7 @@ WebInspector.TracingModel.Process.prototype = {
}, },
/** /**
* @param {!WebInspector.TracingModel.EventPayload} payload * @param {!WebInspector.TracingManager.EventPayload} payload
* @return {?WebInspector.TracingModel.Event} event * @return {?WebInspector.TracingModel.Event} event
*/ */
_addEvent: function(payload) _addEvent: function(payload)
...@@ -590,8 +612,8 @@ WebInspector.TracingModel.Process.prototype = { ...@@ -590,8 +612,8 @@ WebInspector.TracingModel.Process.prototype = {
_tracingComplete: function(lastEventTime) _tracingComplete: function(lastEventTime)
{ {
/** /**
* @param {!WebInspector.TracingModel.EventPayload} a * @param {!WebInspector.TracingManager.EventPayload} a
* @param {!WebInspector.TracingModel.EventPayload} b * @param {!WebInspector.TracingManager.EventPayload} b
*/ */
function comparePayloadTimestamp(a, b) function comparePayloadTimestamp(a, b)
{ {
...@@ -611,7 +633,7 @@ WebInspector.TracingModel.Process.prototype = { ...@@ -611,7 +633,7 @@ WebInspector.TracingModel.Process.prototype = {
}, },
/** /**
* @param {!WebInspector.TracingModel.EventPayload} payload * @param {!WebInspector.TracingManager.EventPayload} payload
*/ */
_addAsyncEvent: function(payload) _addAsyncEvent: function(payload)
{ {
...@@ -713,7 +735,7 @@ WebInspector.TracingModel.Thread.prototype = { ...@@ -713,7 +735,7 @@ WebInspector.TracingModel.Thread.prototype = {
}, },
/** /**
* @param {!WebInspector.TracingModel.EventPayload} payload * @param {!WebInspector.TracingManager.EventPayload} payload
* @return {?WebInspector.TracingModel.Event} event * @return {?WebInspector.TracingModel.Event} event
*/ */
_addEvent: function(payload) _addEvent: function(payload)
...@@ -778,11 +800,11 @@ WebInspector.TracingModel.Thread.prototype = { ...@@ -778,11 +800,11 @@ WebInspector.TracingModel.Thread.prototype = {
/** /**
* @constructor * @constructor
* @implements {TracingAgent.Dispatcher} * @implements {TracingAgent.Dispatcher}
* @param {!WebInspector.TracingModel} tracingModel * @param {!WebInspector.TracingManager} tracingManager
*/ */
WebInspector.TracingDispatcher = function(tracingModel) WebInspector.TracingDispatcher = function(tracingManager)
{ {
this._tracingModel = tracingModel; this._tracingManager = tracingManager;
} }
WebInspector.TracingDispatcher.prototype = { WebInspector.TracingDispatcher.prototype = {
...@@ -791,24 +813,24 @@ WebInspector.TracingDispatcher.prototype = { ...@@ -791,24 +813,24 @@ WebInspector.TracingDispatcher.prototype = {
*/ */
bufferUsage: function(usage) bufferUsage: function(usage)
{ {
this._tracingModel._bufferUsage(usage); this._tracingManager._bufferUsage(usage);
}, },
/** /**
* @param {!Array.<!WebInspector.TracingModel.EventPayload>} data * @param {!Array.<!WebInspector.TracingManager.EventPayload>} data
*/ */
dataCollected: function(data) dataCollected: function(data)
{ {
this._tracingModel._eventsCollected(data); this._tracingManager._eventsCollected(data);
}, },
tracingComplete: function() tracingComplete: function()
{ {
this._tracingModel._tracingComplete(); this._tracingManager._tracingComplete();
}, },
started: function() started: function()
{ {
this._tracingModel._tracingStarted(); this._tracingManager._tracingStarted();
} }
} }
...@@ -49,11 +49,12 @@ WebInspector.TimelinePanel = function() ...@@ -49,11 +49,12 @@ WebInspector.TimelinePanel = function()
// Create model. // Create model.
if (WebInspector.experimentsSettings.timelineOnTraceEvents.isEnabled()) { if (WebInspector.experimentsSettings.timelineOnTraceEvents.isEnabled()) {
this._tracingModel = new WebInspector.TracingModel(); this._tracingManager = new WebInspector.TracingManager();
this._tracingModel.addEventListener(WebInspector.TracingModel.Events.BufferUsage, this._onTracingBufferUsage, this); this._tracingManager.addEventListener(WebInspector.TracingManager.Events.BufferUsage, this._onTracingBufferUsage, this);
this._tracingModel = new WebInspector.TracingModel();
this._uiUtils = new WebInspector.TracingTimelineUIUtils(); this._uiUtils = new WebInspector.TracingTimelineUIUtils();
this._tracingTimelineModel = new WebInspector.TracingTimelineModel(this._tracingModel, this._uiUtils.hiddenRecordsFilter()); this._tracingTimelineModel = new WebInspector.TracingTimelineModel(this._tracingManager, this._tracingModel, this._uiUtils.hiddenRecordsFilter());
this._model = this._tracingTimelineModel; this._model = this._tracingTimelineModel;
} else { } else {
this._uiUtils = new WebInspector.TimelineUIUtilsImpl(); this._uiUtils = new WebInspector.TimelineUIUtilsImpl();
......
...@@ -4,17 +4,21 @@ ...@@ -4,17 +4,21 @@
/** /**
* @constructor * @constructor
* @param {!WebInspector.TracingManager} tracingManager
* @param {!WebInspector.TracingModel} tracingModel * @param {!WebInspector.TracingModel} tracingModel
* @param {!WebInspector.TimelineModel.Filter} recordFilter * @param {!WebInspector.TimelineModel.Filter} recordFilter
* @extends {WebInspector.TimelineModel} * @extends {WebInspector.TimelineModel}
*/ */
WebInspector.TracingTimelineModel = function(tracingModel, recordFilter) WebInspector.TracingTimelineModel = function(tracingManager, tracingModel, recordFilter)
{ {
WebInspector.TimelineModel.call(this); WebInspector.TimelineModel.call(this);
this._tracingManager = tracingManager;
this._tracingModel = tracingModel; this._tracingModel = tracingModel;
this._recordFilter = recordFilter; this._recordFilter = recordFilter;
this._tracingModel.addEventListener(WebInspector.TracingModel.Events.TracingStarted, this._onTracingStarted, this); this._tracingManager.addEventListener(WebInspector.TracingManager.Events.TracingStarted, this._onTracingStarted, this);
this._tracingModel.addEventListener(WebInspector.TracingModel.Events.TracingComplete, this._onTracingComplete, this); this._tracingManager.addEventListener(WebInspector.TracingManager.Events.EventsCollected, this._onEventsCollected, this);
this._tracingManager.addEventListener(WebInspector.TracingManager.Events.TracingComplete, this._onTracingComplete, this);
this.reset(); this.reset();
} }
...@@ -155,15 +159,17 @@ WebInspector.TracingTimelineModel.prototype = { ...@@ -155,15 +159,17 @@ WebInspector.TracingTimelineModel.prototype = {
this._currentTarget.profilerAgent().stop(this._stopCallbackBarrier.createCallback(this._didStopRecordingJSSamples.bind(this))); this._currentTarget.profilerAgent().stop(this._stopCallbackBarrier.createCallback(this._didStopRecordingJSSamples.bind(this)));
this._jsProfilerStarted = false; this._jsProfilerStarted = false;
} }
this._tracingModel.stop(); this._tracingManager.stop();
}, },
/** /**
* @param {!Array.<!WebInspector.TracingModel.EventPayload>} events * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
*/ */
setEventsForTest: function(events) setEventsForTest: function(events)
{ {
this._tracingModel.setEventsForTest(events); this._onTracingStarted();
this._tracingModel.addEvents(events);
this._onTracingComplete();
}, },
_configureCpuProfilerSamplingInterval: function() _configureCpuProfilerSamplingInterval: function()
...@@ -183,18 +189,28 @@ WebInspector.TracingTimelineModel.prototype = { ...@@ -183,18 +189,28 @@ WebInspector.TracingTimelineModel.prototype = {
*/ */
_startRecordingWithCategories: function(categories) _startRecordingWithCategories: function(categories)
{ {
this.reset(); this._tracingManager.start(categories, "");
this._tracingModel.start(categories, "");
}, },
_onTracingStarted: function() _onTracingStarted: function()
{ {
this.reset(); this.reset();
this._tracingModel.reset();
this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStarted); 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() _onTracingComplete: function()
{ {
this._tracingModel.tracingComplete();
if (this._stopCallbackBarrier) if (this._stopCallbackBarrier)
this._stopCallbackBarrier.callWhenDone(this._didStopRecordingTraceEvents.bind(this)); this._stopCallbackBarrier.callWhenDone(this._didStopRecordingTraceEvents.bind(this));
else else
...@@ -947,7 +963,7 @@ WebInspector.TracingModelLoader.prototype = { ...@@ -947,7 +963,7 @@ WebInspector.TracingModelLoader.prototype = {
return; return;
if (this._firstChunk) { if (this._firstChunk) {
this._model.reset(); this._model._onTracingStarted();
} else { } else {
var commaIndex = json.indexOf(","); var commaIndex = json.indexOf(",");
if (commaIndex !== -1) if (commaIndex !== -1)
...@@ -957,7 +973,7 @@ WebInspector.TracingModelLoader.prototype = { ...@@ -957,7 +973,7 @@ WebInspector.TracingModelLoader.prototype = {
var items; var items;
try { try {
items = /** @type {!Array.<!WebInspector.TracingModel.EventPayload>} */ (JSON.parse(json)); items = /** @type {!Array.<!WebInspector.TracingManager.EventPayload>} */ (JSON.parse(json));
} catch (e) { } catch (e) {
this._reportErrorAndCancelLoading("Malformed timeline data: " + e); this._reportErrorAndCancelLoading("Malformed timeline data: " + e);
return; return;
...@@ -982,6 +998,7 @@ WebInspector.TracingModelLoader.prototype = { ...@@ -982,6 +998,7 @@ WebInspector.TracingModelLoader.prototype = {
_reportErrorAndCancelLoading: function(messsage) _reportErrorAndCancelLoading: function(messsage)
{ {
WebInspector.console.error(messsage); WebInspector.console.error(messsage);
this._model._onTracingComplete();
this._model.reset(); this._model.reset();
this._reader.cancel(); this._reader.cancel();
this._progress.done(); this._progress.done();
...@@ -995,6 +1012,7 @@ WebInspector.TracingModelLoader.prototype = { ...@@ -995,6 +1012,7 @@ WebInspector.TracingModelLoader.prototype = {
close: function() close: function()
{ {
this._loader.finish(); this._loader.finish();
this._model._onTracingComplete();
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment