Index: mojo/public/cpp/bindings/binding.h |
diff --git a/mojo/public/cpp/bindings/binding.h b/mojo/public/cpp/bindings/binding.h |
index a982bdbd4b10642837f8e1306253f0832f43e95b..97508faafb9c9ade492bc42e8dbdbc37d91e799f 100644 |
--- a/mojo/public/cpp/bindings/binding.h |
+++ b/mojo/public/cpp/bindings/binding.h |
@@ -100,6 +100,7 @@ class Binding : public ErrorHandler { |
// Tears down the binding, closing the message pipe and leaving the interface |
// implementation unbound. |
~Binding() override { |
+ stub_.Close(); |
rudominer
2015/03/13 23:52:36
I was confused here. Closing the stub here makes l
|
if (internal_router_) { |
Close(); |
} |
@@ -156,6 +157,7 @@ class Binding : public ErrorHandler { |
// Closes the message pipe that was previously bound. Put this object into a |
// state where it can be rebound to a new pipe. |
void Close() { |
+ stub_.Close(); |
MOJO_DCHECK(internal_router_); |
internal_router_->CloseMessagePipe(); |
DestroyRouter(); |
@@ -182,6 +184,13 @@ class Binding : public ErrorHandler { |
// Implements the |Binding|'s response to a connection error. |
void OnConnectionError() override { |
+ // Note that it is important that we tell |stub_| that there was a |
+ // connection error before we tell |error_handler_|. This is because |
+ // in response |error_handler_| may destroy a Callback that hasn't been |
+ // run and this will cause |stub_| to DCHECK unless it also knows that |
+ // this happened for a legitimate reason, namely that a connection error |
+ // occurred. |
+ stub_.OnConnectionError(); |
if (error_handler_) |
error_handler_->OnConnectionError(); |
} |