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

Unified Diff: mojo/public/js/bindings.js

Issue 2676443005: Add interface versioning. Methods queryVersion and requireVersion. (Closed)
Patch Set: Expect the result inside the error handler for test. Code formatting and address codereview comment… Created 3 years, 10 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 | « mojo/public/js/BUILD.gn ('k') | mojo/public/js/constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/js/bindings.js
diff --git a/mojo/public/js/bindings.js b/mojo/public/js/bindings.js
index 06075b513f1867f9fc8b4e612738b64a4ef0fda1..f3e40d293ebb025f4bf3c8a3c4e01c81626b5aa4 100644
--- a/mojo/public/js/bindings.js
+++ b/mojo/public/js/bindings.js
@@ -4,9 +4,10 @@
define("mojo/public/js/bindings", [
"mojo/public/js/core",
+ "mojo/public/js/lib/control_message_proxy",
"mojo/public/js/interface_types",
"mojo/public/js/router",
-], function(core, types, router) {
+], function(core, controlMessageProxy, types, router) {
// ---------------------------------------------------------------------------
@@ -31,6 +32,7 @@ define("mojo/public/js/bindings", [
// |router_| is lazily initialized. |handle_| is valid between bind() and
// the initialization of |router_|.
this.handle_ = null;
+ this.controlMessageProxy_ = null;
if (ptrInfoOrHandle)
this.bind(ptrInfoOrHandle);
@@ -111,12 +113,32 @@ define("mojo/public/js/bindings", [
this.handle_ = null;
this.router_ .setPayloadValidators([this.interfaceType_.validateResponse]);
+ this.controlMessageProxy_ = new
+ controlMessageProxy.ControlMessageProxy(this.router_);
+
this.proxy_ = new this.interfaceType_.proxyClass(this.router_);
};
- // TODO(yzshen): Implement the following methods.
- // InterfacePtrController.prototype.queryVersion
- // InterfacePtrController.prototype.requireVersion
+ InterfacePtrController.prototype.queryVersion = function() {
+ function onQueryVersion(version) {
+ this.version = version;
+ return version;
+ }
+
+ this.configureProxyIfNecessary_();
+ return this.controlMessageProxy_.queryVersion().then(
+ onQueryVersion.bind(this));
+ };
+
+ InterfacePtrController.prototype.requireVersion = function(version) {
+ this.configureProxyIfNecessary_();
+
+ if (this.version >= version) {
+ return;
+ }
+ this.version = version;
+ this.controlMessageProxy_.requireVersion(version);
+ };
// ---------------------------------------------------------------------------
@@ -163,7 +185,7 @@ define("mojo/public/js/bindings", [
return;
this.stub_ = new this.interfaceType_.stubClass(this.impl_);
- this.router_ = new router.Router(handle);
+ this.router_ = new router.Router(handle, this.interfaceType_.kVersion);
this.router_.setIncomingReceiver(this.stub_);
this.router_ .setPayloadValidators([this.interfaceType_.validateRequest]);
};
« no previous file with comments | « mojo/public/js/BUILD.gn ('k') | mojo/public/js/constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698