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

Unified Diff: mojo/public/cpp/bindings/lib/binding_state.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/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
« no previous file with comments | « mojo/public/cpp/bindings/lib/binding_state.h ('k') | mojo/public/cpp/bindings/lib/control_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698