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 */ |
| 14 cr.define('gpu', function() { |
| 15 /** |
| 16 * Provides information on the GPU process and underlying graphics hardware. |
| 17 * @constructor |
| 18 */ |
| 19 function InfoView(mainBoxId) { |
| 20 DivView.call(this, mainBoxId); |
| 21 |
| 22 this.beginRequestClientInfo(); |
| 23 this.beginRequestGpuInfo(); |
| 24 this.refresh(); |
| 25 } |
| 26 |
| 27 InfoView.prototype = { |
| 28 __proto__: DivView.prototype, |
| 29 |
| 30 /** |
| 31 * This function begins a request for the ClientInfo. If it comes back |
| 32 * as undefined, then we will issue the request again in 250ms. |
| 33 */ |
| 34 beginRequestClientInfo : function() { |
| 35 browserBridge.callAsync('requestClientInfo', undefined, (function(data) { |
| 36 this.clientInfo_ = data; |
| 37 this.refresh(); |
| 38 if (data === undefined) { // try again in 250 ms |
| 39 window.setTimeout(this.beginRequestClientInfo.bind(this), 250); |
| 40 } |
| 41 }).bind(this)); |
| 42 }, |
| 43 |
| 44 /** |
| 45 * This function begins a request for the GpuInfo. If it comes back |
| 46 * as undefined, then we will issue the request again in 250ms. |
| 47 */ |
| 48 beginRequestGpuInfo : function() { |
| 49 browserBridge.callAsync('requestGpuInfo', undefined, (function(data) { |
| 50 this.gpuInfo_ = data; |
| 51 this.refresh(); |
| 52 if (!data || data.progress != 'complete') { // try again in 250 ms |
| 53 window.setTimeout(this.beginRequestGpuInfo.bind(this), 250); |
| 54 } |
| 55 }).bind(this)); |
| 56 }, |
| 57 |
| 58 /** |
| 59 * Updates the view based on its currently known data |
| 60 */ |
| 61 refresh: function(data) { |
| 62 // Client info |
| 63 if (this.clientInfo_) { |
| 64 var chromeVersion = this.clientInfo_.version + |
| 65 ' (' + this.clientInfo_.official + |
| 66 ' ' + this.clientInfo_.cl + |
| 67 ') ' + this.clientInfo_.version_mod; |
| 68 this.setTable_('client-info', [ |
| 69 { |
| 70 description: 'Data exported', |
| 71 value: (new Date()).toLocaleString() |
| 72 }, |
| 73 { |
| 74 description: 'Chrome version', |
| 75 value: chromeVersion |
| 76 }]); |
| 77 } else { |
| 78 this.setText_('client-info', '... loading...'); |
| 79 } |
| 80 |
| 81 // GPU info, basic |
| 82 if (this.gpuInfo_) { |
| 83 this.setTable_('basic-info', this.gpuInfo_.basic_info); |
| 84 if (this.gpuInfo_.diagnostics) { |
| 85 this.setTable_('diagnostics', this.gpuInfo_.diagnostics); |
| 86 } else if (this.gpuInfo_.progress == 'partial') { |
| 87 this.setText_('diagnostics', '... loading...'); |
| 88 } else { |
| 89 this.setText_('diagnostics', 'None'); |
| 90 } |
| 91 } else { |
| 92 this.setText_('basic-info', '... loading ...'); |
| 93 this.setText_('diagnostics', '... loading ...'); |
| 94 } |
| 95 }, |
| 96 |
| 97 setText_: function(outputElementId, text) { |
| 98 var peg = document.getElementById(outputElementId); |
| 99 peg.innerText = text; |
| 100 }, |
| 101 |
| 102 setTable_: function(outputElementId, inputData) { |
| 103 var template = jstGetTemplate('info-view-table-template'); |
| 104 jstProcess(new JsEvalContext({value: inputData}), |
| 105 template); |
| 106 |
| 107 var peg = document.getElementById(outputElementId); |
| 108 if (!peg) |
| 109 throw new Error('Node ' + outputElementId + ' not found'); |
| 110 |
| 111 peg.innerHTML = ''; |
| 112 peg.appendChild(template); |
| 113 } |
| 114 }; |
| 115 |
| 116 return { |
| 117 InfoView: InfoView |
| 118 }; |
| 119 }); |
OLD | NEW |