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

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

Issue 996923003: Dart: Better handle leak checks. close() is async. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge 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: mojo/public/dart/src/stub.dart
diff --git a/mojo/public/dart/src/stub.dart b/mojo/public/dart/src/stub.dart
index eb926a518eabaceaff47e7e56c54f6c1eb990912..6695f07a3353a0cc088cc65de311b5f1a6db452e 100644
--- a/mojo/public/dart/src/stub.dart
+++ b/mojo/public/dart/src/stub.dart
@@ -7,6 +7,7 @@ part of bindings;
abstract class Stub extends core.MojoEventStreamListener {
int _outstandingResponseFutures = 0;
bool _isClosing = false;
+ Completer _closeCompleter;
Stub.fromEndpoint(core.MojoMessagePipeEndpoint endpoint)
: super.fromEndpoint(endpoint);
@@ -51,6 +52,8 @@ abstract class Stub extends core.MojoEventStreamListener {
// a response. It is safe to close.
super.close();
_isClosing = false;
+ _closeCompleter.complete(null);
+ _closeCompleter = null;
}
}
});
@@ -59,6 +62,8 @@ abstract class Stub extends core.MojoEventStreamListener {
// there are no outstanding response futures. Do the close now.
super.close();
_isClosing = false;
+ _closeCompleter.complete(null);
+ _closeCompleter = null;
}
}
@@ -69,7 +74,7 @@ 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.
- void close({bool nodefer: false}) {
+ Future close({bool nodefer: false}) {
if (isOpen &&
!nodefer &&
(isInHandler || (_outstandingResponseFutures > 0))) {
@@ -78,8 +83,10 @@ abstract class Stub extends core.MojoEventStreamListener {
// response futures. Defer the actual close until all response futures
// have been resolved.
_isClosing = true;
+ _closeCompleter = new Completer();
+ return _closeCompleter.future;
} else {
- super.close();
+ return super.close();
}
}

Powered by Google App Engine
This is Rietveld 408576698