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

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

Issue 1029113005: Update mojo sdk to rev cb6c5abfadfea0ca73dca466e2894554ac1ae144 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 5 years, 9 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 6695f07a3353a0cc088cc65de311b5f1a6db452e..9008f55e2abef06c557c58a739ac85b8a8d5c697 100644
--- a/third_party/mojo/src/mojo/public/dart/src/stub.dart
+++ b/third_party/mojo/src/mojo/public/dart/src/stub.dart
@@ -44,26 +44,29 @@ abstract class Stub extends core.MojoEventStreamListener {
if (isOpen) {
endpoint.write(
response.buffer, response.buffer.lengthInBytes, response.handles);
- if (!endpoint.status.isOk) {
- throw 'message pipe write failed: ${endpoint.status}';
- }
+ // FailedPrecondition is only used to indicate that the other end of
+ // the pipe has been closed. We can ignore the close here and wait for
+ // the PeerClosed signal on the event stream.
+ assert(endpoint.status.isOk || endpoint.status.isFailedPrecondition);
if (_isClosing && (_outstandingResponseFutures == 0)) {
// This was the final response future for which we needed to send
// a response. It is safe to close.
- super.close();
- _isClosing = false;
- _closeCompleter.complete(null);
- _closeCompleter = null;
+ super.close().then((_) {
+ _isClosing = false;
+ _closeCompleter.complete(null);
+ _closeCompleter = null;
+ });
}
}
});
} else if (_isClosing && (_outstandingResponseFutures == 0)) {
// We are closing, there is no response to send for this message, and
// there are no outstanding response futures. Do the close now.
- super.close();
- _isClosing = false;
- _closeCompleter.complete(null);
- _closeCompleter = null;
+ super.close().then((_) {
+ _isClosing = false;
+ _closeCompleter.complete(null);
+ _closeCompleter = null;
+ });
}
}
@@ -73,7 +76,8 @@ abstract class Stub extends core.MojoEventStreamListener {
// NB: |nodefer| should only be true when calling close() while handling an
// exception thrown from handleRead(), e.g. when we receive a malformed
- // message.
+ // message, or when we have received the PEER_CLOSED event.
+ @override
Future close({bool nodefer: false}) {
if (isOpen &&
!nodefer &&
@@ -86,7 +90,13 @@ abstract class Stub extends core.MojoEventStreamListener {
_closeCompleter = new Completer();
return _closeCompleter.future;
} else {
- return super.close();
+ return super.close(nodefer: nodefer).then((_) {
+ if (_isClosing) {
+ _isClosing = false;
+ _closeCompleter.complete(null);
+ _closeCompleter = null;
+ }
+ });
}
}

Powered by Google App Engine
This is Rietveld 408576698