Commit 3648b35f authored by mbrunson's avatar mbrunson Committed by Commit bot

Add bindProxy implementation without callback.

The original implementation of bindProxy in Mojo connection requires a callback
in order to receive the proxy for the remote interface. This pattern is
counterintuitive and unnecessary. A new function that doesn't require a
callback has been added here.

Review-Url: https://codereview.chromium.org/2389303002
Cr-Commit-Position: refs/heads/master@{#422992}
parent 879d6c37
...@@ -98,6 +98,25 @@ define("mojo/public/js/connection", [ ...@@ -98,6 +98,25 @@ define("mojo/public/js/connection", [
return messagePipe.handle1; return messagePipe.handle1;
} }
// Return a handle and proxy for a message pipe that's connected to a proxy
// for remoteInterface. Used by generated code for outgoing interface&
// (request) parameters
function getProxy(remoteInterface) {
var messagePipe = core.createMessagePipe();
if (messagePipe.result != core.RESULT_OK)
throw new Error("createMessagePipe failed " + messagePipe.result);
var proxy = new remoteInterface.proxyClass;
var router = new Router(messagePipe.handle0);
var connection = new BaseConnection(undefined, proxy, router);
ProxyBindings(proxy).connection = connection;
return {
requestHandle: messagePipe.handle1,
proxy: proxy
};
}
// Return a handle for a message pipe that's connected to a stub for // Return a handle for a message pipe that's connected to a stub for
// localInterface. Used by generated code for outgoing interface // localInterface. Used by generated code for outgoing interface
// parameters: the caller is given the generated stub via // parameters: the caller is given the generated stub via
...@@ -168,6 +187,7 @@ define("mojo/public/js/connection", [ ...@@ -168,6 +187,7 @@ define("mojo/public/js/connection", [
exports.TestConnection = TestConnection; exports.TestConnection = TestConnection;
exports.bindProxy = bindProxy; exports.bindProxy = bindProxy;
exports.getProxy = getProxy;
exports.bindImpl = bindImpl; exports.bindImpl = bindImpl;
exports.bindHandleToProxy = bindHandleToProxy; exports.bindHandleToProxy = bindHandleToProxy;
exports.bindHandleToStub = bindHandleToStub; exports.bindHandleToStub = bindHandleToStub;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment