OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 /** | 6 /** |
7 * @fileoverview State and UI for trace data collection. | 7 * @fileoverview State and UI for trace data collection. |
8 */ | 8 */ |
9 cr.define('tracing', function() { | 9 cr.define('tracing', function() { |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 if (browserBridge.debugMode) { | 30 if (browserBridge.debugMode) { |
31 var tracingControllerTests = document.createElement('script'); | 31 var tracingControllerTests = document.createElement('script'); |
32 tracingControllerTests.src = | 32 tracingControllerTests.src = |
33 './tracing/tracing_controller_tests.js'; | 33 './tracing/tracing_controller_tests.js'; |
34 document.body.appendChild(tracingControllerTests); | 34 document.body.appendChild(tracingControllerTests); |
35 } | 35 } |
36 | 36 |
37 this.onKeydownBoundToThis_ = this.onKeydown_.bind(this); | 37 this.onKeydownBoundToThis_ = this.onKeydown_.bind(this); |
38 this.onKeypressBoundToThis_ = this.onKeypress_.bind(this); | 38 this.onKeypressBoundToThis_ = this.onKeypress_.bind(this); |
| 39 |
| 40 chrome.send('tracingControllerInitialized'); |
39 } | 41 } |
40 | 42 |
41 TracingController.prototype = { | 43 TracingController.prototype = { |
42 __proto__: cr.EventTarget.prototype, | 44 __proto__: cr.EventTarget.prototype, |
43 | 45 |
| 46 gpuInfo_: undefined, |
| 47 clientInfo_: undefined, |
44 tracingEnabled_: false, | 48 tracingEnabled_: false, |
45 tracingEnding_: false, | 49 tracingEnding_: false, |
46 | 50 |
47 onRequestBufferPercentFullComplete: function(percent_full) { | 51 onRequestBufferPercentFullComplete: function(percent_full) { |
48 if (!this.overlay_.visible) | 52 if (!this.overlay_.visible) |
49 return; | 53 return; |
50 | 54 |
51 window.setTimeout(this.beginRequestBufferPercentFull_.bind(this), 250); | 55 window.setTimeout(this.beginRequestBufferPercentFull_.bind(this), 250); |
52 | 56 |
53 this.bufferPercentDiv_.textContent = 'Buffer usage: ' + | 57 this.bufferPercentDiv_.textContent = 'Buffer usage: ' + |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (e.keyCode == 27) { | 106 if (e.keyCode == 27) { |
103 this.endTracing(); | 107 this.endTracing(); |
104 } | 108 } |
105 }, | 109 }, |
106 | 110 |
107 onKeypress_: function(e) { | 111 onKeypress_: function(e) { |
108 if (e.keyIdentifier == 'Enter') { | 112 if (e.keyIdentifier == 'Enter') { |
109 this.endTracing(); | 113 this.endTracing(); |
110 } | 114 } |
111 }, | 115 }, |
| 116 |
| 117 /** |
| 118 * Called from gpu c++ code when ClientInfo is updated. |
| 119 */ |
| 120 onClientInfoUpdate: function(clientInfo) { |
| 121 this.clientInfo_ = clientInfo; |
| 122 }, |
| 123 |
| 124 /** |
| 125 * Called from gpu c++ code when GPU Info is updated. |
| 126 */ |
| 127 onGpuInfoUpdate: function(gpuInfo) { |
| 128 this.gpuInfo_ = gpuInfo; |
| 129 }, |
| 130 |
112 /** | 131 /** |
113 * Checks whether tracing is enabled | 132 * Checks whether tracing is enabled |
114 */ | 133 */ |
115 get isTracingEnabled() { | 134 get isTracingEnabled() { |
116 return this.tracingEnabled_; | 135 return this.tracingEnabled_; |
117 }, | 136 }, |
118 | 137 |
119 /** | 138 /** |
120 * Gets the currently traced events. If tracing is active, then | 139 * Gets the currently traced events. If tracing is active, then |
121 * this can change on the fly. | 140 * this can change on the fly. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 onLoadTraceFileCanceled: function() { | 220 onLoadTraceFileCanceled: function() { |
202 cr.dispatchSimpleEvent(this, 'loadTraceFileCanceled'); | 221 cr.dispatchSimpleEvent(this, 'loadTraceFileCanceled'); |
203 }, | 222 }, |
204 | 223 |
205 /** | 224 /** |
206 * Tells browser to put up a save dialog and save the trace file | 225 * Tells browser to put up a save dialog and save the trace file |
207 */ | 226 */ |
208 beginSaveTraceFile: function(traceEvents) { | 227 beginSaveTraceFile: function(traceEvents) { |
209 var data = { | 228 var data = { |
210 traceEvents: traceEvents, | 229 traceEvents: traceEvents, |
211 clientInfo: browserBridge.clientInfo, | 230 clientInfo: this.clientInfo_, |
212 gpuInfo: browserBridge.gpuInfo | 231 gpuInfo: this.gpuInfo_ |
213 }; | 232 }; |
214 chrome.send('saveTraceFile', [JSON.stringify(data)]); | 233 chrome.send('saveTraceFile', [JSON.stringify(data)]); |
215 }, | 234 }, |
216 | 235 |
217 /** | 236 /** |
218 * Called by the browser when a trace file is saveed. | 237 * Called by the browser when a trace file is saveed. |
219 */ | 238 */ |
220 onSaveTraceFileComplete: function() { | 239 onSaveTraceFileComplete: function() { |
221 cr.dispatchSimpleEvent(this, 'saveTraceFileComplete'); | 240 cr.dispatchSimpleEvent(this, 'saveTraceFileComplete'); |
222 }, | 241 }, |
223 | 242 |
224 /** | 243 /** |
225 * Called by the browser when saving a trace file was canceled. | 244 * Called by the browser when saving a trace file was canceled. |
226 */ | 245 */ |
227 onSaveTraceFileCanceled: function() { | 246 onSaveTraceFileCanceled: function() { |
228 cr.dispatchSimpleEvent(this, 'saveTraceFileCanceled'); | 247 cr.dispatchSimpleEvent(this, 'saveTraceFileCanceled'); |
229 }, | 248 }, |
230 | 249 |
231 selfTest: function() { | 250 selfTest: function() { |
232 this.beginTracing(); | 251 this.beginTracing(); |
233 window.setTimeout(this.endTracing.bind(This), 500); | 252 window.setTimeout(this.endTracing.bind(This), 500); |
234 } | 253 } |
235 }; | 254 }; |
236 return { | 255 return { |
237 TracingController: TracingController | 256 TracingController: TracingController |
238 }; | 257 }; |
239 }); | 258 }); |
240 | 259 |
OLD | NEW |