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

Unified Diff: mojo/public/dart/mojo/lib/src/proxy.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_pipe.dart ('k') | mojo/public/dart/mojo/lib/src/stub.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/proxy.dart
diff --git a/mojo/public/dart/mojo/lib/src/proxy.dart b/mojo/public/dart/mojo/lib/src/proxy.dart
index db8065ee3a3c4edd3534900598f1a8262c7a9f72..0b0f60c37c282a84c7982ec8efd55f3eb6059ed8 100644
--- a/mojo/public/dart/mojo/lib/src/proxy.dart
+++ b/mojo/public/dart/mojo/lib/src/proxy.dart
@@ -34,16 +34,12 @@ abstract class Proxy extends core.MojoEventStreamListener {
void handleResponse(ServiceMessage reader);
void handleRead() {
- // Query how many bytes are available.
- var result = endpoint.query();
- assert(result.status.isOk || result.status.isResourceExhausted);
-
- // Read the data.
- var bytes = new ByteData(result.bytesRead);
- var handles = new List<core.MojoHandle>(result.handlesRead);
- result = endpoint.read(bytes, result.bytesRead, handles);
- assert(result.status.isOk || result.status.isResourceExhausted);
- var message = new ServiceMessage.fromMessage(new Message(bytes, handles));
+ var result = endpoint.queryAndRead();
+ if ((result.bytesRead == null) || (result.bytesRead.length == 0)) {
+ throw new MojoCodecError('Unexpected empty message or error: $result');
+ }
+ var message = new ServiceMessage.fromMessage(
+ new Message(result.bytesRead, result.handlesRead));
if (ControlMessageHandler.isControlMessage(message)) {
_handleControlMessageResponse(message);
return;
« no previous file with comments | « mojo/public/dart/mojo/lib/src/message_pipe.dart ('k') | mojo/public/dart/mojo/lib/src/stub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698