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

Unified Diff: mojo/public/dart/mojo/lib/src/stub.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/proxy.dart ('k') | mojo/public/dart/mojo/sdk_ext/src/natives.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/stub.dart
diff --git a/mojo/public/dart/mojo/lib/src/stub.dart b/mojo/public/dart/mojo/lib/src/stub.dart
index 4957dd9702a7a737e1266837a4ba326466368d04..7ea00593e1f318f7a5b8e9899e5e6482831f0eaf 100644
--- a/mojo/public/dart/mojo/lib/src/stub.dart
+++ b/mojo/public/dart/mojo/lib/src/stub.dart
@@ -19,27 +19,22 @@ abstract class Stub extends core.MojoEventStreamListener {
dynamic handleMessage(ServiceMessage message);
void handleRead() {
- // Query how many bytes are available.
- var result = endpoint.query();
- assert(result.status.isOk || result.status.isResourceExhausted);
- if (result.bytesRead == 0) {
- throw new MojoCodecError('Unexpected empty message: $this');
+ var result = endpoint.queryAndRead();
+ if ((result.bytesRead == null) || (result.bytesRead.length == 0)) {
+ throw new MojoCodecError('Unexpected empty message or error: $result');
}
- // Read the data and view as a message.
- 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);
-
// Prepare the response.
var message;
var response;
try {
- message = new ServiceMessage.fromMessage(new Message(bytes, handles));
+ message = new ServiceMessage.fromMessage(
+ new Message(result.bytesRead, result.handlesRead));
response = _isClosing ? null : handleMessage(message);
} catch (e) {
- handles.forEach((h) => h.close());
+ if (result.handlesRead != null) {
+ result.handlesRead.forEach((h) => h.close());
+ }
rethrow;
}
« no previous file with comments | « mojo/public/dart/mojo/lib/src/proxy.dart ('k') | mojo/public/dart/mojo/sdk_ext/src/natives.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698