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

Unified Diff: chrome/browser/resources/plugins.js

Issue 2020463002: Mojo JS: Attempt to simplify bindTo* related code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More refinements. Created 4 years, 7 months 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 | « no previous file | mojo/public/js/connection.js » ('j') | mojo/public/js/connection.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/plugins.js
diff --git a/chrome/browser/resources/plugins.js b/chrome/browser/resources/plugins.js
index 19b21195729468df0efb39fc1a3728846e35bae2..b7402206017fef8a9b3861a3332c49e9adb203a3 100644
--- a/chrome/browser/resources/plugins.js
+++ b/chrome/browser/resources/plugins.js
@@ -263,48 +263,45 @@ function importModules(moduleNames) {
});
}
-// NOTE: Need to keep a reference to the stub here such that it is not garbage
-// collected, which causes the pipe to close and future calls from C++ to JS to
-// get dropped.
-var pluginsPageStub = null;
-
-var browserProxy = null;
-// Exposed globally such that the tests can make direct calls on it.
+// NOTE: Need to keep a global reference to the |pageProxy| such that it is not
+// garbage collected, which causes the pipe to close and future calls from C++
+// to JS to get dropped. This also allows tests to make direct calls on it.
var pageProxy = null;
+var browserProxy = null;
function initializeProxies() {
return importModules([
'mojo/public/js/bindings',
- 'mojo/public/js/core',
'mojo/public/js/connection',
'chrome/browser/ui/webui/plugins/plugins.mojom',
'content/public/renderer/frame_service_registry',
]).then(function(modules) {
var bindings = modules[0];
- var core = modules[1];
- var connection = modules[2];
- var pluginsMojom = modules[3];
- var serviceProvider = modules[4];
+ var connection = modules[1];
+ var pluginsMojom = modules[2];
+ var serviceProvider = modules[3];
browserProxy = connection.bindHandleToProxy(
serviceProvider.connectToService(pluginsMojom.PluginsPageHandler.name),
pluginsMojom.PluginsPageHandler);
- // Connect pipe handle to JS code.
- var pipe = core.createMessagePipe();
- pluginsPageStub = connection.bindHandleToStub(
- pipe.handle0, pluginsMojom.PluginsPage);
+ /** @constructor */
+ var PluginsPageProxy = function() {};
- pageProxy = {
+ PluginsPageProxy.prototype = {
__proto__: pluginsMojom.PluginsPage.stubClass.prototype,
+
+ /** @override */
onPluginsUpdated: function(plugins) {
returnPluginsData({plugins: plugins});
},
};
+ pageProxy = new PluginsPageProxy();
- bindings.StubBindings(pluginsPageStub).delegate = pageProxy;
- // Send pipe handle to C++.
- browserProxy.setClientPage(pipe.handle1);
+ // Create a message pipe, with one end of the pipe already connected to JS.
+ var handle = connection.createHandleForImpl(pageProxy);
+ // Send the other end of the pipe to C++.
+ browserProxy.setClientPage(handle);
});
}
« no previous file with comments | « no previous file | mojo/public/js/connection.js » ('j') | mojo/public/js/connection.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698