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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 StubBindings(stub).connection = connection; | 135 StubBindings(stub).connection = connection; |
136 if (stubCallback) | 136 if (stubCallback) |
137 stubCallback(stub); | 137 stubCallback(stub); |
138 | 138 |
139 return messagePipe.handle1; | 139 return messagePipe.handle1; |
140 } | 140 } |
141 | 141 |
142 // Return a remoteInterface proxy for handle. Used by generated code | 142 // Return a remoteInterface proxy for handle. Used by generated code |
143 // for converting incoming interface parameters to proxies. | 143 // for converting incoming interface parameters to proxies. |
144 function bindHandleToProxy(handle, remoteInterface) { | 144 function bindHandleToProxy(handle, remoteInterface) { |
145 if (!core.isHandle(handle)) | 145 if (!(handle instanceof MojoHandle)) |
146 throw new Error("Not a handle " + handle); | 146 throw new Error("Not a handle " + handle); |
147 | 147 |
148 var proxy = new remoteInterface.proxyClass; | 148 var proxy = new remoteInterface.proxyClass; |
149 var router = new Router(handle); | 149 var router = new Router(handle); |
150 var connection = new BaseConnection(undefined, proxy, router); | 150 var connection = new BaseConnection(undefined, proxy, router); |
151 ProxyBindings(proxy).connection = connection; | 151 ProxyBindings(proxy).connection = connection; |
152 return proxy; | 152 return proxy; |
153 } | 153 } |
154 | 154 |
155 // Return a localInterface stub for handle. Used by generated code | 155 // Return a localInterface stub for handle. Used by generated code |
156 // for converting incoming interface& request parameters to localInterface | 156 // for converting incoming interface& request parameters to localInterface |
157 // stubs. The caller can specify the stub's implementation of localInterface | 157 // stubs. The caller can specify the stub's implementation of localInterface |
158 // like this: StubBindings(stub).delegate = myStubImpl. | 158 // like this: StubBindings(stub).delegate = myStubImpl. |
159 function bindHandleToStub(handle, localInterface) { | 159 function bindHandleToStub(handle, localInterface) { |
160 if (!core.isHandle(handle)) | 160 if (!(handle instanceof MojoHandle)) |
161 throw new Error("Not a handle " + handle); | 161 throw new Error("Not a handle " + handle); |
162 | 162 |
163 var stub = new localInterface.stubClass; | 163 var stub = new localInterface.stubClass; |
164 var router = new Router(handle); | 164 var router = new Router(handle); |
165 var connection = new BaseConnection(stub, undefined, router); | 165 var connection = new BaseConnection(stub, undefined, router); |
166 StubBindings(stub).connection = connection; | 166 StubBindings(stub).connection = connection; |
167 return stub; | 167 return stub; |
168 } | 168 } |
169 | 169 |
170 /** | 170 /** |
(...skipping 16 matching lines...) Expand all Loading... |
187 exports.TestConnection = TestConnection; | 187 exports.TestConnection = TestConnection; |
188 | 188 |
189 exports.bindProxy = bindProxy; | 189 exports.bindProxy = bindProxy; |
190 exports.getProxy = getProxy; | 190 exports.getProxy = getProxy; |
191 exports.bindImpl = bindImpl; | 191 exports.bindImpl = bindImpl; |
192 exports.bindHandleToProxy = bindHandleToProxy; | 192 exports.bindHandleToProxy = bindHandleToProxy; |
193 exports.bindHandleToStub = bindHandleToStub; | 193 exports.bindHandleToStub = bindHandleToStub; |
194 exports.bindStubDerivedImpl = bindStubDerivedImpl; | 194 exports.bindStubDerivedImpl = bindStubDerivedImpl; |
195 return exports; | 195 return exports; |
196 }); | 196 }); |
OLD | NEW |