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; |