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

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 /**
6 * This class provides a 'bridge' for communicating between javascript and
7 * the browser.
8 *
9 * @constructor
arv (Not doing code reviews) 2010/12/03 22:19:20 Wrong annotation
10 */
11 cr.define('gpu', function() {
12 function convertTimeTicksToDate(timeTicks) {
13 // Note that the subtraction by 0 is to cast to a number (probably a float
14 // since the numbers are big).
15 var timeStampMs = (this.timeTickOffset_ - 0) + (timeTicks - 0);
arv (Not doing code reviews) 2010/12/03 22:19:20 Number(expr) is cleaner
nduca 2010/12/03 22:49:39 Turns out I'm not even using this function anymore
arv (Not doing code reviews) 2010/12/06 19:45:57 Non existing code is the cleanest code ;)
16 var d = new Date();
17 d.setTime(timeStampMs);
18 return d;
19 }
20
21 // If we are not running inside DOMUI, output chrome.send messages
22 // to the console to help with quick-iteration debugging.
23 function BrowserBridge() {
arv (Not doing code reviews) 2010/12/03 22:19:20 This one should have the @constructor
nduca 2010/12/03 22:49:39 Done.
24 if(chrome.send === undefined && console.log) {
25 chrome.send = function(messageHandler,args) {
arv (Not doing code reviews) 2010/12/03 22:19:20 ws after comma
nduca 2010/12/03 22:49:39 Done.
26 if(args) {
27 console.log('chrome.send(' + messageHandler + ', ' +
28 args.toString() + ')');
arv (Not doing code reviews) 2010/12/03 22:19:20 Why not? console.log('chrome.send', messageHandle
nduca 2010/12/03 22:49:39 Done.
29 } else {
30 console.log('chrome.send(' + messageHandler + ')');
31 }
32 };
33 }
34
35 this.nextRequestId_ = 0;
36 this.pendingCallbacks_ = [];
37 }
38
39 BrowserBridge.prototype = {
40 __proto__: Object.prototype,
41
42 /**
43 * Sends a message to the browser with specified args. The
44 * browser will reply asynchronously via the provided callback.
45 */
46 callAsync: function(submessage, args, callback) {
47 var requestId = this.nextRequestId_;
48 this.nextRequestId_ += 1;
49 this.pendingCallbacks_[requestId] = callback;
50 if(args === undefined) {
arv (Not doing code reviews) 2010/12/03 22:19:20 ws
arv (Not doing code reviews) 2010/12/03 22:19:20 if (!args) {
nduca 2010/12/03 22:49:39 Done.
51 chrome.send('callAsync', [requestId.toString(), submessage]);
52 } else {
53 var all_args = [requestId.toString(), submessage].concat(args);
arv (Not doing code reviews) 2010/12/03 22:19:20 no underscores in js
nduca 2010/12/03 22:49:39 Done.
54 chrome.send('callAsync', all_args);
55 }
56 },
57
58 /**
59 * Called by gpu c++ code when client info is ready.
60 */
61 onCallAsyncReply: function(requestId,args) {
62 if(this.pendingCallbacks_[requestId] === undefined) {
arv (Not doing code reviews) 2010/12/03 22:19:20 ws
nduca 2010/12/03 22:49:39 Done.
63 throw new Error('requestId ' + requestId + ' is not pending');
64 }
65 var callback = this.pendingCallbacks_[requestId];
66 callback(args);
67 delete this.pendingCallbacks_[requestId];
68 }
69 };
70
71 return {
72 BrowserBridge : BrowserBridge
73 };
74 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698