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

Unified Diff: mojo/public/dart/mojo/lib/src/message_pipe.dart

Issue 1415253008: Dart: Merge message pipe query and read into one native call (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Format 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/message.dart ('k') | mojo/public/dart/mojo/lib/src/proxy.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/message_pipe.dart
diff --git a/mojo/public/dart/mojo/lib/src/message_pipe.dart b/mojo/public/dart/mojo/lib/src/message_pipe.dart
index 62c7cb3a88bc6aa7f40bfd9fe09f2b547c2fffd9..0a4805f94bdf4ac9fd0d9a42d15bc3f12d1e97a1 100644
--- a/mojo/public/dart/mojo/lib/src/message_pipe.dart
+++ b/mojo/public/dart/mojo/lib/src/message_pipe.dart
@@ -19,11 +19,46 @@ class MojoMessagePipeReadResult {
}
}
+class MojoMessagePipeQueryAndReadState {
+ static final List _result = new List(5);
+
+ List<MojoHandle> _handles;
+
+ MojoResult get status => new MojoResult(_result[0]);
+ ByteData get data => _result[1];
+ List<MojoHandle> get handles => _handles;
+ int get dataLength => _result[3];
+ int get handlesLength => _result[4];
+
+ MojoMessagePipeQueryAndReadState();
+
+ void queryAndRead(int handle, int flags) {
+ MojoMessagePipeNatives.MojoQueryAndReadMessage(handle, flags, _result);
+
+ if (handlesLength == 0) {
+ _handles = null;
+ } else {
+ _handles = new List(handlesLength);
+ for (int i = 0; i < handlesLength; i++) {
+ _handles[i] = new MojoHandle(_result[2][i]);
+ }
+ }
+ }
+
+ String toString() {
+ return "MojoMessagePipeQueryAndReadState("
+ "status: $status, dataLength: $dataLength, "
+ "handlesLength: $handlesLength)";
+ }
+}
+
class MojoMessagePipeEndpoint {
static const int WRITE_FLAG_NONE = 0;
static const int READ_FLAG_NONE = 0;
static const int READ_FLAG_MAY_DISCARD = 1 << 0;
+ static final _queryAndReadState = new MojoMessagePipeQueryAndReadState();
+
MojoHandle handle;
MojoResult status;
@@ -109,6 +144,20 @@ class MojoMessagePipeEndpoint {
MojoMessagePipeReadResult query() => read(null);
+ /// Warning: The object returned by this function, and the buffers inside of
+ /// it are only valid until the next call to this function by the same
+ /// isolate.
+ MojoMessagePipeQueryAndReadState queryAndRead([int flags = 0]) {
+ if (handle == null) {
+ status = MojoResult.INVALID_ARGUMENT;
+ return null;
+ }
+
+ _queryAndReadState.queryAndRead(handle.h, flags);
+ status = _queryAndReadState.status;
+ return _queryAndReadState;
+ }
+
bool setDescription(String description) {
assert(MojoHandle._setHandleLeakDescription(handle, description));
return true;
« no previous file with comments | « mojo/public/dart/mojo/lib/src/message.dart ('k') | mojo/public/dart/mojo/lib/src/proxy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698