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

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

Issue 982673002: Dart: Removes need to call listen(). (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge 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
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 5d98896ce60660131df841c6cab68b23efd7d393..b4a361c8d77023ad2394fa4afa902d9589754b7c 100644
--- a/mojo/public/dart/src/application_connection.dart
+++ b/mojo/public/dart/src/application_connection.dart
@@ -15,20 +15,14 @@ class LocalServiceProvider implements ServiceProvider {
LocalServiceProvider(this.connection, this._stub) {
_stub.impl = this;
+ assert(_stub.isOpen);
}
- listen({Function onClosed}) => _stub.listen(onClosed: _closer(onClosed));
-
- Function _closer(Function onClosed) {
- return (() {
- if (onClosed != null) {
- onClosed();
- }
- close();
- });
+ set onError(Function f) {
+ _stub.onError = f;
}
- void close({bool nodefer: false}) => _stub.close(nodefer: nodefer);
+ void close({bool nodefer : false}) => _stub.close(nodefer: nodefer);
void connectToService(String interfaceName,
core.MojoMessagePipeEndpoint pipe) {
@@ -73,14 +67,15 @@ class ApplicationConnection {
final _nameToServiceFactory = new Map<String, ServiceFactory>();
FallbackServiceFactory _fallbackServiceFactory;
- ApplicationConnection(ServiceProviderStub stub, ServiceProviderProxy proxy)
- : remoteServiceProvider = proxy {
- if (stub != null) _localServiceProvider =
- new LocalServiceProvider(this, stub);
+ ApplicationConnection(ServiceProviderStub stub, this.remoteServiceProvider) {
+ if (stub != null) {
+ _localServiceProvider = new LocalServiceProvider(this, stub);
+ _localServiceProvider.onError = close;
+ }
}
FallbackServiceFactory get fallbackServiceFactory => _fallbackServiceFactory;
- set fallbackServiceFactory(FallbackServiceFactory f) {
+ set fallbackServiceFactory(FallbackServiceFactory f) {
assert(_localServiceProvider != null);
_fallbackServiceFactory = f;
}
@@ -100,18 +95,9 @@ class ApplicationConnection {
_nameToServiceFactory[interfaceName] = factory;
}
- void listen({Function onClosed}) {
+ set onError(Function f) {
assert(_localServiceProvider != null);
- _localServiceProvider.listen(onClosed: _closer(onClosed));
- }
-
- Function _closer(Function onClosed) {
- return (() {
- if (onClosed != null) {
- onClosed();
- }
- close();
- });
+ _localServiceProvider.onError = f;
}
void close({bool nodefer: false}) {

Powered by Google App Engine
This is Rietveld 408576698