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

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

Issue 851173002: Dart: Encode/Decode handle and interface types. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix Interface encode parameters Created 5 years, 11 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/data_pipe.dart ('k') | mojo/public/dart/src/interface.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bde490dde4dde3bea0dbb6faceb77f3e891078f6..797f0e6775d6f5fd7996e336f8519ca07a294cfc 100644
--- a/mojo/public/dart/src/event_stream.dart
+++ b/mojo/public/dart/src/event_stream.dart
@@ -122,17 +122,36 @@ class MojoEventStream extends Stream<int> {
class MojoEventStreamListener {
MojoMessagePipeEndpoint _endpoint;
MojoEventStream _eventStream;
- bool _isOpen;
- bool _isInHandler;
+ bool _isOpen = false;
+ bool _isInHandler = false;
MojoEventStreamListener(MojoMessagePipeEndpoint endpoint) :
_endpoint = endpoint,
_eventStream = new MojoEventStream(endpoint.handle),
_isOpen = false;
- MojoEventStreamListener.fromHandle(int handle) {
- _endpoint = new MojoMessagePipeEndpoint(new MojoHandle(handle));
- _eventStream = new MojoEventStream(_endpoint.handle);
+ MojoEventStreamListener.fromHandle(MojoHandle handle) {
+ _endpoint = new MojoMessagePipeEndpoint(handle);
+ _eventStream = new MojoEventStream(handle);
+ _isOpen = false;
+ }
+
+ MojoEventStreamListener.unbound() :
+ _endpoint = null,
+ _eventStream = null,
+ _isOpen = false;
+
+ void bind(MojoMessagePipeEndpoint endpoint) {
+ assert(!isBound);
+ _endpoint = endpoint;
+ _eventStream = new MojoEventStream(endpoint.handle);
+ _isOpen = false;
+ }
+
+ void bindFromHandle(MojoHandle handle) {
+ assert(!isBound);
+ _endpoint = new MojoMessagePipeEndpoint(handle);
+ _eventStream = new MojoEventStream(handle);
_isOpen = false;
}
@@ -168,6 +187,7 @@ class MojoEventStreamListener {
_eventStream.close();
_isOpen = false;
_eventStream = null;
+ _endpoint = null;
}
}
@@ -183,4 +203,5 @@ class MojoEventStreamListener {
MojoMessagePipeEndpoint get endpoint => _endpoint;
bool get isOpen => _isOpen;
bool get isInHandler => _isInHandler;
+ bool get isBound => _endpoint != null;
}
« no previous file with comments | « mojo/public/dart/src/data_pipe.dart ('k') | mojo/public/dart/src/interface.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698