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

Unified Diff: mojo/public/cpp/bindings/binding.h

Issue 1003773002: CPP bindings: DCHECK when a Callback is destructed without being invoked (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixed BUILD.gn file. 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
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/tests/BUILD.gn » ('j') | mojo/public/cpp/bindings/tests/BUILD.gn » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/tests/BUILD.gn » ('j') | mojo/public/cpp/bindings/tests/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698