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

Unified Diff: mojo/public/cpp/bindings/lib/interface_endpoint_client.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
Index: mojo/public/cpp/bindings/lib/interface_endpoint_client.cc
diff --git a/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc b/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc
index 0f15398545073e92465b29a7bf217756288238a9..368a521612be364cd18f71bc0f54b4aaea278252 100644
--- a/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc
+++ b/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc
@@ -281,8 +281,16 @@ void InterfaceEndpointClient::NotifyError() {
control_message_proxy_.OnConnectionError();
- 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);
+ }
}
bool InterfaceEndpointClient::HandleValidatedMessage(Message* message) {
« no previous file with comments | « mojo/public/cpp/bindings/lib/control_message_proxy.cc ('k') | mojo/public/cpp/bindings/lib/interface_ptr_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698