| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 /** | 6 /** |
| 7 * @interface | 7 * @interface |
| 8 */ | 8 */ |
| 9 SDK.TracingManagerClient = function() {}; | 9 SDK.TracingManagerClient = function() {}; |
| 10 | 10 |
| 11 SDK.TracingManagerClient.prototype = { | 11 SDK.TracingManagerClient.prototype = { |
| 12 /** | 12 /** |
| 13 * @param {!Array.<!SDK.TracingManager.EventPayload>} events | 13 * @param {!Array.<!SDK.TracingManager.EventPayload>} events |
| 14 */ | 14 */ |
| 15 traceEventsCollected(events) {}, | 15 traceEventsCollected(events) {}, |
| 16 tracingComplete() {}, | 16 tracingComplete() {}, |
| 17 /** | 17 /** |
| 18 * @param {number} usage | 18 * @param {number} usage |
| 19 */ | 19 */ |
| 20 tracingBufferUsage(usage) {}, | 20 tracingBufferUsage(usage) {}, |
| 21 /** | 21 /** |
| 22 * @param {number} progress | 22 * @param {number} progress |
| 23 */ | 23 */ |
| 24 eventsRetrievalProgress(progress) {} | 24 eventsRetrievalProgress(progress) {} |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * @unrestricted | 28 * @unrestricted |
| 29 */ | 29 */ |
| 30 SDK.TracingManager = class { | 30 SDK.TracingManager = class extends SDK.SDKModel { |
| 31 /** | 31 /** |
| 32 * @param {!SDK.Target} target | 32 * @param {!SDK.Target} target |
| 33 */ | 33 */ |
| 34 constructor(target) { | 34 constructor(target) { |
| 35 this._target = target; | 35 super(target); |
| 36 this._tracingAgent = target.tracingAgent(); |
| 36 target.registerTracingDispatcher(new SDK.TracingDispatcher(this)); | 37 target.registerTracingDispatcher(new SDK.TracingDispatcher(this)); |
| 37 | 38 |
| 38 /** @type {?SDK.TracingManagerClient} */ | 39 /** @type {?SDK.TracingManagerClient} */ |
| 39 this._activeClient = null; | 40 this._activeClient = null; |
| 40 this._eventBufferSize = 0; | 41 this._eventBufferSize = 0; |
| 41 this._eventsRetrieved = 0; | 42 this._eventsRetrieved = 0; |
| 42 } | 43 } |
| 43 | 44 |
| 44 /** | 45 /** |
| 45 * @return {?SDK.Target} | |
| 46 */ | |
| 47 target() { | |
| 48 return this._target; | |
| 49 } | |
| 50 | |
| 51 /** | |
| 52 * @param {number=} usage | 46 * @param {number=} usage |
| 53 * @param {number=} eventCount | 47 * @param {number=} eventCount |
| 54 * @param {number=} percentFull | 48 * @param {number=} percentFull |
| 55 */ | 49 */ |
| 56 _bufferUsage(usage, eventCount, percentFull) { | 50 _bufferUsage(usage, eventCount, percentFull) { |
| 57 this._eventBufferSize = eventCount; | 51 this._eventBufferSize = eventCount; |
| 58 this._activeClient.tracingBufferUsage(usage || percentFull || 0); | 52 this._activeClient.tracingBufferUsage(usage || percentFull || 0); |
| 59 } | 53 } |
| 60 | 54 |
| 61 /** | 55 /** |
| (...skipping 21 matching lines...) Expand all Loading... |
| 83 * @param {!SDK.TracingManagerClient} client | 77 * @param {!SDK.TracingManagerClient} client |
| 84 * @param {string} categoryFilter | 78 * @param {string} categoryFilter |
| 85 * @param {string} options | 79 * @param {string} options |
| 86 * @return {!Promise} | 80 * @return {!Promise} |
| 87 */ | 81 */ |
| 88 start(client, categoryFilter, options) { | 82 start(client, categoryFilter, options) { |
| 89 if (this._activeClient) | 83 if (this._activeClient) |
| 90 throw new Error('Tracing is already started'); | 84 throw new Error('Tracing is already started'); |
| 91 var bufferUsageReportingIntervalMs = 500; | 85 var bufferUsageReportingIntervalMs = 500; |
| 92 this._activeClient = client; | 86 this._activeClient = client; |
| 93 return this._target.tracingAgent().start( | 87 return this._tracingAgent.start( |
| 94 categoryFilter, options, bufferUsageReportingIntervalMs, SDK.TracingMana
ger.TransferMode.ReportEvents); | 88 categoryFilter, options, bufferUsageReportingIntervalMs, SDK.TracingMana
ger.TransferMode.ReportEvents); |
| 95 } | 89 } |
| 96 | 90 |
| 97 stop() { | 91 stop() { |
| 98 if (!this._activeClient) | 92 if (!this._activeClient) |
| 99 throw new Error('Tracing is not started'); | 93 throw new Error('Tracing is not started'); |
| 100 if (this._finishing) | 94 if (this._finishing) |
| 101 throw new Error('Tracing is already being stopped'); | 95 throw new Error('Tracing is already being stopped'); |
| 102 this._finishing = true; | 96 this._finishing = true; |
| 103 this._target.tracingAgent().end(); | 97 this._tracingAgent.end(); |
| 104 } | 98 } |
| 105 }; | 99 }; |
| 106 | 100 |
| 101 SDK.SDKModel.register(SDK.TracingManager, SDK.Target.Capability.Tracing); |
| 102 |
| 107 /** @typedef {!{ | 103 /** @typedef {!{ |
| 108 cat: string, | 104 cat: string, |
| 109 pid: number, | 105 pid: number, |
| 110 tid: number, | 106 tid: number, |
| 111 ts: number, | 107 ts: number, |
| 112 ph: string, | 108 ph: string, |
| 113 name: string, | 109 name: string, |
| 114 args: !Object, | 110 args: !Object, |
| 115 dur: number, | 111 dur: number, |
| 116 id: string, | 112 id: string, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 this._tracingManager._eventsCollected(data); | 153 this._tracingManager._eventsCollected(data); |
| 158 } | 154 } |
| 159 | 155 |
| 160 /** | 156 /** |
| 161 * @override | 157 * @override |
| 162 */ | 158 */ |
| 163 tracingComplete() { | 159 tracingComplete() { |
| 164 this._tracingManager._tracingComplete(); | 160 this._tracingManager._tracingComplete(); |
| 165 } | 161 } |
| 166 }; | 162 }; |
| OLD | NEW |