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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/gpu_internals/browser_bridge.js
===================================================================
--- chrome/browser/resources/gpu_internals/browser_bridge.js (revision 0)
+++ chrome/browser/resources/gpu_internals/browser_bridge.js (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('gpu', function() {
+ /**
+ * This class provides a 'bridge' for communicating between javascript and
+ * the browser.
+ * @constructor
+ */
+ function BrowserBridge() {
+ // If we are not running inside DOMUI, output chrome.send messages
+ // to the console to help with quick-iteration debugging.
+ if (chrome.send === undefined && console.log) {
+ chrome.send = function(messageHandler, args) {
+ console.log('chrome.send', messageHandler, args);
+ };
+ }
+
+ this.nextRequestId_ = 0;
+ this.pendingCallbacks_ = [];
+ }
+
+ BrowserBridge.prototype = {
+ __proto__: Object.prototype,
+
+ /**
+ * Sends a message to the browser with specified args. The
+ * browser will reply asynchronously via the provided callback.
+ */
+ callAsync: function(submessage, args, callback) {
+ var requestId = this.nextRequestId_;
+ this.nextRequestId_ += 1;
+ this.pendingCallbacks_[requestId] = callback;
+ if (!args) {
+ chrome.send('callAsync', [requestId.toString(), submessage]);
+ } else {
+ var allArgs = [requestId.toString(), submessage].concat(args);
+ chrome.send('callAsync', allArgs);
+ }
+ },
+
+ /**
+ * Called by gpu c++ code when client info is ready.
+ */
+ onCallAsyncReply: function(requestId, args) {
+ if (this.pendingCallbacks_[requestId] === undefined) {
+ throw new Error('requestId ' + requestId + ' is not pending');
+ }
+ var callback = this.pendingCallbacks_[requestId];
+ callback(args);
+ delete this.pendingCallbacks_[requestId];
+ }
+ };
+
+ return {
+ BrowserBridge : BrowserBridge
+ };
+});
Property changes on: chrome/browser/resources/gpu_internals/browser_bridge.js
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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