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

Unified Diff: mojo/public/cpp/bindings/lib/router.cc

Issue 2318793002: Mojo C++ bindings: support disconnect with a reason. (Closed)
Patch Set: . Created 4 years, 3 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 | « mojo/public/cpp/bindings/lib/router.h ('k') | mojo/public/cpp/bindings/strong_binding.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/router.cc
diff --git a/mojo/public/cpp/bindings/lib/router.cc b/mojo/public/cpp/bindings/lib/router.cc
index 2c8036849cae5d4d0af8513a7f60897296002cbb..8db5c1bbe4cc1822664d6f663277986ae4a1318c 100644
--- a/mojo/public/cpp/bindings/lib/router.cc
+++ b/mojo/public/cpp/bindings/lib/router.cc
@@ -327,8 +327,16 @@ void Router::OnConnectionError() {
// longer.
async_responders_.clear();
- if (!error_handler_.is_null())
+ if (!error_handler_.is_null()) {
error_handler_.Run();
+ } else if (!error_with_reason_handler_.is_null()) {
+ // Make a copy on the stack. If we directly pass a reference to a member of
+ // |control_message_handler_|, that reference will be invalidated as soon as
+ // the user destroys the interface endpoint.
+ std::string description = control_message_handler_.disconnect_description();
+ error_with_reason_handler_.Run(
+ control_message_handler_.disconnect_custom_reason(), description);
+ }
}
// ----------------------------------------------------------------------------
« no previous file with comments | « mojo/public/cpp/bindings/lib/router.h ('k') | mojo/public/cpp/bindings/strong_binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698