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

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

Issue 2676443005: Add interface versioning. Methods queryVersion and requireVersion. (Closed)
Patch Set: 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
Index: mojo/public/js/bindings.js
diff --git a/mojo/public/js/bindings.js b/mojo/public/js/bindings.js
index 06075b513f1867f9fc8b4e612738b64a4ef0fda1..c7d9d4f5b5e175925dc4e8e5e6fedb9e756a9a48 100644
--- a/mojo/public/js/bindings.js
+++ b/mojo/public/js/bindings.js
@@ -6,7 +6,8 @@ define("mojo/public/js/bindings", [
"mojo/public/js/core",
"mojo/public/js/interface_types",
"mojo/public/js/router",
-], function(core, types, router) {
+ "mojo/public/js/lib/control_message_proxy",
+], function(core, types, router, controlMessageProxy) {
// ---------------------------------------------------------------------------
@@ -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_ = new controlMessageProxy.ControlMessageProxy();
if (ptrInfoOrHandle)
this.bind(ptrInfoOrHandle);
@@ -110,13 +112,28 @@ define("mojo/public/js/bindings", [
this.router_ = new router.Router(this.handle_);
this.handle_ = null;
this.router_ .setPayloadValidators([this.interfaceType_.validateResponse]);
+ this.controlMessageProxy_.receiver = 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() {
+ this.configureProxyIfNecessary_();
+ return this.controlMessageProxy_.queryVersion().then(function(version) {
+ this.version = version;
+ return version;
+ });
+ };
+
+ InterfacePtrController.prototype.requireVersion = function(version) {
+ this.configureProxyIfNecessary_();
+
+ if (this.version >= version) {
+ return;
+ }
+ this.version = version;
+ this.controlMessageProxy_.requireVersion(version);
+ };
// ---------------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698