Chromium Code Reviews| Index: mojo/dart/packages/mojo/lib/src/application_connection.dart |
| diff --git a/mojo/dart/packages/mojo/lib/src/application_connection.dart b/mojo/dart/packages/mojo/lib/src/application_connection.dart |
| index a014a7ca917dad0a2d410abd564cc0658ae39b82..76929e319235fd55407f04f4884578fc8a507775 100644 |
| --- a/mojo/dart/packages/mojo/lib/src/application_connection.dart |
| +++ b/mojo/dart/packages/mojo/lib/src/application_connection.dart |
| @@ -64,6 +64,8 @@ class ApplicationConnection { |
| ServiceProviderProxy remoteServiceProvider; |
| LocalServiceProvider _localServiceProvider; |
| final _nameToServiceFactory = new HashMap<String, ServiceFactory>(); |
| + final _serviceDescriptions = |
| + new HashMap<String, service_describer.ServiceDescription>(); |
| FallbackServiceFactory _fallbackServiceFactory; |
| core.ErrorHandler onError; |
| @@ -80,8 +82,8 @@ class ApplicationConnection { |
| _fallbackServiceFactory = f; |
| } |
| - bindings.ProxyBase requestService( |
| - bindings.ProxyBase proxy, [String serviceName]) { |
| + bindings.ProxyBase requestService(bindings.ProxyBase proxy, |
| + [String serviceName]) { |
| assert(!proxy.impl.isBound && |
| (remoteServiceProvider != null) && |
| remoteServiceProvider.impl.isBound); |
| @@ -95,10 +97,30 @@ class ApplicationConnection { |
| return proxy; |
| } |
| - void provideService(String interfaceName, ServiceFactory factory) { |
| + // Prepares this connection to provide the specified service when a call for |
|
zra
2016/02/10 22:48:24
Use /// so the document generator will see this co
alexfandrianto
2016/02/11 01:04:55
Done.
|
| + // the given interfaceName is received. The provided service can also |
|
zra
2016/02/10 22:48:24
[interfaceName]
alexfandrianto
2016/02/11 01:04:55
Done.
|
| + // choose to expose a service description. |
| + void provideService(String interfaceName, ServiceFactory factory, |
| + {service_describer.ServiceDescription description}) { |
| assert(_localServiceProvider != null); |
| assert(interfaceName != null); |
| _nameToServiceFactory[interfaceName] = factory; |
| + if (description != null) { |
| + _serviceDescriptions[interfaceName] = description; |
| + _provideServiceDescriber(); |
| + } |
| + } |
| + |
| + // Provides the ServiceDescriber interface for the set of services whose |
| + // service descriptions have been provided (see provideService). |
| + void _provideServiceDescriber() { |
| + String describerName = service_describer.ServiceDescriber.serviceName; |
| + if (_nameToServiceFactory[describerName] == null) { |
| + ServiceFactory serviceDescriberFactory = (endpoint) => |
| + new _ServiceDescriberImpl(_serviceDescriptions, endpoint); |
| + |
| + _nameToServiceFactory[describerName] = serviceDescriberFactory; |
|
zra
2016/02/10 22:48:24
_nameToServiceFactory[describerName] = (endpoint)
alexfandrianto
2016/02/11 01:04:55
Done.
|
| + } |
| } |
| void _errorHandler(Object e) { |