Chromium Code Reviews| Index: Source/devtools/front_end/sdk/TracingModel.js |
| diff --git a/Source/devtools/front_end/sdk/TracingModel.js b/Source/devtools/front_end/sdk/TracingModel.js |
| index f05b1aa643a242467eb29d5f246f14e38128965b..fdf0f7df42ef6c675328d21fdb9f3efc2b35e32e 100644 |
| --- a/Source/devtools/front_end/sdk/TracingModel.js |
| +++ b/Source/devtools/front_end/sdk/TracingModel.js |
| @@ -9,16 +9,17 @@ |
| * @extends {WebInspector.Object} |
| * @implements {WebInspector.TargetManager.Observer} |
| */ |
| -WebInspector.TracingModel = function() |
| +WebInspector.TracingManager = function() |
| { |
| - this.reset(); |
| + WebInspector.Object.call(this); |
| this._active = false; |
| WebInspector.targetManager.observeTargets(this); |
| } |
| -WebInspector.TracingModel.Events = { |
| +WebInspector.TracingManager.Events = { |
| "BufferUsage": "BufferUsage", |
| "TracingStarted": "TracingStarted", |
| + "EventsCollected": "EventsCollected", |
| "TracingStopped": "TracingStopped", |
| "TracingComplete": "TracingComplete" |
| } |
| @@ -36,7 +37,98 @@ WebInspector.TracingModel.Events = { |
| s: string |
| }} |
| */ |
| -WebInspector.TracingModel.EventPayload; |
| +WebInspector.TracingManager.EventPayload; |
|
yurys
2014/09/10 09:57:42
Can we move it somewhere else to avoid dependency
caseq
2014/09/10 11:59:56
I like the idea, but let's do it as a separate cha
|
| + |
| + |
| +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); |
| + }, |
| + |
| + /** |
| + * @param {string} categoryFilter |
| + * @param {string} options |
| + * @param {function(?string)=} callback |
| + */ |
| + start: function(categoryFilter, options, callback) |
| + { |
| + if (this._active) |
| + return; |
| + WebInspector.profilingLock().acquire(); |
| + this._active = true; |
| + this._shouldReleaseLock = true; |
| + var bufferUsageReportingIntervalMs = 500; |
| + TracingAgent.start(categoryFilter, options, bufferUsageReportingIntervalMs, callback); |
| + this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingStarted); |
| + }, |
| + |
| + 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} |
| @@ -91,27 +183,6 @@ WebInspector.TracingModel.isAsyncPhase = function(phase) |
| 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>} |
| */ |
| devtoolsPageMetadataEvents: function() |
| @@ -128,32 +199,6 @@ WebInspector.TracingModel.prototype = { |
| }, |
| /** |
| - * @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} |
| */ |
| sessionId: function() |
| @@ -162,60 +207,31 @@ WebInspector.TracingModel.prototype = { |
| }, |
| /** |
| - * @param {!Array.<!WebInspector.TracingModel.EventPayload>} events |
| + * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events |
| */ |
| setEventsForTest: function(events) |
| { |
| - this._tracingStarted(); |
| - this._eventsCollected(events); |
| - this._tracingComplete(); |
| - }, |
| - |
| - /** |
| - * @param {number} usage |
| - */ |
| - _bufferUsage: function(usage) |
| - { |
| - this.dispatchEventToListeners(WebInspector.TracingModel.Events.BufferUsage, usage); |
| + this.reset(); |
| + this.addEvents(events); |
| + this.tracingComplete(); |
| }, |
| /** |
| - * @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) { |
| this._addEvent(events[i]); |
| this._rawEvents.push(events[i]); |
| } |
| }, |
| - _tracingComplete: function() |
| + tracingComplete: function() |
| { |
| this._processMetadataEvents(); |
| - this._active = false; |
| for (var process in this._processById) |
| 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() |
| @@ -230,7 +246,7 @@ WebInspector.TracingModel.prototype = { |
| }, |
| /** |
| - * @return {!Array.<!WebInspector.TracingModel.EventPayload>} |
| + * @return {!Array.<!WebInspector.TracingManager.EventPayload>} |
| */ |
| rawEvents: function() |
| { |
| @@ -238,7 +254,7 @@ WebInspector.TracingModel.prototype = { |
| }, |
| /** |
| - * @param {!WebInspector.TracingModel.EventPayload} payload |
| + * @param {!WebInspector.TracingManager.EventPayload} payload |
| */ |
| _addEvent: function(payload) |
| { |
| @@ -331,9 +347,7 @@ WebInspector.TracingModel.prototype = { |
| sortedProcesses: function() |
| { |
| return WebInspector.TracingModel.NamedObject._sort(Object.values(this._processById)); |
| - }, |
| - |
| - __proto__: WebInspector.Object.prototype |
| + } |
| } |
| @@ -349,20 +363,20 @@ WebInspector.TracingModel.Loader = function(tracingModel) |
| WebInspector.TracingModel.Loader.prototype = { |
| /** |
| - * @param {!Array.<!WebInspector.TracingModel.EventPayload>} events |
| + * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events |
| */ |
| loadNextChunk: function(events) |
| { |
| if (!this._firstChunkReceived) { |
| - this._tracingModel._tracingStarted(); |
| + this._tracingModel.reset(); |
| this._firstChunkReceived = true; |
| } |
| - this._tracingModel._eventsCollected(events); |
| + this._tracingModel.addEvents(events); |
| }, |
| finish: function() |
| { |
| - this._tracingModel._tracingComplete(); |
| + this._tracingModel.tracingComplete(); |
| } |
| } |
| @@ -402,7 +416,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 |
| * @return {!WebInspector.TracingModel.Event} |
| */ |
| @@ -448,7 +462,7 @@ WebInspector.TracingModel.Event.prototype = { |
| }, |
| /** |
| - * @param {!WebInspector.TracingModel.EventPayload} payload |
| + * @param {!WebInspector.TracingManager.EventPayload} payload |
| */ |
| _complete: function(payload) |
| { |
| @@ -544,7 +558,7 @@ WebInspector.TracingModel.Process = function(id) |
| this._setName("Process " + id); |
| this._threads = {}; |
| this._objects = {}; |
| - /** @type {!Array.<!WebInspector.TracingModel.EventPayload>} */ |
| + /** @type {!Array.<!WebInspector.TracingManager.EventPayload>} */ |
| this._asyncEvents = []; |
| /** @type {!Object.<string, ?Array.<!WebInspector.TracingModel.Event>>} */ |
| this._openAsyncEvents = []; |
| @@ -566,7 +580,7 @@ WebInspector.TracingModel.Process.prototype = { |
| }, |
| /** |
| - * @param {!WebInspector.TracingModel.EventPayload} payload |
| + * @param {!WebInspector.TracingManager.EventPayload} payload |
| * @return {?WebInspector.TracingModel.Event} event |
| */ |
| _addEvent: function(payload) |
| @@ -590,8 +604,8 @@ WebInspector.TracingModel.Process.prototype = { |
| _tracingComplete: function(lastEventTime) |
| { |
| /** |
| - * @param {!WebInspector.TracingModel.EventPayload} a |
| - * @param {!WebInspector.TracingModel.EventPayload} b |
| + * @param {!WebInspector.TracingManager.EventPayload} a |
| + * @param {!WebInspector.TracingManager.EventPayload} b |
| */ |
| function comparePayloadTimestamp(a, b) |
| { |
| @@ -611,7 +625,7 @@ WebInspector.TracingModel.Process.prototype = { |
| }, |
| /** |
| - * @param {!WebInspector.TracingModel.EventPayload} payload |
| + * @param {!WebInspector.TracingManager.EventPayload} payload |
| */ |
| _addAsyncEvent: function(payload) |
| { |
| @@ -713,7 +727,7 @@ WebInspector.TracingModel.Thread.prototype = { |
| }, |
| /** |
| - * @param {!WebInspector.TracingModel.EventPayload} payload |
| + * @param {!WebInspector.TracingManager.EventPayload} payload |
| * @return {?WebInspector.TracingModel.Event} event |
| */ |
| _addEvent: function(payload) |
| @@ -778,11 +792,11 @@ WebInspector.TracingModel.Thread.prototype = { |
| /** |
| * @constructor |
| * @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 = { |
| @@ -791,24 +805,23 @@ WebInspector.TracingDispatcher.prototype = { |
| */ |
| 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) |
| { |
| - this._tracingModel._eventsCollected(data); |
| + this._tracingManager._eventsCollected(data); |
| }, |
| tracingComplete: function() |
| { |
| - this._tracingModel._tracingComplete(); |
| + this._tracingManager._tracingComplete(); |
| }, |
| started: function() |
| { |
|
yurys
2014/09/10 09:57:42
How do we handle console.timeline initiated record
caseq
2014/09/10 11:59:56
Reverted this one. Sorry, got a bit carried away w
|
| - this._tracingModel._tracingStarted(); |
| } |
| } |