Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Unified Diff: mojo/dart/packages/mojo/lib/src/application_connection.dart

Issue 1648803006: Expose Service Describer in Dart mojo package (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase Retest and Update Mojoms Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698