OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 define("mojo/public/js/connection", [ | 5 define("mojo/public/js/connection", [ |
6 "mojo/public/js/bindings", | 6 "mojo/public/js/bindings", |
7 "mojo/public/js/connector", | 7 "mojo/public/js/connector", |
8 "mojo/public/js/core", | 8 "mojo/public/js/core", |
9 "mojo/public/js/router", | 9 "mojo/public/js/router", |
10 ], function(bindings, connector, core, router) { | 10 ], function(bindings, connector, core, router) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 var proxy = new remoteInterface.proxyClass; | 91 var proxy = new remoteInterface.proxyClass; |
92 var router = new Router(messagePipe.handle0); | 92 var router = new Router(messagePipe.handle0); |
93 var connection = new BaseConnection(undefined, proxy, router); | 93 var connection = new BaseConnection(undefined, proxy, router); |
94 ProxyBindings(proxy).connection = connection; | 94 ProxyBindings(proxy).connection = connection; |
95 if (proxyCallback) | 95 if (proxyCallback) |
96 proxyCallback(proxy); | 96 proxyCallback(proxy); |
97 | 97 |
98 return messagePipe.handle1; | 98 return messagePipe.handle1; |
99 } | 99 } |
100 | 100 |
101 // Return a handle and a proxy for a message pipe that's connected to a proxy | |
102 // for |remoteInterface|. Used by generated code for outgoing interface& | |
103 // (request) parameters. | |
104 function bindProxy2(remoteInterface) { | |
scheib
2016/09/23 20:53:52
Let's separate out this change to be stand-alone.
| |
105 var messagePipe = core.createMessagePipe(); | |
106 if (messagePipe.result != core.RESULT_OK) | |
107 throw new Error("createMessagePipe failed " + messagePipe.result); | |
108 | |
109 var proxy = new remoteInterface.proxyClass; | |
110 var router = new Router(messagePipe.handle0); | |
111 var connection = new BaseConnection(undefined, proxy, router); | |
112 ProxyBindings(proxy).connection = connection; | |
113 | |
114 return { | |
115 handle: messagePipe.handle1, | |
116 proxy: proxy | |
117 }; | |
118 } | |
119 | |
101 // Return a handle for a message pipe that's connected to a stub for | 120 // Return a handle for a message pipe that's connected to a stub for |
102 // localInterface. Used by generated code for outgoing interface | 121 // localInterface. Used by generated code for outgoing interface |
103 // parameters: the caller is given the generated stub via | 122 // parameters: the caller is given the generated stub via |
104 // |stubCallback(stub)| and the generated code sends the handle | 123 // |stubCallback(stub)| and the generated code sends the handle |
105 // returned by this function. The caller is responsible for managing | 124 // returned by this function. The caller is responsible for managing |
106 // the lifetime of the stub and for setting it's implementation | 125 // the lifetime of the stub and for setting it's implementation |
107 // delegate with: StubBindings(stub).delegate = myImpl; | 126 // delegate with: StubBindings(stub).delegate = myImpl; |
108 function bindImpl(stubCallback, localInterface) { | 127 function bindImpl(stubCallback, localInterface) { |
109 var messagePipe = core.createMessagePipe(); | 128 var messagePipe = core.createMessagePipe(); |
110 if (messagePipe.result != core.RESULT_OK) | 129 if (messagePipe.result != core.RESULT_OK) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 var connection = new BaseConnection(obj, undefined, router); | 180 var connection = new BaseConnection(obj, undefined, router); |
162 obj.connection = connection; | 181 obj.connection = connection; |
163 return pipe.handle1; | 182 return pipe.handle1; |
164 } | 183 } |
165 | 184 |
166 var exports = {}; | 185 var exports = {}; |
167 exports.Connection = Connection; | 186 exports.Connection = Connection; |
168 exports.TestConnection = TestConnection; | 187 exports.TestConnection = TestConnection; |
169 | 188 |
170 exports.bindProxy = bindProxy; | 189 exports.bindProxy = bindProxy; |
190 exports.bindProxy2 = bindProxy2; | |
171 exports.bindImpl = bindImpl; | 191 exports.bindImpl = bindImpl; |
172 exports.bindHandleToProxy = bindHandleToProxy; | 192 exports.bindHandleToProxy = bindHandleToProxy; |
173 exports.bindHandleToStub = bindHandleToStub; | 193 exports.bindHandleToStub = bindHandleToStub; |
174 exports.bindStubDerivedImpl = bindStubDerivedImpl; | 194 exports.bindStubDerivedImpl = bindStubDerivedImpl; |
175 return exports; | 195 return exports; |
176 }); | 196 }); |
OLD | NEW |