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

Unified Diff: mojo/dart/packages/mojo/lib/src/data_pipe.dart

Issue 1694413003: Cleanups in the Mojo package. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
Index: mojo/dart/packages/mojo/lib/src/data_pipe.dart
diff --git a/mojo/dart/packages/mojo/lib/src/data_pipe.dart b/mojo/dart/packages/mojo/lib/src/data_pipe.dart
index 6ba8ec3149af007c3c002cc16f5194f599bc139d..9607bdba5338a0b86603519829cef7596086e244 100644
--- a/mojo/dart/packages/mojo/lib/src/data_pipe.dart
+++ b/mojo/dart/packages/mojo/lib/src/data_pipe.dart
@@ -5,8 +5,8 @@
part of core;
class MojoDataPipeProducer {
- static const int FLAG_NONE = 0;
- static const int FLAG_ALL_OR_NONE = 1 << 0;
+ static const int flagNone = MojoConstants.kNone;
+ static const int flagAllOrNone = MojoConstants.kAllOrNone;
final int elementBytes;
MojoHandle handle;
@@ -15,7 +15,7 @@ class MojoDataPipeProducer {
MojoDataPipeProducer(this.handle,
[this.status = MojoResult.kOk, this.elementBytes = 1]);
- int write(ByteData data, [int numBytes = -1, int flags = FLAG_NONE]) {
+ int write(ByteData data, [int numBytes = -1, int flags = flagNone]) {
if (handle == null) {
status = MojoResult.kInvalidArgument;
return 0;
@@ -34,8 +34,7 @@ class MojoDataPipeProducer {
return result[1];
}
- // TODO(floitsch): remove bufferBytes.
- ByteData beginWrite(int bufferBytes, [int flags = FLAG_NONE]) {
+ ByteData beginWrite([int flags = flagNone]) {
if (handle == null) {
status = MojoResult.kInvalidArgument;
return null;
@@ -67,11 +66,11 @@ class MojoDataPipeProducer {
}
class MojoDataPipeConsumer {
- static const int FLAG_NONE = 0;
- static const int FLAG_ALL_OR_NONE = 1 << 0;
- static const int FLAG_DISCARD = 1 << 1;
- static const int FLAG_QUERY = 1 << 2;
- static const int FLAG_PEEK = 1 << 3;
+ static const int flagNone = MojoConstants.kNone;
+ static const int flagAllOrNone = MojoConstants.kAllOrNone;
+ static const int flagDiscard = MojoConstants.kDiscard;
+ static const int flagQuery = MojoConstants.kQuery;
+ static const int flagPeek = MojoConstants.kPeek;
MojoHandle handle;
final int elementBytes;
@@ -80,7 +79,7 @@ class MojoDataPipeConsumer {
MojoDataPipeConsumer(this.handle,
[this.status = MojoResult.kOk, this.elementBytes = 1]);
- int read(ByteData data, [int numBytes = -1, int flags = FLAG_NONE]) {
+ int read(ByteData data, [int numBytes = -1, int flags = flagNone]) {
if (handle == null) {
status = MojoResult.kInvalidArgument;
return 0;
@@ -98,8 +97,7 @@ class MojoDataPipeConsumer {
return result[1];
}
- // TODO(floitsch): remove bufferBytes.
- ByteData beginRead([int bufferBytes = 0, int flags = FLAG_NONE]) {
+ ByteData beginRead([int flags = flagNone]) {
if (handle == null) {
status = MojoResult.kInvalidArgument;
return null;
@@ -126,7 +124,7 @@ class MojoDataPipeConsumer {
return status;
}
- int query() => read(null, 0, FLAG_QUERY);
+ int query() => read(null, 0, flagQuery);
String toString() => "MojoDataPipeConsumer(handle: $handle, "
"status: ${MojoResult.string(status)}, "
@@ -134,9 +132,9 @@ class MojoDataPipeConsumer {
}
class MojoDataPipe {
- static const int FLAG_NONE = 0;
- static const int DEFAULT_ELEMENT_SIZE = 1;
- static const int DEFAULT_CAPACITY = 0;
+ static const int flagNone = MojoConstants.kNone;
+ static const int defaultElementSize = MojoConstants.kDefaultPipeElementSize;
+ static const int defaultCapacity = MojoConstants.kDefaultPipeCapacity;
MojoDataPipeProducer producer;
MojoDataPipeConsumer consumer;
@@ -145,9 +143,9 @@ class MojoDataPipe {
MojoDataPipe._internal() : status = MojoResult.kOk;
factory MojoDataPipe(
- [int elementBytes = DEFAULT_ELEMENT_SIZE,
- int capacityBytes = DEFAULT_CAPACITY,
- int flags = FLAG_NONE]) {
+ [int elementBytes = defaultElementSize,
+ int capacityBytes = defaultCapacity,
+ int flags = flagNone]) {
List result = MojoDataPipeNatives.MojoCreateDataPipe(
elementBytes, capacityBytes, flags);
if (result == null) {

Powered by Google App Engine
This is Rietveld 408576698