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

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

Issue 800523004: Dart: Simplifies the handle watcher. Various cleanups and bugfixes. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
Index: mojo/public/dart/src/data_pipe.dart
diff --git a/mojo/public/dart/src/data_pipe.dart b/mojo/public/dart/src/data_pipe.dart
index 665285de4a953d5b8a3287300240e5ebe31e13ce..11fc55d4c2e66537f35a4d958c91224a60f36c8a 100644
--- a/mojo/public/dart/src/data_pipe.dart
+++ b/mojo/public/dart/src/data_pipe.dart
@@ -96,14 +96,14 @@ class MojoDataPipeConsumer {
static const int FLAG_ALL_OR_NONE = 1 << 0;
static const int FLAG_MAY_DISCARD = 1 << 1;
static const int FLAG_QUERY = 1 << 2;
+ static const int FLAG_PEEK = 1 << 3;
RawMojoHandle handle;
MojoResult status;
final int element_bytes;
- MojoDataPipeConsumer(this.handle,
- this.status,
- this.element_bytes);
+ MojoDataPipeConsumer(
+ this.handle, [this.status = MojoResult.OK, this.element_bytes = 1]);
int read(ByteData data, [int num_bytes = -1, int flags = 0]) {
if (handle == null) {
@@ -123,7 +123,7 @@ class MojoDataPipeConsumer {
return result[1];
}
- ByteData beginRead(int buffer_bytes, [int flags = 0]) {
+ ByteData beginRead([int buffer_bytes = 0, int flags = 0]) {
if (handle == null) {
status = MojoResult.INVALID_ARGUMENT;
return null;
@@ -150,6 +150,8 @@ class MojoDataPipeConsumer {
status = new MojoResult(result);
return status;
}
+
+ int query() => read(null, 0, FLAG_QUERY);
}

Powered by Google App Engine
This is Rietveld 408576698