| 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 cr.define('gpu', function() { | 4 cr.define('gpu', function() { |
| 5 /** | 5 /** |
| 6 * This class provides a 'bridge' for communicating between javascript and the | 6 * This class provides a 'bridge' for communicating between javascript and the |
| 7 * browser. When run outside of WebUI, e.g. as a regular webpage, it provides | 7 * browser. When run outside of WebUI, e.g. as a regular webpage, it provides |
| 8 * synthetic data to assist in testing. | 8 * synthetic data to assist in testing. |
| 9 * @constructor | 9 * @constructor |
| 10 */ | 10 */ |
| 11 function BrowserBridge() { | 11 function BrowserBridge() { |
| 12 // If we are not running inside WebUI, output chrome.send messages | 12 // If we are not running inside WebUI, output chrome.send messages |
| 13 // to the console to help with quick-iteration debugging. | 13 // to the console to help with quick-iteration debugging. |
| 14 if (chrome.send === undefined && console.log) { | 14 this.debugMode_ = (chrome.send === undefined && console.log); |
| 15 this.debugMode_ = true; | 15 if (this.debugMode_) { |
| 16 var browserBridgeTests = document.createElement('script'); | 16 var browserBridgeTests = document.createElement('script'); |
| 17 browserBridgeTests.src = './gpu_internals/browser_bridge_tests.js'; | 17 browserBridgeTests.src = './gpu_internals/browser_bridge_tests.js'; |
| 18 document.body.appendChild(browserBridgeTests); | 18 document.body.appendChild(browserBridgeTests); |
| 19 } else { | |
| 20 this.debugMode_ = false; | |
| 21 } | 19 } |
| 22 | 20 |
| 23 this.nextRequestId_ = 0; | 21 this.nextRequestId_ = 0; |
| 24 this.pendingCallbacks_ = []; | 22 this.pendingCallbacks_ = []; |
| 25 this.logMessages_ = []; | 23 this.logMessages_ = []; |
| 26 | 24 |
| 27 // Tell c++ code that we are ready to receive GPU Info. | 25 // Tell c++ code that we are ready to receive GPU Info. |
| 28 if (!this.debugMode_) { | 26 if (!this.debugMode_) { |
| 29 chrome.send('browserBridgeInitialized'); | 27 chrome.send('browserBridgeInitialized'); |
| 30 this.beginRequestClientInfo_(); | 28 this.beginRequestClientInfo_(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 get logMessages() { | 138 get logMessages() { |
| 141 return this.logMessages_; | 139 return this.logMessages_; |
| 142 } | 140 } |
| 143 | 141 |
| 144 }; | 142 }; |
| 145 | 143 |
| 146 return { | 144 return { |
| 147 BrowserBridge: BrowserBridge | 145 BrowserBridge: BrowserBridge |
| 148 }; | 146 }; |
| 149 }); | 147 }); |
| OLD | NEW |