Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: chrome/browser/resources/gpu_internals/tracing_controller.js

Issue 6551019: Trace_event upgrades (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More gooder js thanks to arv. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 cr.define('gpu', function() {
arv (Not doing code reviews) 2011/02/25 00:51:29 Can you add an empty line before this?
5 function TracingController() {
6 this.overlay_ = $('gpu-tracing-overlay-template').cloneNode(true);
7 this.overlay_.removeAttribute('id');
arv (Not doing code reviews) 2011/02/25 00:51:29 Prefer DOM properties where possible this.overlay
8 cr.ui.decorate(this.overlay_, gpu.Overlay);
9
10 this.traceEvents_ = [];
11
12 var startButton = $('gpu-tracing-start-button-template').cloneNode(true);
13 startButton.removeAttribute('id');
14 document.body.appendChild(startButton);
15 startButton.onclick = this.beginTracing.bind(this);
16
17 var stopButton = this.overlay_.querySelector('.gpu-tracing-stop-button');
18 stopButton.onclick = this.endTracing.bind(this);
19 }
20
21 TracingController.prototype = {
22 __proto__: cr.EventTarget.prototype,
23
24 tracingEnabled_ : false,
25
26 /**
27 * Called by info_view to empty the trace buffer
28 */
29 beginTracing: function() {
30 if (this.tracingEnabled_)
31 throw Error('Tracing already begun.');
32
33 this.overlay_.visible = true;
34
35 this.tracingEnabled_ = true;
36 console.log('Beginning to trace...');
37
38 this.traceEvents_ = [];
39 if (!browserBridge.debugMode)
40 chrome.send('beginTracing');
41
42 this.tracingEnabled_ = true;
43
44 var e = new cr.Event('traceBegun');
45 e.events = this.traceEvents_;
46 this.dispatchEvent(e);
47
48 e = new cr.Event('traceEventsChanged');
49 e.numEvents = this.traceEvents_.length;
50 this.dispatchEvent(e);
51
52 var self;
53 window.addEventListener('keypress', function f(e) {
54 if(e.keyIdentifier == 'Enter') {
arv (Not doing code reviews) 2011/02/25 00:51:29 ws
55 window.removeEventListener('keypress', f);
56 self.endTracing();
57 }
58 });
59 },
60
61 /**
62 * Checks whether tracing is enabled
63 */
64 get isTracingEnabled() {
65 return this.tracingEnabled_;
66 },
67
68 /**
69 * Gets the currently traced events. If tracing is active, then
70 * this can change on the fly.
71 */
72 get traceEvents() {
73 return this.traceEvents_;
74 },
75
76 /**
77 * Callbed by gpu c++ code when new GPU trace data arrives.
78 */
79 onTraceDataCollected: function(events) {
80 this.traceEvents_.push.apply(this.traceEvents_, events);
81 },
82
83 /**
84 * Called by info_view to finish tracing and update all views.
85 */
86 endTracing: function() {
87 if (!this.tracingEnabled_) throw new Error('Tracing not begun.');
88
89 console.log('Finishing trace');
90 if (!browserBridge.debugMode) {
91 chrome.send('beginToEndTracing');
92 } else {
93 var events;
94 if(window.getTimelineTestData1){
arv (Not doing code reviews) 2011/02/25 00:51:29 ws
arv (Not doing code reviews) 2011/02/25 00:51:29 or events = window.getTimelineTestData1 ? getTime
95 events = getTimelineTestData1();
96 } else {
97 events = [];
98 }
99 this.onTraceDataCollected(events);
100 window.setTimeout(this.onEndTracingComplete.bind(this), 250);
101 }
102 },
103 /* Called by the browser when all processes ack tracing having completed. */
arv (Not doing code reviews) 2011/02/25 00:51:29 Use JSDoc
104 onEndTracingComplete: function() {
105 this.overlay_.visible = false;
106 this.tracingEnabled_ = false;
107 console.log('onEndTracingComplete p1 with ' +
108 this.traceEvents_.length + ' events.');
109 var e = new cr.Event('traceEnded');
110 e.events = this.traceEvents_;
111 this.dispatchEvent(e);
112 },
113
114 selfTest: function() {
115 this.beginTracing();
116 window.setTimeout(this.endTracing.bind(This), 500);
117 }
118 };
119 return {
120 TracingController : TracingController
121 };
122 });
123
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698