| 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) { |
| 11 | 11 |
| 12 var Router = router.Router; | 12 var Router = router.Router; |
| 13 var EmptyProxy = bindings.EmptyProxy; | 13 var EmptyProxy = bindings.EmptyProxy; |
| 14 var EmptyStub = bindings.EmptyStub; | 14 var EmptyStub = bindings.EmptyStub; |
| 15 var ProxyBindings = bindings.ProxyBindings; | 15 var ProxyBindings = bindings.ProxyBindings; |
| 16 var StubBindings = bindings.StubBindings; | 16 var StubBindings = bindings.StubBindings; |
| 17 var TestConnector = connector.TestConnector; | 17 var TestConnector = connector.TestConnector; |
| 18 var TestRouter = router.TestRouter; | 18 var TestRouter = router.TestRouter; |
| 19 | 19 |
| 20 // TODO(hansmuller): the proxy receiver_ property should be receiver$ | 20 // TODO(hansmuller): the proxy receiver_ property should be receiver$ |
| 21 | 21 |
| 22 function BaseConnection(localStub, remoteProxy, router) { | 22 function BaseConnection(localStub, remoteProxy, router) { |
| 23 this.router_ = router; | 23 this.router_ = router; |
| 24 this.local = localStub; | 24 this.local = localStub; |
| 25 this.remote = remoteProxy; | 25 this.remote = remoteProxy; |
| 26 | 26 |
| 27 this.router_.setIncomingReceiver(localStub); | 27 this.router_.setIncomingReceiver(localStub); |
| 28 this.router_.setErrorHandler(() => { |
| 29 if (StubBindings(this.local) && |
| 30 StubBindings(this.local).connectionErrorHandler) |
| 31 StubBindings(this.local).connectionErrorHandler(); |
| 32 }); |
| 28 if (this.remote) | 33 if (this.remote) |
| 29 this.remote.receiver_ = router; | 34 this.remote.receiver_ = router; |
| 30 | 35 |
| 31 // Validate incoming messages: remote responses and local requests. | 36 // Validate incoming messages: remote responses and local requests. |
| 32 var validateRequest = localStub && localStub.validator; | 37 var validateRequest = localStub && localStub.validator; |
| 33 var validateResponse = remoteProxy && remoteProxy.validator; | 38 var validateResponse = remoteProxy && remoteProxy.validator; |
| 34 var payloadValidators = []; | 39 var payloadValidators = []; |
| 35 if (validateRequest) | 40 if (validateRequest) |
| 36 payloadValidators.push(validateRequest); | 41 payloadValidators.push(validateRequest); |
| 37 if (validateResponse) | 42 if (validateResponse) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 var exports = {}; | 151 var exports = {}; |
| 147 exports.Connection = Connection; | 152 exports.Connection = Connection; |
| 148 exports.TestConnection = TestConnection; | 153 exports.TestConnection = TestConnection; |
| 149 | 154 |
| 150 exports.bindProxy = bindProxy; | 155 exports.bindProxy = bindProxy; |
| 151 exports.bindImpl = bindImpl; | 156 exports.bindImpl = bindImpl; |
| 152 exports.bindHandleToProxy = bindHandleToProxy; | 157 exports.bindHandleToProxy = bindHandleToProxy; |
| 153 exports.bindHandleToStub = bindHandleToStub; | 158 exports.bindHandleToStub = bindHandleToStub; |
| 154 return exports; | 159 return exports; |
| 155 }); | 160 }); |
| OLD | NEW |