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

Unified Diff: mojo/public/dart/src/application_connection.dart

Issue 968243003: Dart: Adds optional named arguments for creating bindings. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Format Created 5 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
« no previous file with comments | « mojo/public/dart/src/application.dart ('k') | mojo/public/dart/src/event_stream.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/dart/src/application_connection.dart
diff --git a/mojo/public/dart/src/application_connection.dart b/mojo/public/dart/src/application_connection.dart
index 4f0b6c8ed250056b670b9b7cddee8faeb53c7b07..5d98896ce60660131df841c6cab68b23efd7d393 100644
--- a/mojo/public/dart/src/application_connection.dart
+++ b/mojo/public/dart/src/application_connection.dart
@@ -14,12 +14,21 @@ class LocalServiceProvider implements ServiceProvider {
ServiceProviderStub _stub;
LocalServiceProvider(this.connection, this._stub) {
- _stub.delegate = this;
+ _stub.impl = this;
}
- listen() => _stub.listen();
+ listen({Function onClosed}) => _stub.listen(onClosed: _closer(onClosed));
- void close({bool nodefer : false}) => _stub.close(nodefer: nodefer);
+ Function _closer(Function onClosed) {
+ return (() {
+ if (onClosed != null) {
+ onClosed();
+ }
+ close();
+ });
+ }
+
+ void close({bool nodefer: false}) => _stub.close(nodefer: nodefer);
void connectToService(String interfaceName,
core.MojoMessagePipeEndpoint pipe) {
@@ -71,7 +80,7 @@ class ApplicationConnection {
}
FallbackServiceFactory get fallbackServiceFactory => _fallbackServiceFactory;
- set fallbackServiceFactory(FallbackServiceFactory f) {
+ set fallbackServiceFactory(FallbackServiceFactory f) {
assert(_localServiceProvider != null);
_fallbackServiceFactory = f;
}
@@ -82,8 +91,7 @@ class ApplicationConnection {
remoteServiceProvider.impl.isBound);
var pipe = new core.MojoMessagePipe();
proxy.impl.bind(pipe.endpoints[0]);
- remoteServiceProvider.ptr.connectToService(
- proxy.name, pipe.endpoints[1]);
+ remoteServiceProvider.ptr.connectToService(proxy.name, pipe.endpoints[1]);
return proxy;
}
@@ -92,9 +100,18 @@ class ApplicationConnection {
_nameToServiceFactory[interfaceName] = factory;
}
- void listen() {
+ void listen({Function onClosed}) {
assert(_localServiceProvider != null);
- _localServiceProvider.listen();
+ _localServiceProvider.listen(onClosed: _closer(onClosed));
+ }
+
+ Function _closer(Function onClosed) {
+ return (() {
+ if (onClosed != null) {
+ onClosed();
+ }
+ close();
+ });
}
void close({bool nodefer: false}) {
« no previous file with comments | « mojo/public/dart/src/application.dart ('k') | mojo/public/dart/src/event_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698