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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 if (!core.isHandle(handle)) | 141 if (!core.isHandle(handle)) |
142 throw new Error("Not a handle " + handle); | 142 throw new Error("Not a handle " + handle); |
143 | 143 |
144 var stub = new localInterface.stubClass; | 144 var stub = new localInterface.stubClass; |
145 var router = new Router(handle); | 145 var router = new Router(handle); |
146 var connection = new BaseConnection(stub, undefined, router); | 146 var connection = new BaseConnection(stub, undefined, router); |
147 StubBindings(stub).connection = connection; | 147 StubBindings(stub).connection = connection; |
148 return stub; | 148 return stub; |
149 } | 149 } |
150 | 150 |
| 151 /** |
| 152 * Creates a messape pipe and links one end of the pipe to the given object. |
| 153 * @param {!Object} obj The object to create a handle for. Must be a subclass |
| 154 * of an auto-generated stub class. |
| 155 * @return {!MojoHandle} The other (not yet connected) end of the message |
| 156 * pipe. |
| 157 */ |
| 158 function bindStubDerivedImpl(obj) { |
| 159 var pipe = core.createMessagePipe(); |
| 160 var router = new Router(pipe.handle0); |
| 161 var connection = new BaseConnection(obj, undefined, router); |
| 162 obj.connection = connection; |
| 163 return pipe.handle1; |
| 164 } |
| 165 |
151 var exports = {}; | 166 var exports = {}; |
152 exports.Connection = Connection; | 167 exports.Connection = Connection; |
153 exports.TestConnection = TestConnection; | 168 exports.TestConnection = TestConnection; |
154 | 169 |
155 exports.bindProxy = bindProxy; | 170 exports.bindProxy = bindProxy; |
156 exports.bindImpl = bindImpl; | 171 exports.bindImpl = bindImpl; |
157 exports.bindHandleToProxy = bindHandleToProxy; | 172 exports.bindHandleToProxy = bindHandleToProxy; |
158 exports.bindHandleToStub = bindHandleToStub; | 173 exports.bindHandleToStub = bindHandleToStub; |
| 174 exports.bindStubDerivedImpl = bindStubDerivedImpl; |
159 return exports; | 175 return exports; |
160 }); | 176 }); |
OLD | NEW |