|
OLD | NEW |
---|---|
(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 | |
5 /** | |
6 * This view displays options for importing/exporting the captured data. Its | |
7 * primarily usefulness is to allow users to copy-paste their data in an easy | |
8 * to read format for bug reports. | |
9 * | |
10 * - Has a button to generate a text report. | |
11 * | |
12 * - Shows how many events have been captured. | |
13 * @constructor | |
arv (Not doing code reviews)
2010/12/06 19:45:57
remove @constructor here
nduca
2010/12/07 01:03:40
Done.
| |
14 */ | |
15 cr.define('gpu', function() { | |
16 /** | |
17 * Provides information on the GPU process and underlying graphics hardware. | |
18 * @constructor | |
19 */ | |
20 function InfoView(mainBoxId) { | |
21 DivView.call(this, mainBoxId); | |
22 | |
23 this.textDiv_ = document.getElementById('info-text'); | |
24 this.gpuInfo_ = undefined; | |
25 this.clientInfo_ = undefined; | |
26 | |
27 var self = this; | |
28 | |
29 // This function begins a request for the ClientInfo. If it comes back | |
30 // as undefined, then we will issue the request again in 250ms. | |
31 function beginRequestClientInfo() { | |
arv (Not doing code reviews)
2010/12/06 19:45:57
Move out of constructor and call with self as argu
nduca
2010/12/07 01:03:40
Done.
| |
32 browser.callAsync('requestClientInfo', undefined, function(data) { | |
33 self.clientInfo_ = data; | |
34 self.refresh(); | |
35 if(data === undefined) { // try again in 250 ms | |
36 window.setTimeout(beginRequestClientInfo, 250); | |
37 } | |
38 }); | |
39 } | |
40 beginRequestClientInfo(); | |
41 | |
42 // This function begins a request for the GpuInfo. If it comes back | |
43 // as undefined, then we will issue the request again in 250ms. | |
44 function beginRequestGpuInfo() { | |
arv (Not doing code reviews)
2010/12/06 19:45:57
same here
nduca
2010/12/07 01:03:40
Done.
| |
45 browser.callAsync('requestGpuInfo', undefined, function(data) { | |
46 self.gpuInfo_ = data; | |
47 self.refresh(); | |
48 if(data === undefined) { // try again in 250 ms | |
49 window.setTimeout(beginRequestGpuInfo, 250); | |
50 } | |
51 }); | |
52 } | |
53 beginRequestGpuInfo(); | |
54 this.refresh(); | |
55 } | |
56 | |
57 InfoView.prototype = { | |
58 __proto__: DivView, | |
59 | |
60 /** | |
61 * Updates the view based on its currently known data | |
62 */ | |
63 refresh: function(data) { | |
64 var html = []; | |
arv (Not doing code reviews)
2010/12/06 19:45:57
This thing might have been a lot cleaner using js
nduca
2010/12/07 01:03:40
I'll go take a peek at this and see if I can switc
| |
65 function outputObject(obj) { | |
arv (Not doing code reviews)
2010/12/06 19:45:57
Move out of refresh. I don't think there is any po
nduca
2010/12/07 01:03:40
Done.
nduca
2010/12/07 01:03:40
Done.
| |
66 var all_values = true; | |
arv (Not doing code reviews)
2010/12/06 19:45:57
no underscores
nduca
2010/12/07 01:03:40
Done.
| |
67 for (var k in obj) { // output values | |
68 var v = obj[k]; | |
69 if(!(typeof(v) === 'number' || typeof(v) === "string")) { | |
arv (Not doing code reviews)
2010/12/06 19:45:57
whitespace after if
arv (Not doing code reviews)
2010/12/06 19:45:57
typeof is not a function, it is an unary operator
arv (Not doing code reviews)
2010/12/06 19:45:57
Use single quotes
nduca
2010/12/07 01:03:40
Done.
| |
70 all_values = false; | |
71 } | |
72 } | |
73 if (all_values) | |
74 html.push("<table class='border'>"); | |
75 else | |
76 html.push("<table>"); | |
77 for (var k in obj) { // output values | |
arv (Not doing code reviews)
2010/12/06 19:45:57
2 spaces before //
| |
78 var v = obj[k]; | |
79 if (typeof(v) === 'number' || typeof(v) === "string") { | |
80 html.push("<tr><td><strong>"); | |
arv (Not doing code reviews)
2010/12/06 19:45:57
Remove strong and use a class name + css
arv (Not doing code reviews)
2010/12/06 19:45:57
push takes var args.
html.push('<tr><td>', k, ...
nduca
2010/12/07 01:03:40
Going to skip the css-ization until I can look at
| |
81 html.push(k); | |
82 html.push("</strong></td><td>"); | |
83 html.push(v); | |
84 html.push("</td></tr>"); | |
85 } else { | |
86 html.push("<tr><td colspan=2><strong>" + k + ":</strong>"); | |
87 html.push("<div style=\"padding-left: 8px;\">"); | |
arv (Not doing code reviews)
2010/12/06 19:45:57
-webkit-padding-start and move to css
nduca
2010/12/07 01:03:40
Done.
| |
88 outputObject(v); | |
89 html.push("</div>"); | |
90 html.push("</td></tr>"); | |
91 } | |
92 } | |
93 html.push("</table>"); | |
94 } | |
95 | |
96 html.push('<h2>Chrome information</h2>'); | |
97 if (this.clientInfo_) { | |
98 var chromeVersion = this.clientInfo_.version + | |
99 ' (' + this.clientInfo_.official + | |
100 ' ' + this.clientInfo_.cl + | |
101 ') ' + this.clientInfo_.version_mod + "</p>"; | |
102 var data = {'Data exported on' : (new Date()).toLocaleString(), | |
arv (Not doing code reviews)
2010/12/06 19:45:57
no ws before :
nduca
2010/12/07 01:03:40
Done.
| |
103 'Chrome version: ' : chromeVersion}; | |
104 outputObject(data); | |
105 } else { | |
106 html.push('... refreshing data ...'); | |
107 } | |
108 | |
109 html.push('<h2>GPU information</h2>'); | |
110 if (this.gpuInfo_) { | |
111 outputObject(this.gpuInfo_); | |
112 } else { | |
113 html.push('... refreshing data ...'); | |
114 } | |
115 | |
116 // Open a new window to display this text. | |
117 this.textDiv_.innerHTML = html.join("\n"); | |
arv (Not doing code reviews)
2010/12/06 19:45:57
XSS? You are not escaping all your text and some o
nduca
2010/12/07 01:03:40
Hopefully I can get out of this trap with jst.
On
| |
118 } | |
119 }; | |
120 | |
121 return { | |
122 InfoView: InfoView | |
123 }; | |
124 }); | |
OLD | NEW |