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

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

Issue 5228004: Switch the about:gpu implementation from an about handler to dom_ui.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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
Property Changes:
Added: svn:eol-style
+ LF
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
5 cr.define('gpu', function() {
6 /**
7 * This class provides a 'bridge' for communicating between javascript and
8 * the browser.
9 * @constructor
10 */
11 function BrowserBridge() {
12 // If we are not running inside DOMUI, output chrome.send messages
13 // to the console to help with quick-iteration debugging.
14 if (chrome.send === undefined && console.log) {
15 chrome.send = function(messageHandler, args) {
16 console.log('chrome.send', messageHandler, args);
17 };
18 }
19
20 this.nextRequestId_ = 0;
21 this.pendingCallbacks_ = [];
22 }
23
24 BrowserBridge.prototype = {
25 __proto__: Object.prototype,
26
27 /**
28 * Sends a message to the browser with specified args. The
29 * browser will reply asynchronously via the provided callback.
30 */
31 callAsync: function(submessage, args, callback) {
32 var requestId = this.nextRequestId_;
33 this.nextRequestId_ += 1;
34 this.pendingCallbacks_[requestId] = callback;
35 if (!args) {
36 chrome.send('callAsync', [requestId.toString(), submessage]);
37 } else {
38 var allArgs = [requestId.toString(), submessage].concat(args);
39 chrome.send('callAsync', allArgs);
40 }
41 },
42
43 /**
44 * Called by gpu c++ code when client info is ready.
45 */
46 onCallAsyncReply: function(requestId, args) {
47 if (this.pendingCallbacks_[requestId] === undefined) {
48 throw new Error('requestId ' + requestId + ' is not pending');
49 }
50 var callback = this.pendingCallbacks_[requestId];
51 callback(args);
52 delete this.pendingCallbacks_[requestId];
53 }
54 };
55
56 return {
57 BrowserBridge : BrowserBridge
58 };
59 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/gpu_internals.html ('k') | chrome/browser/resources/gpu_internals/info_view.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698