| 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 1ce098239cec317e1093c564d98eb7a319e1f890..6695f07a3353a0cc088cc65de311b5f1a6db452e 100644
|
| --- a/third_party/mojo/src/mojo/public/dart/src/stub.dart
|
| +++ b/third_party/mojo/src/mojo/public/dart/src/stub.dart
|
| @@ -7,8 +7,10 @@ part of bindings;
|
| abstract class Stub extends core.MojoEventStreamListener {
|
| int _outstandingResponseFutures = 0;
|
| bool _isClosing = false;
|
| + Completer _closeCompleter;
|
|
|
| - Stub(core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
|
| + Stub.fromEndpoint(core.MojoMessagePipeEndpoint endpoint)
|
| + : super.fromEndpoint(endpoint);
|
|
|
| Stub.fromHandle(core.MojoHandle handle) : super.fromHandle(handle);
|
|
|
| @@ -41,9 +43,7 @@ abstract class Stub extends core.MojoEventStreamListener {
|
| _outstandingResponseFutures--;
|
| if (isOpen) {
|
| endpoint.write(
|
| - response.buffer,
|
| - response.buffer.lengthInBytes,
|
| - response.handles);
|
| + response.buffer, response.buffer.lengthInBytes, response.handles);
|
| if (!endpoint.status.isOk) {
|
| throw 'message pipe write failed: ${endpoint.status}';
|
| }
|
| @@ -52,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;
|
| }
|
| }
|
| });
|
| @@ -60,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;
|
| }
|
| }
|
|
|
| @@ -70,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))) {
|
| @@ -79,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();
|
| }
|
| }
|
|
|
| @@ -93,4 +99,9 @@ abstract class Stub extends core.MojoEventStreamListener {
|
| var header = new MessageHeader.withRequestId(name, flags, id);
|
| return response.serializeWithHeader(header);
|
| }
|
| +
|
| + String toString() {
|
| + var superString = super.toString();
|
| + return "Stub(${superString})";
|
| + }
|
| }
|
|
|