2 * Copyright 2014 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
9 * @extends {WebInspector.Object}
10 * @implements {WebInspector.TargetManager.Observer}
12 WebInspector.TracingManager = function()
14 WebInspector.Object.call(this);
16 WebInspector.targetManager.observeTargets(this);
19 WebInspector.TracingManager.Events = {
20 "BufferUsage": "BufferUsage",
21 "TracingStarted": "TracingStarted",
22 "EventsCollected": "EventsCollected",
23 "TracingStopped": "TracingStopped",
24 "TracingComplete": "TracingComplete"
40 WebInspector.TracingManager.EventPayload;
42 WebInspector.TracingManager.prototype = {
44 * @param {!WebInspector.Target} target
46 targetAdded: function(target)
50 this._target = target;
51 target.registerTracingDispatcher(new WebInspector.TracingDispatcher(this));
55 * @param {!WebInspector.Target} target
57 targetRemoved: function(target)
59 if (this._target !== target)
65 * @param {number} usage
67 _bufferUsage: function(usage)
69 this.dispatchEventToListeners(WebInspector.TracingManager.Events.BufferUsage, usage);
73 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events
75 _eventsCollected: function(events)
77 this.dispatchEventToListeners(WebInspector.TracingManager.Events.EventsCollected, events);
80 _tracingComplete: function()
82 this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingComplete);
85 _tracingStarted: function()
90 this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingStarted);
94 * @param {string} categoryFilter
95 * @param {string} options
96 * @param {function(?string)=} callback
98 start: function(categoryFilter, options, callback)
102 WebInspector.profilingLock().acquire();
103 this._shouldReleaseLock = true;
104 var bufferUsageReportingIntervalMs = 500;
105 TracingAgent.start(categoryFilter, options, bufferUsageReportingIntervalMs, callback);
106 this._tracingStarted();
114 TracingAgent.end(this._onStop.bind(this));
115 if (this._shouldReleaseLock) {
116 this._shouldReleaseLock = false;
117 WebInspector.profilingLock().release();
125 this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingStopped);
126 this._active = false;
129 __proto__: WebInspector.Object.prototype
134 * @implements {TracingAgent.Dispatcher}
135 * @param {!WebInspector.TracingManager} tracingManager
137 WebInspector.TracingDispatcher = function(tracingManager)
139 this._tracingManager = tracingManager;
142 WebInspector.TracingDispatcher.prototype = {
144 * @param {number} usage
146 bufferUsage: function(usage)
148 this._tracingManager._bufferUsage(usage);
152 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} data
154 dataCollected: function(data)
156 this._tracingManager._eventsCollected(data);
159 tracingComplete: function()
161 this._tracingManager._tracingComplete();
166 this._tracingManager._tracingStarted();