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

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: Adds close() notification to Stub when Binding is closed or deleted. 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/tools/bindings/generators/cpp_templates/interface_definition.tmpl » ('j') | no next file with comments »
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..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();
}
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698