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

Unified Diff: mojo/public/dart/mojo/lib/src/proxy.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: add cast 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
Index: mojo/public/dart/mojo/lib/src/proxy.dart
diff --git a/mojo/public/dart/mojo/lib/src/proxy.dart b/mojo/public/dart/mojo/lib/src/proxy.dart
index e6e728e7ca37730e842c9bffda5466aad3043430..6de8c28cb18ba9d985ea838220ea6af427a15f2d 100644
--- a/mojo/public/dart/mojo/lib/src/proxy.dart
+++ b/mojo/public/dart/mojo/lib/src/proxy.dart
@@ -36,23 +36,15 @@ abstract class Proxy extends core.MojoEventStreamListener {
int get version => _version;
void handleRead() {
- // Query how many bytes are available.
- var result = endpoint.query();
- if (!result.status.isOk && !result.status.isResourceExhausted) {
- proxyError("Query of message pipe endpoint failed");
- return;
- }
-
- // Read the data.
- var bytes = new ByteData(result.bytesRead);
- var handles = new List<core.MojoHandle>(result.handlesRead);
- result = endpoint.read(bytes, result.bytesRead, handles);
- if (!result.status.isOk && !result.status.isResourceExhausted) {
+ var result = endpoint.queryAndRead();
+ if ((result.data == null) || (result.dataLength == 0)) {
proxyError("Read from message pipe endpoint failed");
return;
}
try {
- var message = new ServiceMessage.fromMessage(new Message(bytes, handles));
+ var message = new ServiceMessage.fromMessage(
+ new Message(result.data, result.handles,
+ result.dataLength, result.handlesLength));
_pendingCount--;
if (ControlMessageHandler.isControlMessage(message)) {
_handleControlMessageResponse(message);

Powered by Google App Engine
This is Rietveld 408576698