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

Unified Diff: third_party/mojo/src/mojo/public/dart/src/stub.dart

Issue 901843003: Update mojo sdk to rev 8d45c89c30b230843c5bd6dd0693a555750946c0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Partial revert of https://codereview.chromium.org/899993002/ Created 5 years, 10 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
Index: third_party/mojo/src/mojo/public/dart/src/stub.dart
diff --git a/third_party/mojo/src/mojo/public/dart/src/stub.dart b/third_party/mojo/src/mojo/public/dart/src/stub.dart
index b4ab2930a48d161492814382a8aa6d99ebaf5d48..823873627ec267adaa25db536f4e036bca2990dd 100644
--- a/third_party/mojo/src/mojo/public/dart/src/stub.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/stub.dart
@@ -20,6 +20,9 @@ abstract class Stub extends core.MojoEventStreamListener {
// 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.');
+ }
// Read the data and view as a message.
var bytes = new ByteData(result.bytesRead);
@@ -41,7 +44,7 @@ abstract class Stub extends core.MojoEventStreamListener {
response.buffer.lengthInBytes,
response.handles);
if (!endpoint.status.isOk) {
- throw "message pipe write failed: ${endpoint.status}";
+ throw 'message pipe write failed: ${endpoint.status}';
}
if (_isClosing && (_outstandingResponseFutures == 0)) {
// This was the final response future for which we needed to send
@@ -63,9 +66,12 @@ abstract class Stub extends core.MojoEventStreamListener {
throw 'Unexpected write signal in client.';
}
- void close() {
+ // NB: |nodefer| should only be true when calling close() while handling an
+ // exception thrown from handleRead(), e.g. when we receive a malformed
+ // message.
+ void close({bool nodefer : false}) {
if (!isOpen) return;
- if (isInHandler || (_outstandingResponseFutures > 0)) {
+ if (!nodefer && (isInHandler || (_outstandingResponseFutures > 0))) {
// Either close() is being called from within handleRead() or
// handleWrite(), or close() is being called while there are outstanding
// response futures. Defer the actual close until all response futures

Powered by Google App Engine
This is Rietveld 408576698