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

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: Address zra's feedback 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..41405e87e611090ce2bb84d86f0c2949d9fb978b 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,28 @@ class ApplicationConnection {
return proxy;
}
- void provideService(String interfaceName, ServiceFactory factory) {
+ /// Prepares this connection to provide the specified service when a call for
+ /// the given [interfaceName] is received. The provided service can also
+ /// 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) {
+ _nameToServiceFactory[describerName] = (endpoint) =>
+ new _ServiceDescriberImpl(_serviceDescriptions, endpoint);
+ }
}
void _errorHandler(Object e) {
« no previous file with comments | « mojo/dart/packages/mojo/lib/src/application.dart ('k') | mojo/dart/packages/mojo/lib/src/service_describer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698