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

Unified Diff: mojo/dart/packages/mojo/sdk_ext/src/natives.dart

Issue 1694413003: Cleanups in the Mojo package. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address comments. 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/sdk_ext/src/natives.dart
diff --git a/mojo/dart/packages/mojo/sdk_ext/src/natives.dart b/mojo/dart/packages/mojo/sdk_ext/src/natives.dart
index e4f8fbbb3de2780b9d00e5c0b6cac0610108a837..4a7e48a173e44fa6e8beb1f10aabd6ae08915df6 100644
--- a/mojo/dart/packages/mojo/sdk_ext/src/natives.dart
+++ b/mojo/dart/packages/mojo/sdk_ext/src/natives.dart
@@ -106,8 +106,8 @@ class MojoHandleNatives {
/// Registers a finalizer on [eventSubscription] to close the given
/// [handleToken].
///
- /// Returns an integer, encoding the result as specified in the [MojoResult]
- /// class. In particular, a successful operation returns [MojoResult.kOk].
+ /// Returns an integer, encoding the result as specified in [MojoConstants].
+ /// In particular, a successful operation returns [MojoConstants.kOk].
///
/// When [eventSubscription] (currently an Instance of the
/// [MojoEventSubscription] class) is garbage-collected, invokes [close] on
@@ -121,8 +121,8 @@ class MojoHandleNatives {
/// Closes the given [handleToken].
///
- /// Returns an integer, encoding the result as specified in the [MojoResult]
- /// class. In particular, a successful operation returns [MojoResult.kOk].
+ /// Returns an integer, encoding the result as specified in [MojoConstants].
+ /// In particular, a successful operation returns [MojoConstants.kOk].
///
/// The [handleToken] is a token that identifies the Mojo handle.
static int close(int handleToken) native "MojoHandle_Close";
@@ -130,36 +130,39 @@ class MojoHandleNatives {
/// Waits on the given [handleToken] for a signal.
///
/// Returns a list of two elements. The first entry is an integer, encoding
- /// if the operation was a success or not, as specified in the [MojoResult]
- /// class. In particular, a successful operation is signaled by
- /// [MojoResult.kOk]. The second entry is itself a list of 2 elements:
+ /// if the operation was a success or not, as specified in [MojoConstants].
+ /// In particular, a successful operation is signaled by
+ /// [MojoConstants.kOk]. The second entry is itself a list of 2 elements:
/// an integer of satisfied signals, and an integer of satisfiable signals.
- /// Both entries are encoded as specified in [MojoHandleSignals].
+ /// Both entries are encoded as specified in [MojoConstants], section
+ /// "Handle Signals".
///
/// A signal is satisfiable, if the signal may become true in the future.
///
/// The [deadline] specifies how long the call should wait (if no signal is
/// triggered). If the deadline passes, the returned result-integer is
- /// [MojoResult.kDeadlineExceeded]. If the deadline is 0, then the result
- /// is only [MojoResult.kDeadlineExceeded] if no other termination condition
+ /// [MojoConstants.kDeadlineExceeded]. If the deadline is 0, then the result
+ /// is only [MojoConstants.kDeadlineExceeded] if no other termination condition
/// is already satisfied (see below).
///
/// The [signals] integer encodes the signals this method should wait for.
- /// The integer is encoded as specified in [MojoHandleSignals].
+ /// The integer is encoded as specified in [MojoConstants], section
+ /// "Handle Signals".
///
/// Waits on the given handle until one of the following happens:
/// - A signal indicated by [signals] is satisfied.
/// - It becomes known that no signal indicated by [signals] will ever be
/// satisfied (for example the handle has been closed on the other side).
- /// - The [deadline] has passed.
+ /// - The [deadline] has passed. [MojoConstants.kDeadlineIndefinite] may be
+ /// used to wait indefinitely.
static List wait(int handleToken, int signals, int deadline)
native "MojoHandle_Wait";
/// Waits on many handles at the same time.
///
/// Returns a list with exactly 3 elements:
- /// - the result integer, encoded as specified in [MojoResult]. In particular,
- /// [MojoResult.kOk] signals success.
+ /// - the result integer, encoded as specified in [MojoConstants]. In
+ /// particular, [MojoConstants.kOk] signals success.
/// - the index of the handle that caused the return. May be `null` if the
/// operation didn't succeed.
/// - a list of signal states. May be `null` if the operation didn't succeed.
@@ -198,19 +201,19 @@ class MojoMessagePipeNatives {
/// Creates a message pipe represented by its two endpoints (handles).
///
/// Returns a list with exactly 3 elements:
- /// - the result integer, encoded as specified in [MojoResult]. In particular,
- /// [MojoResult.kOk] signals a successful creation.
+ /// - the result integer, encoded as specified in [MojoConstants]. In
+ /// particular, [MojoConstants.kOk] signals a successful creation.
/// - the two endpoints of the message pipe. These tokens can be used in the
/// methods of [MojoHandleNatives].
///
/// The parameter [flags] is reserved for future use and should currently be
- /// set to [MojoMessagePipe.FLAG_NONE] (equal to 0).
+ /// set to [MojoConstants.kNone].
static List MojoCreateMessagePipe(int flags) native "MojoMessagePipe_Create";
/// Writes a message into the endpoint [handleToken].
///
- /// Returns a result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful write.
+ /// Returns an integer, encoding the result as specified in [MojoConstants].
+ /// In particular, a successful operation returns [MojoConstants.kOk].
///
/// The [handleToken] is a token that identifies the Mojo handle.
///
@@ -218,7 +221,7 @@ class MojoMessagePipeNatives {
/// [handleTokens].
///
/// The parameter [flags] is reserved for future use and should currently be
- /// set to [MojoMessagePipeEndpoint.WRITE_FLAG_NONE] (equal to 0).
+ /// set to [MojoConstants.kNone].
static int MojoWriteMessage(int handleToken, ByteData data, int numBytes,
List<int> handles, int flags) native "MojoMessagePipe_Write";
@@ -226,15 +229,15 @@ class MojoMessagePipeNatives {
///
/// Returns `null` if the parameters are invalid. Otherwise returns a list of
/// exactly 3 elements:
- /// 1. the result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful read.
+ /// 1. the result integer, encoded as specified in [MojoConstants]. In
+ /// particular, [MojoConstants.kOk] signals a successful creation.
/// 2. the number of bytes read (or bytes available if the message couldn't
/// be read).
/// 3. the number of handles read (or handles available if the message
/// couldn't be read).
///
/// If no message is available, the result-integer is set to
- /// [MojoResult.kShouldWait].
+ /// [MojoConstants.kShouldWait].
///
/// The [handleToken] is a token that identifies the Mojo handle.
///
@@ -246,7 +249,7 @@ class MojoMessagePipeNatives {
/// pipe or discarded (see the description of [flags] below).
///
/// If the message wasn't read because [data] or [handleTokens] was too small,
- /// the result integer is set to [MojoResult.kResourceExhausted].
+ /// the result integer is set to [MojoConstants.kResourceExhausted].
///
/// The returned list *always* contains the size of the message (independent
/// if it was actually read into [data] and [handleTokens]).
@@ -254,9 +257,8 @@ class MojoMessagePipeNatives {
/// [data] and [handleTokens] set to `null` to query the size of the next
/// message that is in the pipe.
///
- /// The parameter [flags] may set to either
- /// [MojoMessagePipeEndpoint.READ_FLAG_NONE] (equal to 0) or
- /// [MojoMessagePipeEndpoint.READ_FLAG_MAY_DISCARD] (equal to 1). In the
+ /// The parameter [flags] may set to either [MojoConstants.kNone] or
+ /// [MojoConstants.kMayDiscard]. In the
/// latter case messages that couldn't be read (for example, because the
/// [data] or [handleTokens] wasn't big enough) are discarded.
static List MojoReadMessage(int handleToken, ByteData data, int numBytes,
@@ -268,8 +270,8 @@ class MojoMessagePipeNatives {
/// a length of at least 5.
///
/// The elements in [result] are:
- /// 1. the result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful read. This value is
+ /// 1. the result integer, encoded as specified in [MojoConstants]. In
+ /// particular, [MojoConstants.kOk] signals a successful read. This value is
/// only used as output.
/// 2. the [ByteData] data array. This entry is used both as input and output.
/// If the array is non-null and big enough it is used to store the
@@ -284,10 +286,9 @@ class MojoMessagePipeNatives {
///
/// The [handleToken] is a token that identifies the Mojo handle.
///
- /// The parameter [flags] may set to either
- /// [MojoMessagePipeEndpoint.READ_FLAG_NONE] (equal to 0) or
- /// [MojoMessagePipeEndpoint.READ_FLAG_MAY_DISCARD] (equal to 1). In the
- /// latter case messages that couldn't be read are discarded.
+ /// The parameter [flags] may set to either [MojoConstants.kNone] or
+ /// [MojoConstants.kMayDiscard]. In the latter case messages that couldn't be
+ /// read are discarded.
///
/// Also see [MojoReadMessage].
static void MojoQueryAndReadMessage(int handleToken, int flags, List result)
@@ -299,31 +300,31 @@ class MojoDataPipeNatives {
/// (handles).
///
/// Returns a list with exactly 3 elements:
- /// 1. the result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful creation.
+ /// 1. the result integer, encoded as specified in [MojoConstants]. In
+ /// particular, [MojoConstants.kOk] signals a successful creation.
/// 2. the producer endpoint. A handle token.
/// 3. the consumer endpoint. A handle token.
///
/// The parameter [elementBytes] specifies the size of an element in bytes.
/// All transactions and buffers consist of an integral number of elements.
/// The integer [elementBytes] must be non-zero. The default should be
- /// [MojoDataPipe.DEFAULT_ELEMENT_SIZE] (equal to 1).
+ /// [MojoConstants.kDefaultPipeElementSize].
///
/// The parameter [capacityBytes] specifies the capacity of the data-pipe, in
/// bytes. The parameter must be a multiple of [elementBytes]. The data-pipe
/// will always be able to queue *at least* this much data. If [capacityBytes]
/// is set to zero, a system-dependent automatically-calculated capacity is
- /// used. The default should be [MojoDataPipe.DEFAULT_CAPACITY] (equal to 0).
+ /// used. The default should be [MojoConstants.kDefaultPipeCapacity].
///
/// The parameter [flags] is reserved for future use and should currently be
- /// set to [MojoDataPipe.FLAG_NONE] (equal to 0).
+ /// set to [MojoConstants.kNone].
static List MojoCreateDataPipe(int elementBytes, int capacityBytes, int flags)
native "MojoDataPipe_Create";
/// Writes [numBytes] bytes from [data] into the producer handle.
///
- /// Returns an integer, encoding the result as specified in the [MojoResult]
- /// class. In particular, a successful operation returns [MojoResult.kOk].
+ /// Returns an integer, encoding the result as specified in [MojoConstants].
+ /// In particular, a successful operation returns [MojoConstants.kOk].
///
/// The argument [handleToken] must be a producer handle created through
/// [MojoCreateDataPipe].
@@ -332,24 +333,24 @@ class MojoDataPipeNatives {
/// element size.
///
/// The argument [flags] can be
- /// - [MojoDataPipeProducer.FLAG_NONE] (equal to 0), or
- /// - [MojoDataPipeProducer.FLAG_ALL_OR_NONE] (equal to 1).
+ /// - [MojoConstants.kNone], or
+ /// - [MojoConstants.kAllOrNone].
///
- /// If [flags] is equal to [MojoDataPipeProducer.FLAG_ALL_OR_NONE], then
+ /// If [flags] is equal to [MojoConstants.kAllOrNone], then
/// either all data is written, or none is. If the data can't be written, then
- /// the result integer is set to [MojoResult.kOutOfRange].
+ /// the result integer is set to [MojoConstants.kOutOfRange].
///
/// If no data can currently be written to an open consumer (and [flags] is
- /// *not* set to [MojoDataPipeProducer.FLAG_ALL_OR_NONE]), then the
- /// result-integer is set to [MojoResult.kShouldWait].
+ /// *not* set to [MojoConstants.kAllOrNone]), then the result integer is set
+ /// to [MojoConstants.kShouldWait].
static List MojoWriteData(int handle, ByteData data, int numBytes, int flags)
native "MojoDataPipe_WriteData";
/// Starts a two-phase write.
///
/// Returns a List of exactly 2 elements:
- /// 1. the result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful operation.
+ /// 1. the result integer, encoded as specified in [MojoConstants]. In
+ /// particular, [MojoConstants.kOk] signals a successful write.
/// 2. a [ByteData] object (when successful), or `null` (if unsuccessful).
///
/// The argument [handleToken] must be a producer handle created through
@@ -363,22 +364,22 @@ class MojoDataPipeNatives {
/// data pipe is set to non-writable.
///
/// A two-phase write is only started if the result integer (the first
- /// argument of the returned list) is equal to [MojoResult.kOk]. Otherwise,
+ /// argument of the returned list) is equal to [MojoConstants.kOk]. Otherwise,
/// the underlying pipe stays writable (assuming it was before), and does not
/// expect a call to [MojoEndWriteData].
///
- /// The result integer is equal to [MojoResult.kBusy] if the pipe is already
- /// executing a two-phase write.
+ /// The result integer is equal to [MojoConstants.kBusy] if the pipe is
+ /// already executing a two-phase write.
///
/// The parameter [flags] is reserved for future use and should currently be
- /// set to [MojoDataPipeProducer.FLAG_NONE] (equal to 0).
+ /// set to [MojoConstants.kNone].
static List MojoBeginWriteData(int handleToken, int flags)
native "MojoDataPipe_BeginWriteData";
/// Finishes a two-phase write.
///
- /// Returns a result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful operation.
+ /// Returns an integer, encoding the result as specified in [MojoConstants].
+ /// In particular, a successful operation returns [MojoConstants.kOk].
///
/// The argument [handleToken] must be a producer handle created through
/// [MojoCreateDataPipe] and must be the same that was given to a previous
@@ -394,8 +395,8 @@ class MojoDataPipeNatives {
/// Reads up to [numBytes] from the given consumer [handleToken].
///
/// Returns a list of exactly two elements:
- /// 1. the result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful operation.
+ /// 1. the result integer, encoded as specified in [MojoConstants]. In
+ /// particular, [MojoConstants.kOk] signals a successful operation.
/// 2. an integer `readBytes` (having different semantics depending on the
/// flags. See below for the different cases.
///
@@ -405,30 +406,30 @@ class MojoDataPipeNatives {
/// The argument [numBytes] must be a multiple of the data pipe's element
/// size.
///
- /// If [flags] has neither [MojoDataPipeConsumer.FLAG_DISCARD] (equal to 2),
- /// nor [MojoDataPipeConsumer.FLAG_QUERY] (equal to 4) set, tries to read up
+ /// If [flags] has neither [MojoConstants.kDiscard], nor
+ /// [MojoConstants.kQuery] set, tries to read up
/// to [numBytes] bytes of data into the [data] buffer and set
/// `readBytes` (the second element of the returned list) to the amount
/// actually read.
///
- /// If [flags] has [MojoDataPipeConsumer.FLAG_ALL_OR_NONE] (equal to 1) set,
- /// either reads exactly [numBytes] bytes of data or none. Additionally, if
- /// [flags] has [MojoDataPipeConsumer.FLAG_PEEK] (equal to 8) set, the data
+ /// If [flags] has [MojoConstants.kAllOrNone] set, either reads exactly
+ /// [numBytes] bytes of data or none. Additionally, if
+ /// [flags] has [MojoConstants.kPeek] set, the data
/// read remains in the pipe and is available to future reads.
///
- /// If [flags] has [MojoDataPipeConsumer.FLAG_DISCARD] (equal to 2) set, it
+ /// If [flags] has [MojoConstants.kDiscard] set, it
/// discards up to [numBytes] (which again must be a multiple of the element
/// size) bytes of data, setting `readBytes` to the amount actually
- /// discarded. If [flags] has [MojoDataPipeConsumer.FLAG_ALL_OR_NONE] (equal
- /// to 1), either discards exactly [numBytes] bytes of data or none. In this
- /// case, [MojoDataPipeConsumer.FLAG_QUERY] must not be set, and
+ /// discarded. If [flags] has [MojoConstants.kAllOrNone]
+ /// either discards exactly [numBytes] bytes of data or none. In this
+ /// case, [MojoConstants.kQuery] must not be set, and
/// the [data] buffer is ignored (and should typically be set to
/// null).
///
- /// If flags has [MojoDataPipeConsumer.FLAG_QUERY] set, queries the amount of
+ /// If flags has [MojoConstants.kQuery] set, queries the amount of
/// data available, setting `readBytes` to the number of bytes available. In
- /// this case, [MojoDataPipeConsumer.FLAG_DISCARD] must not be set, and
- /// [MojoDataPipeConsumer.FLAG_ALL_OR_NONE] is ignored, as are [data] and
+ /// this case, [MojoConstants.kDiscard] must not be set, and
+ /// [MojoConstants.kAllOrNone] is ignored, as are [data] and
/// [numBytes].
static List MojoReadData(int handleToken, ByteData data, int numBytes,
int flags) native "MojoDataPipe_ReadData";
@@ -436,8 +437,8 @@ class MojoDataPipeNatives {
/// Starts a two-phase read.
///
/// Returns a List of exactly 2 elements:
- /// 1. the result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful operation.
+ /// 1. the result integer, encoded as specified in [MojoConstants]. In
+ /// particular, [MojoConstants.kOk] signals a successful operation.
/// 2. a [ByteData] object (when successful), or `null` (if unsuccessful).
///
/// The argument [handleToken] must be a consumer handle created through
@@ -451,25 +452,25 @@ class MojoDataPipeNatives {
/// data pipe is set to non-readable.
///
/// A two-phase read is only started if the result integer (the first
- /// argument of the returned list) is equal to [MojoResult.kOk]. Otherwise,
+ /// argument of the returned list) is equal to [MojoConstants.kOk]. Otherwise,
/// the underlying pipe stays readable (assuming it was before), and does not
/// expect a call to [MojoEndReadData].
///
- /// The result integer is equal to [MojoResult.kBusy] if the pipe is already
- /// executing a two-phase read.
+ /// The result integer is equal to [MojoConstants.kBusy] if the pipe is
+ /// already executing a two-phase read.
///
- /// The result integer is equal to [MojoResult.kShouldWait] if the pipe has
+ /// The result integer is equal to [MojoConstants.kShouldWait] if the pipe has
/// no data available.
///
/// The parameter [flags] is reserved for future use and should currently be
- /// set to [MojoDataPipeConsumer.FLAG_NONE] (equal to 0).
+ /// set to [MojoConstants.kNone].
static List MojoBeginReadData(int handleToken, int flags)
native "MojoDataPipe_BeginReadData";
/// Finishes a two-phase read.
///
- /// Returns a result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful operation.
+ /// Returns an integer, encoding the result as specified in [MojoConstants].
+ /// In particular, a successful operation returns [MojoConstants.kOk].
///
/// The argument [handleToken] must be a consumer handle created through
/// [MojoCreateDataPipe] and must be the same that was given to a previous
@@ -487,8 +488,8 @@ class MojoSharedBufferNatives {
/// Creates a shared buffer of [numBytes] bytes.
///
/// Returns a List of exactly 2 elements:
- /// 1. the result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful operation.
+ /// 1. the result integer, encoded as specified in [MojoConstants]. In
+ /// particular, [MojoConstants.kOk] signals a successful creation.
/// 2. a handle.
///
/// A shared buffer can be shared between applications (by duplicating the
@@ -497,15 +498,15 @@ class MojoSharedBufferNatives {
/// A shared buffer can be accessed through by invoking [Map].
///
/// The parameter [flags] is reserved for future use and should currently be
- /// set to [MojoSharedBuffer.createFlagNone] (equal to 0).
+ /// set to [MojoConstants.kNone].
static List Create(int numBytes, int flags) native "MojoSharedBuffer_Create";
/// Duplicates the given [bufferHandleToken] so that it can be shared through
/// a message pipe.
///
/// Returns a list of exactly 2 elements:
- /// 1. the result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful operation.
+ /// 1. the result integer, encoded as specified in [MojoConstants]. In
+ /// particular, [MojoConstants.kOk] signals a successful operation.
/// 2. the duplicated handle.
///
/// The [bufferHandleToken] must be a handle created by [Create].
@@ -516,7 +517,7 @@ class MojoSharedBufferNatives {
/// have).
///
/// The parameter [flags] is reserved for future use and should currently be
- /// set to [MojoSharedBuffer.duplicateFlagNone] (equal to 0).
+ /// set to [MojoConstants.kNone].
static List Duplicate(int bufferHandleToken, int flags)
native "MojoSharedBuffer_Duplicate";
@@ -524,8 +525,8 @@ class MojoSharedBufferNatives {
/// a [ByteData] buffer.
///
/// Returns a list of exactly 2 elements:
- /// 1. the result integer, encoded as specified in [MojoResult]. In
- /// particular, [MojoResult.kOk] signals a successful operation.
+ /// 1. the result integer, encoded as specified in [MojoConstants]. In
+ /// particular, [MojoConstants.kOk] signals a successful operation.
/// 2. a [ByteData] buffer that maps to the data in the shared buffer.
///
/// The [bufferHandleToken] must be a handle created by [Create].
@@ -537,7 +538,7 @@ class MojoSharedBufferNatives {
/// finalizers.
///
/// The parameter [flags] is reserved for future use and should currently be
- /// set to [MojoSharedBuffer.mapFlagNone] (equal to 0).
+ /// set to [MojoConstants.kNone].
static List Map(int bufferHandleToken, int offset, int numBytes, int flags)
native "MojoSharedBuffer_Map";
}
« no previous file with comments | « mojo/dart/packages/mojo/sdk_ext/src/handle_watcher.dart ('k') | mojo/dart/packages/mojo/sdk_ext_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698