Chromium Code Reviews| Index: mojo/public/dart/src/event_stream.dart |
| diff --git a/mojo/public/dart/src/event_stream.dart b/mojo/public/dart/src/event_stream.dart |
| index c1251140acaaefd870bf0e18085337e16cf8a879..7643ac71c7ed8bb4bcd21032b56cd41219e15c27 100644 |
| --- a/mojo/public/dart/src/event_stream.dart |
| +++ b/mojo/public/dart/src/event_stream.dart |
| @@ -123,9 +123,7 @@ class MojoEventStream extends Stream<List<int>> { |
| String toString() => "$_handle"; |
| } |
| -abstract class Listener { |
| - StreamSubscription<List<int>> listen({Function onClosed}); |
| -} |
| +typedef void ErrorHandler(); |
| class MojoEventStreamListener { |
| MojoMessagePipeEndpoint _endpoint; |
| @@ -133,25 +131,20 @@ class MojoEventStreamListener { |
| bool _isOpen = false; |
| bool _isInHandler = false; |
| StreamSubscription subscription; |
| + ErrorHandler onError; |
| - MojoEventStreamListener.fromEndpoint(MojoMessagePipeEndpoint endpoint, |
| - {bool doListen: true, Function onClosed}) |
| + MojoEventStreamListener.fromEndpoint(MojoMessagePipeEndpoint endpoint) |
|
hansmuller1
2015/03/06 17:12:38
We've run into the need for |doListen: false| when
zra
2015/03/06 21:12:00
Scott pointed out that it is okay to wait to set i
|
| : _endpoint = endpoint, |
| _eventStream = new MojoEventStream(endpoint.handle), |
| _isOpen = false { |
| - if (doListen) { |
| - listen(onClosed: onClosed); |
| - } |
| + listen(); |
| } |
| - MojoEventStreamListener.fromHandle(MojoHandle handle, {bool doListen: true, |
| - Function onClosed}) { |
| + MojoEventStreamListener.fromHandle(MojoHandle handle) { |
| _endpoint = new MojoMessagePipeEndpoint(handle); |
| _eventStream = new MojoEventStream(handle); |
| _isOpen = false; |
| - if (doListen) { |
| - listen(onClosed: onClosed); |
| - } |
| + listen(); |
| } |
| MojoEventStreamListener.unbound() |
| @@ -173,7 +166,7 @@ class MojoEventStreamListener { |
| _isOpen = false; |
| } |
| - StreamSubscription<List<int>> listen({Function onClosed}) { |
| + StreamSubscription<List<int>> listen() { |
| assert(isBound && (subscription == null)); |
| _isOpen = true; |
| subscription = _eventStream.listen((List<int> event) { |
| @@ -193,7 +186,7 @@ class MojoEventStreamListener { |
| } |
| _isInHandler = false; |
| if (signalsReceived.isPeerClosed) { |
| - if (onClosed != null) onClosed(); |
| + if (onError != null) onError(); |
| close(); |
| // The peer being closed obviates any other signal we might |
| // have received since we won't be able to read or write the handle. |