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

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

Issue 2556353004: Mojo JS bindings: code generator maps interface ptr and request to InterfacePtr and InterfaceReques… (Closed)
Patch Set: . Created 4 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
Index: mojo/public/js/bindings.js
diff --git a/mojo/public/js/bindings.js b/mojo/public/js/bindings.js
index 6032dea1e09dddcdab870c315a89d57c3a675042..4ae2311663dcfd42320df3be0589957712c20416 100644
--- a/mojo/public/js/bindings.js
+++ b/mojo/public/js/bindings.js
@@ -5,35 +5,15 @@
define("mojo/public/js/bindings", [
"mojo/public/js/connection",
"mojo/public/js/core",
-], function(connection, core) {
-
- // ---------------------------------------------------------------------------
-
- function InterfacePtrInfo(handle, version) {
- this.handle = handle;
- this.version = version;
- }
-
- InterfacePtrInfo.prototype.isValid = function() {
- return core.isHandle(this.handle);
- };
-
- // ---------------------------------------------------------------------------
-
- function InterfaceRequest(handle) {
- this.handle = handle;
- }
-
- InterfaceRequest.prototype.isValid = function() {
- return core.isHandle(this.handle);
- };
+ "mojo/public/js/interface_types",
+], function(connection, core, types) {
// ---------------------------------------------------------------------------
function makeRequest(interfacePtr) {
var pipe = core.createMessagePipe();
- interfacePtr.ptr.bind(new InterfacePtrInfo(pipe.handle0, 0));
- return new InterfaceRequest(pipe.handle1);
+ interfacePtr.ptr.bind(new types.InterfacePtrInfo(pipe.handle0, 0));
+ return new types.InterfaceRequest(pipe.handle1);
}
// ---------------------------------------------------------------------------
@@ -87,12 +67,12 @@ define("mojo/public/js/bindings", [
InterfacePtrController.prototype.passInterface = function() {
var result;
if (this.connection_) {
- result = new InterfacePtrInfo(
+ result = new types.InterfacePtrInfo(
this.connection_.router_.connector_.handle_, this.version);
this.connection_.router_.connector_.handle_ = null;
} else {
// This also handles the case when this object is not bound.
- result = new InterfacePtrInfo(this.handle_, this.version);
+ result = new types.InterfacePtrInfo(this.handle_, this.version);
this.handle_ = null;
}
@@ -148,6 +128,13 @@ define("mojo/public/js/bindings", [
return this.stub_ !== null;
};
+ Binding.prototype.createInterfacePtrAndBind = function() {
+ var ptr = new this.interfaceType_.ptrClass();
+ // TODO(yzshen): Set the version of the interface pointer.
+ this.bind(makeRequest(ptr));
+ return ptr;
+ }
+
Binding.prototype.bind = function(request) {
this.close();
if (request.isValid()) {
@@ -174,9 +161,9 @@ define("mojo/public/js/bindings", [
Binding.prototype.unbind = function() {
if (!this.isBound())
- return new InterfaceRequest(null);
+ return new types.InterfaceRequest(null);
- var result = new InterfaceRequest(
+ var result = new types.InterfaceRequest(
connection.StubBindings(this.stub_).connection.router_.connector_
.handle_);
connection.StubBindings(this.stub_).connection.router_.connector_.handle_ =
@@ -186,8 +173,8 @@ define("mojo/public/js/bindings", [
};
var exports = {};
- exports.InterfacePtrInfo = InterfacePtrInfo;
- exports.InterfaceRequest = InterfaceRequest;
+ exports.InterfacePtrInfo = types.InterfacePtrInfo;
+ exports.InterfaceRequest = types.InterfaceRequest;
exports.makeRequest = makeRequest;
exports.InterfacePtrController = InterfacePtrController;
exports.Binding = Binding;

Powered by Google App Engine
This is Rietveld 408576698