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);
86 * @param {string} categoryFilter
87 * @param {string} options
88 * @param {function(?string)=} callback
90 start: function(categoryFilter, options, callback)
94 WebInspector.targetManager.suspendAllTargets();
95 var bufferUsageReportingIntervalMs = 500;
96 TracingAgent.start(categoryFilter, options, bufferUsageReportingIntervalMs, callback);
98 this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingStarted);
105 TracingAgent.end(this._onStop.bind(this));
106 WebInspector.targetManager.resumeAllTargets();
113 this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingStopped);
114 this._active = false;
117 __proto__: WebInspector.Object.prototype
122 * @implements {TracingAgent.Dispatcher}
123 * @param {!WebInspector.TracingManager} tracingManager
125 WebInspector.TracingDispatcher = function(tracingManager)
127 this._tracingManager = tracingManager;
130 WebInspector.TracingDispatcher.prototype = {
132 * @param {number} usage
134 bufferUsage: function(usage)
136 this._tracingManager._bufferUsage(usage);
140 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} data
142 dataCollected: function(data)
144 this._tracingManager._eventsCollected(data);
147 tracingComplete: function()
149 this._tracingManager._tracingComplete();