| 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 WebInspector.TracingManagerClient = function() {}; | 9 SDK.TracingManagerClient = function() {}; |
| 10 | 10 |
| 11 WebInspector.TracingManagerClient.prototype = { | 11 SDK.TracingManagerClient.prototype = { |
| 12 tracingStarted: function() {}, | 12 tracingStarted: function() {}, |
| 13 /** | 13 /** |
| 14 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events | 14 * @param {!Array.<!SDK.TracingManager.EventPayload>} events |
| 15 */ | 15 */ |
| 16 traceEventsCollected: function(events) {}, | 16 traceEventsCollected: function(events) {}, |
| 17 tracingComplete: function() {}, | 17 tracingComplete: function() {}, |
| 18 /** | 18 /** |
| 19 * @param {number} usage | 19 * @param {number} usage |
| 20 */ | 20 */ |
| 21 tracingBufferUsage: function(usage) {}, | 21 tracingBufferUsage: function(usage) {}, |
| 22 /** | 22 /** |
| 23 * @param {number} progress | 23 * @param {number} progress |
| 24 */ | 24 */ |
| 25 eventsRetrievalProgress: function(progress) {} | 25 eventsRetrievalProgress: function(progress) {} |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * @unrestricted | 29 * @unrestricted |
| 30 */ | 30 */ |
| 31 WebInspector.TracingManager = class { | 31 SDK.TracingManager = class { |
| 32 /** | 32 /** |
| 33 * @param {!WebInspector.Target} target | 33 * @param {!SDK.Target} target |
| 34 */ | 34 */ |
| 35 constructor(target) { | 35 constructor(target) { |
| 36 this._target = target; | 36 this._target = target; |
| 37 target.registerTracingDispatcher(new WebInspector.TracingDispatcher(this)); | 37 target.registerTracingDispatcher(new SDK.TracingDispatcher(this)); |
| 38 | 38 |
| 39 /** @type {?WebInspector.TracingManagerClient} */ | 39 /** @type {?SDK.TracingManagerClient} */ |
| 40 this._activeClient = null; | 40 this._activeClient = null; |
| 41 this._eventBufferSize = 0; | 41 this._eventBufferSize = 0; |
| 42 this._eventsRetrieved = 0; | 42 this._eventsRetrieved = 0; |
| 43 } | 43 } |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * @return {?WebInspector.Target} | 46 * @return {?SDK.Target} |
| 47 */ | 47 */ |
| 48 target() { | 48 target() { |
| 49 return this._target; | 49 return this._target; |
| 50 } | 50 } |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * @param {number=} usage | 53 * @param {number=} usage |
| 54 * @param {number=} eventCount | 54 * @param {number=} eventCount |
| 55 * @param {number=} percentFull | 55 * @param {number=} percentFull |
| 56 */ | 56 */ |
| 57 _bufferUsage(usage, eventCount, percentFull) { | 57 _bufferUsage(usage, eventCount, percentFull) { |
| 58 this._eventBufferSize = eventCount; | 58 this._eventBufferSize = eventCount; |
| 59 this._activeClient.tracingBufferUsage(usage || percentFull || 0); | 59 this._activeClient.tracingBufferUsage(usage || percentFull || 0); |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events | 63 * @param {!Array.<!SDK.TracingManager.EventPayload>} events |
| 64 */ | 64 */ |
| 65 _eventsCollected(events) { | 65 _eventsCollected(events) { |
| 66 this._activeClient.traceEventsCollected(events); | 66 this._activeClient.traceEventsCollected(events); |
| 67 this._eventsRetrieved += events.length; | 67 this._eventsRetrieved += events.length; |
| 68 if (!this._eventBufferSize) | 68 if (!this._eventBufferSize) |
| 69 return; | 69 return; |
| 70 if (this._eventsRetrieved > this._eventBufferSize) | 70 if (this._eventsRetrieved > this._eventBufferSize) |
| 71 this._eventsRetrieved = this._eventBufferSize; | 71 this._eventsRetrieved = this._eventBufferSize; |
| 72 this._activeClient.eventsRetrievalProgress(this._eventsRetrieved / this._eve
ntBufferSize); | 72 this._activeClient.eventsRetrievalProgress(this._eventsRetrieved / this._eve
ntBufferSize); |
| 73 } | 73 } |
| 74 | 74 |
| 75 _tracingComplete() { | 75 _tracingComplete() { |
| 76 this._eventBufferSize = 0; | 76 this._eventBufferSize = 0; |
| 77 this._eventsRetrieved = 0; | 77 this._eventsRetrieved = 0; |
| 78 this._activeClient.tracingComplete(); | 78 this._activeClient.tracingComplete(); |
| 79 this._activeClient = null; | 79 this._activeClient = null; |
| 80 this._finishing = false; | 80 this._finishing = false; |
| 81 } | 81 } |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * @param {!WebInspector.TracingManagerClient} client | 84 * @param {!SDK.TracingManagerClient} client |
| 85 * @param {string} categoryFilter | 85 * @param {string} categoryFilter |
| 86 * @param {string} options | 86 * @param {string} options |
| 87 * @param {function(?string)=} callback | 87 * @param {function(?string)=} callback |
| 88 */ | 88 */ |
| 89 start(client, categoryFilter, options, callback) { | 89 start(client, categoryFilter, options, callback) { |
| 90 if (this._activeClient) | 90 if (this._activeClient) |
| 91 throw new Error('Tracing is already started'); | 91 throw new Error('Tracing is already started'); |
| 92 var bufferUsageReportingIntervalMs = 500; | 92 var bufferUsageReportingIntervalMs = 500; |
| 93 this._activeClient = client; | 93 this._activeClient = client; |
| 94 this._target.tracingAgent().start( | 94 this._target.tracingAgent().start( |
| 95 categoryFilter, options, bufferUsageReportingIntervalMs, WebInspector.Tr
acingManager.TransferMode.ReportEvents, | 95 categoryFilter, options, bufferUsageReportingIntervalMs, SDK.TracingMana
ger.TransferMode.ReportEvents, |
| 96 callback); | 96 callback); |
| 97 this._activeClient.tracingStarted(); | 97 this._activeClient.tracingStarted(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 stop() { | 100 stop() { |
| 101 if (!this._activeClient) | 101 if (!this._activeClient) |
| 102 throw new Error('Tracing is not started'); | 102 throw new Error('Tracing is not started'); |
| 103 if (this._finishing) | 103 if (this._finishing) |
| 104 throw new Error('Tracing is already being stopped'); | 104 throw new Error('Tracing is already being stopped'); |
| 105 this._finishing = true; | 105 this._finishing = true; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 116 name: string, | 116 name: string, |
| 117 args: !Object, | 117 args: !Object, |
| 118 dur: number, | 118 dur: number, |
| 119 id: string, | 119 id: string, |
| 120 id2: (!{global: (string|undefined), local: (string|undefined)}|undefined
), | 120 id2: (!{global: (string|undefined), local: (string|undefined)}|undefined
), |
| 121 scope: string, | 121 scope: string, |
| 122 bind_id: string, | 122 bind_id: string, |
| 123 s: string | 123 s: string |
| 124 }} | 124 }} |
| 125 */ | 125 */ |
| 126 WebInspector.TracingManager.EventPayload; | 126 SDK.TracingManager.EventPayload; |
| 127 | 127 |
| 128 WebInspector.TracingManager.TransferMode = { | 128 SDK.TracingManager.TransferMode = { |
| 129 ReportEvents: 'ReportEvents', | 129 ReportEvents: 'ReportEvents', |
| 130 ReturnAsStream: 'ReturnAsStream' | 130 ReturnAsStream: 'ReturnAsStream' |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 /** | 133 /** |
| 134 * @implements {Protocol.TracingDispatcher} | 134 * @implements {Protocol.TracingDispatcher} |
| 135 * @unrestricted | 135 * @unrestricted |
| 136 */ | 136 */ |
| 137 WebInspector.TracingDispatcher = class { | 137 SDK.TracingDispatcher = class { |
| 138 /** | 138 /** |
| 139 * @param {!WebInspector.TracingManager} tracingManager | 139 * @param {!SDK.TracingManager} tracingManager |
| 140 */ | 140 */ |
| 141 constructor(tracingManager) { | 141 constructor(tracingManager) { |
| 142 this._tracingManager = tracingManager; | 142 this._tracingManager = tracingManager; |
| 143 } | 143 } |
| 144 | 144 |
| 145 /** | 145 /** |
| 146 * @override | 146 * @override |
| 147 * @param {number=} usage | 147 * @param {number=} usage |
| 148 * @param {number=} eventCount | 148 * @param {number=} eventCount |
| 149 * @param {number=} percentFull | 149 * @param {number=} percentFull |
| 150 */ | 150 */ |
| 151 bufferUsage(usage, eventCount, percentFull) { | 151 bufferUsage(usage, eventCount, percentFull) { |
| 152 this._tracingManager._bufferUsage(usage, eventCount, percentFull); | 152 this._tracingManager._bufferUsage(usage, eventCount, percentFull); |
| 153 } | 153 } |
| 154 | 154 |
| 155 /** | 155 /** |
| 156 * @override | 156 * @override |
| 157 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} data | 157 * @param {!Array.<!SDK.TracingManager.EventPayload>} data |
| 158 */ | 158 */ |
| 159 dataCollected(data) { | 159 dataCollected(data) { |
| 160 this._tracingManager._eventsCollected(data); | 160 this._tracingManager._eventsCollected(data); |
| 161 } | 161 } |
| 162 | 162 |
| 163 /** | 163 /** |
| 164 * @override | 164 * @override |
| 165 */ | 165 */ |
| 166 tracingComplete() { | 166 tracingComplete() { |
| 167 this._tracingManager._tracingComplete(); | 167 this._tracingManager._tracingComplete(); |
| 168 } | 168 } |
| 169 }; | 169 }; |
| OLD | NEW |