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

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 and Format Created 5 years, 9 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/codec.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 687599d877c894263481dd724236353c68f5f77c..d4d8d20152a33ae55d85e228e1e6bd131e650721 100644
--- a/mojo/public/dart/src/application_connection.dart
+++ b/mojo/public/dart/src/application_connection.dart
@@ -13,18 +13,12 @@ class LocalServiceProvider implements ServiceProvider {
ServiceProviderStub _stub;
LocalServiceProvider(this.connection, this._stub) {
+ assert(_stub.isOpen);
_stub.impl = this;
}
- 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);
@@ -71,11 +65,13 @@ class ApplicationConnection {
LocalServiceProvider _localServiceProvider;
final _nameToServiceFactory = new Map<String, ServiceFactory>();
FallbackServiceFactory _fallbackServiceFactory;
+ core.ErrorHandler onError;
- 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 = _errorHandler;
+ }
}
FallbackServiceFactory get fallbackServiceFactory => _fallbackServiceFactory;
@@ -99,18 +95,9 @@ class ApplicationConnection {
_nameToServiceFactory[interfaceName] = factory;
}
- void listen({Function onClosed}) {
- assert(_localServiceProvider != null);
- _localServiceProvider.listen(onClosed: _closer(onClosed));
- }
-
- Function _closer(Function onClosed) {
- return (() {
- if (onClosed != null) {
- onClosed();
- }
- close();
- });
+ void _errorHandler() {
+ if (onError != null) onError();
+ close();
}
void close({bool nodefer: false}) {
« no previous file with comments | « mojo/public/dart/src/application.dart ('k') | mojo/public/dart/src/codec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698