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

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

Issue 1060193002: Provide mechanism to close immediately to Dart bindings (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 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: mojo/public/dart/src/stub.dart
diff --git a/mojo/public/dart/src/stub.dart b/mojo/public/dart/src/stub.dart
index 9008f55e2abef06c557c58a739ac85b8a8d5c697..c932584b2655f0fbc33bbf33fbd07608a114ec9d 100644
--- a/mojo/public/dart/src/stub.dart
+++ b/mojo/public/dart/src/stub.dart
@@ -52,9 +52,11 @@ abstract class Stub extends core.MojoEventStreamListener {
// This was the final response future for which we needed to send
// a response. It is safe to close.
super.close().then((_) {
- _isClosing = false;
- _closeCompleter.complete(null);
- _closeCompleter = null;
+ if (_isClosing) {
zra 2015/04/07 19:49:46 Was this code running when _isClosing was already
Cutch 2015/04/07 19:52:13 Yes, the then clause on line 98 could sometimes ru
+ _isClosing = false;
+ _closeCompleter.complete(null);
+ _closeCompleter = null;
+ }
});
}
}
@@ -63,9 +65,11 @@ abstract class Stub extends core.MojoEventStreamListener {
// 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().then((_) {
- _isClosing = false;
- _closeCompleter.complete(null);
- _closeCompleter = null;
+ if (_isClosing) {
+ _isClosing = false;
+ _closeCompleter.complete(null);
+ _closeCompleter = null;
+ }
});
}
}
@@ -74,13 +78,13 @@ abstract class Stub extends core.MojoEventStreamListener {
throw 'Unexpected write signal in client.';
}
- // NB: |nodefer| should only be true when calling close() while handling an
+ // NB: |immediate| should only be true when calling close() while handling an
// exception thrown from handleRead(), e.g. when we receive a malformed
// message, or when we have received the PEER_CLOSED event.
@override
- Future close({bool nodefer: false}) {
+ Future close({bool immediate: false}) {
if (isOpen &&
- !nodefer &&
+ !immediate &&
(isInHandler || (_outstandingResponseFutures > 0))) {
// Either close() is being called from within handleRead() or
// handleWrite(), or close() is being called while there are outstanding
@@ -90,7 +94,7 @@ abstract class Stub extends core.MojoEventStreamListener {
_closeCompleter = new Completer();
return _closeCompleter.future;
} else {
- return super.close(nodefer: nodefer).then((_) {
+ return super.close(immediate: immediate).then((_) {
if (_isClosing) {
_isClosing = false;
_closeCompleter.complete(null);

Powered by Google App Engine
This is Rietveld 408576698