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

Unified Diff: mojo/public/dart/mojo/lib/src/drain_data.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 | « mojo/public/dart/mojo/lib/src/codec.dart ('k') | mojo/public/dart/mojo/lib/src/event_stream.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/dart/mojo/lib/src/drain_data.dart
diff --git a/mojo/public/dart/mojo/lib/src/drain_data.dart b/mojo/public/dart/mojo/lib/src/drain_data.dart
index b5929e567a3191f1582a32bcc011bb28a9a43549..dc630bfbdc7c1a2fc73b72023bcebd4af8a2fe6a 100644
--- a/mojo/public/dart/mojo/lib/src/drain_data.dart
+++ b/mojo/public/dart/mojo/lib/src/drain_data.dart
@@ -6,19 +6,18 @@ part of core;
class DataPipeDrainer {
MojoDataPipeConsumer _consumer;
- MojoEventStream _eventStream;
+ MojoEventSubscription _eventSubscription;
List<ByteData> _dataList;
int _dataSize;
DataPipeDrainer(this._consumer) {
- _eventStream = new MojoEventStream(_consumer.handle);
+ _eventSubscription = new MojoEventSubscription(_consumer.handle);
_dataList = new List();
_dataSize = 0;
}
- ByteData _copy(ByteData byteData) =>
- new ByteData.view(
- new Uint8List.fromList(byteData.buffer.asUint8List()).buffer);
+ ByteData _copy(ByteData byteData) => new ByteData.view(
+ new Uint8List.fromList(byteData.buffer.asUint8List()).buffer);
MojoResult _doRead() {
ByteData thisRead = _consumer.beginRead();
@@ -34,8 +33,9 @@ class DataPipeDrainer {
var data = new ByteData(_dataSize);
int end = 0;
for (var chunk in _dataList) {
- data.buffer.asUint8List().setRange(
- end, end + chunk.lengthInBytes, chunk.buffer.asUint8List());
+ data.buffer
+ .asUint8List()
+ .setRange(end, end + chunk.lengthInBytes, chunk.buffer.asUint8List());
end += chunk.lengthInBytes;
}
return data;
@@ -43,20 +43,20 @@ class DataPipeDrainer {
Future<ByteData> drain() {
var completer = new Completer();
- _eventStream.listen((List<int> event) {
+ _eventSubscription.subscribe((List<int> event) {
var mojoSignals = new MojoHandleSignals(event[1]);
if (mojoSignals.isReadable) {
var result = _doRead();
if (!result.isOk) {
- _eventStream.close();
- _eventStream = null;
+ _eventSubscription.close();
+ _eventSubscription = null;
completer.complete(_concatData());
} else {
- _eventStream.enableReadEvents();
+ _eventSubscription.enableReadEvents();
}
} else if (mojoSignals.isPeerClosed) {
- _eventStream.close();
- _eventStream = null;
+ _eventSubscription.close();
+ _eventSubscription = null;
completer.complete(_concatData());
} else {
throw 'Unexpected handle event: $mojoSignals';
« no previous file with comments | « mojo/public/dart/mojo/lib/src/codec.dart ('k') | mojo/public/dart/mojo/lib/src/event_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698