Index: mojo/public/cpp/bindings/lib/binding_state.cc |
diff --git a/mojo/public/cpp/bindings/lib/binding_state.cc b/mojo/public/cpp/bindings/lib/binding_state.cc |
index 6d92f7239acf3d1b3ef17df8e78d7ab537e20e81..b63677e41714b86f5dd463e69b2f5839faf0aff6 100644 |
--- a/mojo/public/cpp/bindings/lib/binding_state.cc |
+++ b/mojo/public/cpp/bindings/lib/binding_state.cc |
@@ -40,6 +40,14 @@ void SimpleBindingState::Close() { |
DestroyRouter(); |
} |
+void SimpleBindingState::CloseWithReason(uint32_t custom_reason, |
+ const std::string& description) { |
+ if (router_) |
+ router_->control_message_proxy()->SendDisconnectReason(custom_reason, |
+ description); |
+ Close(); |
+} |
+ |
void SimpleBindingState::FlushForTesting() { |
router_->control_message_proxy()->FlushForTesting(); |
} |
@@ -65,20 +73,11 @@ void SimpleBindingState::BindInternal( |
has_sync_methods, std::move(runner), |
interface_version); |
router_->set_incoming_receiver(stub); |
- router_->set_connection_error_handler(base::Bind( |
- &SimpleBindingState::RunConnectionErrorHandler, base::Unretained(this))); |
} |
void SimpleBindingState::DestroyRouter() { |
- router_->set_connection_error_handler(base::Closure()); |
delete router_; |
router_ = nullptr; |
- connection_error_handler_.Reset(); |
-} |
- |
-void SimpleBindingState::RunConnectionErrorHandler() { |
- if (!connection_error_handler_.is_null()) |
- connection_error_handler_.Run(); |
} |
// ----------------------------------------------------------------------------- |
@@ -118,7 +117,14 @@ void MultiplexedBindingState::Close() { |
endpoint_client_.reset(); |
router_->CloseMessagePipe(); |
router_ = nullptr; |
- connection_error_handler_.Reset(); |
+} |
+ |
+void MultiplexedBindingState::CloseWithReason(uint32_t custom_reason, |
+ const std::string& description) { |
+ if (endpoint_client_) |
+ endpoint_client_->control_message_proxy()->SendDisconnectReason( |
+ custom_reason, description); |
+ Close(); |
} |
void MultiplexedBindingState::FlushForTesting() { |
@@ -147,15 +153,6 @@ void MultiplexedBindingState::BindInternal( |
router_->CreateLocalEndpointHandle(kMasterInterfaceId), stub, |
std::move(request_validator), has_sync_methods, std::move(runner), |
interface_version)); |
- |
- endpoint_client_->set_connection_error_handler( |
- base::Bind(&MultiplexedBindingState::RunConnectionErrorHandler, |
- base::Unretained(this))); |
-} |
- |
-void MultiplexedBindingState::RunConnectionErrorHandler() { |
- if (!connection_error_handler_.is_null()) |
- connection_error_handler_.Run(); |
} |
} // namesapce internal |