Chromium Code Reviews| 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..faff0375c25467b60f807b3451aba180d63b2d76 100644 |
| --- a/mojo/public/dart/mojo/lib/src/message_pipe.dart |
| +++ b/mojo/public/dart/mojo/lib/src/message_pipe.dart |
| @@ -19,11 +19,59 @@ class MojoMessagePipeReadResult { |
| } |
| } |
| +class MojoMessagePipeQueryAndReadState { |
| + static ByteData _data; |
| + static Uint32List _rawHandles; |
| + static final List _result = new List(5); |
| + |
| + MojoResult _status; |
| + List<MojoHandle> _handles; |
| + int _dataLength; |
| + int _handlesLength; |
| + |
| + MojoResult get status => _status; |
| + List<MojoHandle> get handles => _handles; |
| + int get dataLength => _dataLength; |
| + int get handlesLength => _handlesLength; |
| + ByteData get data => _data; |
| + |
| + MojoMessagePipeQueryAndReadState() |
| + : _dataLength = 0, |
| + _handlesLength = 0; |
| + |
| + void queryAndRead(int handle, int flags) { |
| + MojoMessagePipeNatives.MojoQueryAndReadMessage( |
| + handle, flags, _data, _rawHandles, _result); |
| + _status = new MojoResult(_result[0]); |
|
Cutch
2015/11/06 21:59:15
I wonder if we could just keep _data, etc in the _
zra
2015/11/06 23:35:42
Done.
|
| + _data = _result[1]; |
| + _rawHandles = _result[2]; |
| + _dataLength = _result[3]; |
| + _handlesLength = _result[4]; |
| + |
| + if (_handlesLength == 0) { |
| + _handles = null; |
| + } else { |
| + _handles = new List(_handlesLength); |
| + for (int i = 0; i < _handlesLength; i++) { |
| + _handles[i] = new MojoHandle(_rawHandles[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 +157,19 @@ 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. |
|
Cutch
2015/11/06 21:59:15
Make this a doc comment.
zra
2015/11/06 23:35:42
Done.
|
| + 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; |