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..18637c1d13abbd25a2a36c9c9e0a8bac53ce805c 100644 |
--- a/mojo/public/cpp/bindings/binding.h |
+++ b/mojo/public/cpp/bindings/binding.h |
@@ -156,6 +156,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 +183,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(); |
} |