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

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

Issue 1405103002: Dart: Merge message pipe query and read into one native call. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 2 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
« 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..68ed35bb8b22da9e398838b944d7b262b5061963 100644
--- a/mojo/public/dart/mojo/lib/src/message_pipe.dart
+++ b/mojo/public/dart/mojo/lib/src/message_pipe.dart
@@ -19,6 +19,28 @@ class MojoMessagePipeReadResult {
}
}
+class MojoMessagePipeQueryAndReadResult {
+ MojoResult status;
+ ByteData bytesRead;
+ List<MojoHandle> handlesRead;
+
+ MojoMessagePipeQueryAndReadResult.fromList(List result) {
+ status = new MojoResult(result[0]);
+ bytesRead = result[1];
+ if (result[2] != null) {
+ handlesRead = new List<MojoHandle>(result[2].length);
+ for (int i = 0; i < handlesRead.length; i++) {
+ handlesRead[i] = new MojoHandle(result[2][i]);
+ }
+ }
+ }
+
+ String toString() {
+ return "MojoMessagePipeQueryAndReadResult("
+ "status: $status, bytesRead: $bytesRead, handlesRead: $handlesRead)";
+ }
+}
+
class MojoMessagePipeEndpoint {
static const int WRITE_FLAG_NONE = 0;
static const int READ_FLAG_NONE = 0;
@@ -109,6 +131,26 @@ class MojoMessagePipeEndpoint {
MojoMessagePipeReadResult query() => read(null);
+ MojoMessagePipeQueryAndReadResult queryAndRead([int flags = 0]) {
+ if (handle == null) {
+ status = MojoResult.INVALID_ARGUMENT;
+ return null;
+ }
+
+ List result =
+ MojoMessagePipeNatives.MojoQueryAndReadMessage(handle.h, flags);
+ if (result == null) {
+ status = MojoResult.INVALID_ARGUMENT;
+ return null;
+ }
+ assert((result is List) && (result.length == 3));
+
+ var readResult = new MojoMessagePipeQueryAndReadResult.fromList(result);
+
+ status = readResult.status;
+ return readResult;
+ }
+
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