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 part of application; | 5 part of application; |
6 | 6 |
7 typedef void ServiceFactory(core.MojoMessagePipeEndpoint endpoint); | 7 typedef void ServiceFactory(core.MojoMessagePipeEndpoint endpoint); |
8 typedef void FallbackServiceFactory( | 8 typedef void FallbackServiceFactory( |
9 String interfaceName, core.MojoMessagePipeEndpoint endpoint); | 9 String interfaceName, core.MojoMessagePipeEndpoint endpoint); |
10 | 10 |
11 class LocalServiceProvider implements ServiceProvider { | 11 class LocalServiceProvider implements ServiceProvider { |
12 final ApplicationConnection connection; | 12 final ApplicationConnection connection; |
13 ServiceProviderStub _stub; | 13 ServiceProviderStub _stub; |
14 | 14 |
15 LocalServiceProvider(this.connection, this._stub) { | 15 LocalServiceProvider(this.connection, this._stub) { |
16 _stub.impl = this; | 16 _stub.impl = this; |
17 if (!_stub.isOpen) { | 17 if (!_stub.ctrl.isOpen) { |
18 throw new core.MojoApiError("The service provider stub must be open"); | 18 throw new core.MojoApiError("The service provider stub must be open"); |
19 } | 19 } |
20 } | 20 } |
21 | 21 |
22 set onError(Function f) { | 22 set onError(Function f) { |
23 _stub.onError = f; | 23 _stub.ctrl.onError = f; |
24 } | 24 } |
25 | 25 |
26 Future close({bool immediate: false}) => _stub.close(immediate: immediate); | 26 Future close({bool immediate: false}) => _stub.close(immediate: immediate); |
27 | 27 |
28 void connectToService_( | 28 void connectToService_( |
29 String interfaceName, core.MojoMessagePipeEndpoint pipe) { | 29 String interfaceName, core.MojoMessagePipeEndpoint pipe) { |
30 if (connection._nameToServiceFactory.containsKey(interfaceName)) { | 30 if (connection._nameToServiceFactory.containsKey(interfaceName)) { |
31 connection._nameToServiceFactory[interfaceName](pipe); | 31 connection._nameToServiceFactory[interfaceName](pipe); |
32 return; | 32 return; |
33 } | 33 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 160 } |
161 if (_localServiceProvider != null) { | 161 if (_localServiceProvider != null) { |
162 lspCloseFuture = _localServiceProvider.close(immediate: immediate); | 162 lspCloseFuture = _localServiceProvider.close(immediate: immediate); |
163 _localServiceProvider = null; | 163 _localServiceProvider = null; |
164 } else { | 164 } else { |
165 lspCloseFuture = new Future.value(null); | 165 lspCloseFuture = new Future.value(null); |
166 } | 166 } |
167 return rspCloseFuture.then((_) => lspCloseFuture); | 167 return rspCloseFuture.then((_) => lspCloseFuture); |
168 } | 168 } |
169 } | 169 } |
OLD | NEW |