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

Unified Diff: mojo/dart/embedder/io/socket_patch.dart

Issue 1414483010: Dart: Use a RawReceivePort to receive events for Mojo handles. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « examples/dart/netcat/lib/main.dart ('k') | mojo/dart/embedder/test/run_dart_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/dart/embedder/io/socket_patch.dart
diff --git a/mojo/dart/embedder/io/socket_patch.dart b/mojo/dart/embedder/io/socket_patch.dart
index d8a80fde6472aed86710f5211de0c214fff573a1..80b172c9b28339199bc76e54205c05bf84408097 100644
--- a/mojo/dart/embedder/io/socket_patch.dart
+++ b/mojo/dart/embedder/io/socket_patch.dart
@@ -34,8 +34,8 @@ class _MojoRawSocket extends Stream<RawSocketEvent> implements RawSocket {
bool _inClosed = false;
bool _readEventsEnabled = true;
bool _writeEventsEnabled = true;
- MojoEventStream _pipeOutEvents;
- MojoEventStream _pipeInEvents;
+ MojoEventSubscription _pipeOutEvents;
+ MojoEventSubscription _pipeInEvents;
InternetAddress _localAddress;
int _localPort;
InternetAddress _remoteAddress;
@@ -267,22 +267,6 @@ class _MojoRawSocket extends Stream<RawSocketEvent> implements RawSocket {
}
}
- _onInputError(e, st) {
- _controller.addError(e);
- _onInputDone();
- }
-
- _onInputDone() {
- if (_inClosed) {
- return;
- }
- if (_trace) {
- _tracePrint('<- READ_CLOSED (done)');
- }
- _controller.add(RawSocketEvent.READ_CLOSED);
- _inClosed = true;
- }
-
_onOutputData(List<int> event) {
if (_outClosed) {
return;
@@ -309,40 +293,20 @@ class _MojoRawSocket extends Stream<RawSocketEvent> implements RawSocket {
}
}
- _onOutputError(e, st) {
- _controller.addError(e);
- _onOutputDone();
- }
-
- _onOutputDone() {
- if (_outClosed) {
- return;
- }
- if (_trace) {
- _tracePrint('<- CLOSED (done)');
- }
- _controller.add(RawSocketEvent.CLOSED);
- _outClosed = true;
- }
-
_setupIn() {
assert(_pipeInEvents == null);
- _pipeInEvents = new MojoEventStream(_pipeIn.consumer.handle,
+ _pipeInEvents = new MojoEventSubscription(_pipeIn.consumer.handle,
MojoHandleSignals.READABLE +
MojoHandleSignals.PEER_CLOSED);
- _pipeInEvents.listen(_onInputData,
- onError: _onInputError,
- onDone: _onInputDone);
+ _pipeInEvents.subscribe(_onInputData);
}
_setupOut() {
assert(_pipeOutEvents == null);
- _pipeOutEvents = new MojoEventStream(_pipeOut.producer.handle,
+ _pipeOutEvents = new MojoEventSubscription(_pipeOut.producer.handle,
MojoHandleSignals.WRITABLE +
MojoHandleSignals.PEER_CLOSED);
- _pipeOutEvents.listen(_onOutputData,
- onError: _onOutputError,
- onDone: _onOutputDone);
+ _pipeOutEvents.subscribe(_onOutputData);
}
_shutdownIn([bool force = false]) {
@@ -498,27 +462,27 @@ class _MojoRawSocket extends Stream<RawSocketEvent> implements RawSocket {
}
- static _enableReadEvents(MojoEventStream stream) {
- if (stream == null) {
+ static _enableReadEvents(MojoEventSubscription subscription) {
+ if (subscription == null) {
return;
}
- stream.enableSignals(MojoHandleSignals.PEER_CLOSED +
- MojoHandleSignals.READABLE);
+ subscription.enableSignals(MojoHandleSignals.PEER_CLOSED +
+ MojoHandleSignals.READABLE);
}
- static _enableWriteEvents(MojoEventStream stream) {
- if (stream == null) {
+ static _enableWriteEvents(MojoEventSubscription subscription) {
+ if (subscription == null) {
return;
}
- stream.enableSignals(MojoHandleSignals.PEER_CLOSED +
- MojoHandleSignals.WRITABLE);
+ subscription.enableSignals(MojoHandleSignals.PEER_CLOSED +
+ MojoHandleSignals.WRITABLE);
}
- static _disableEvents(MojoEventStream stream) {
- if (stream == null) {
+ static _disableEvents(MojoEventSubscription subscription) {
+ if (subscription == null) {
return;
}
- stream.enableSignals(MojoHandleSignals.PEER_CLOSED);
+ subscription.enableSignals(MojoHandleSignals.PEER_CLOSED);
}
_pause() {
« no previous file with comments | « examples/dart/netcat/lib/main.dart ('k') | mojo/dart/embedder/test/run_dart_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698