| Index: mojo/public/cpp/bindings/associated_binding.h
|
| diff --git a/mojo/public/cpp/bindings/associated_binding.h b/mojo/public/cpp/bindings/associated_binding.h
|
| index 3f991290171cf0a3d1ef5e4588f6ee2064a39d66..a7a7c822869b414eb33fd63bde32f5a3e1f89de8 100644
|
| --- a/mojo/public/cpp/bindings/associated_binding.h
|
| +++ b/mojo/public/cpp/bindings/associated_binding.h
|
| @@ -6,6 +6,7 @@
|
| #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_BINDING_H_
|
|
|
| #include <memory>
|
| +#include <string>
|
| #include <utility>
|
|
|
| #include "base/bind.h"
|
| @@ -18,6 +19,7 @@
|
| #include "mojo/public/cpp/bindings/associated_group.h"
|
| #include "mojo/public/cpp/bindings/associated_group_controller.h"
|
| #include "mojo/public/cpp/bindings/associated_interface_request.h"
|
| +#include "mojo/public/cpp/bindings/connection_error_callback.h"
|
| #include "mojo/public/cpp/bindings/interface_endpoint_client.h"
|
| #include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
|
| #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
|
| @@ -105,9 +107,6 @@ class AssociatedBinding {
|
| std::move(handle), &stub_,
|
| base::WrapUnique(new typename Interface::RequestValidator_()),
|
| Interface::HasSyncMethods_, std::move(runner), Interface::Version_));
|
| - endpoint_client_->set_connection_error_handler(
|
| - base::Bind(&AssociatedBinding::RunConnectionErrorHandler,
|
| - base::Unretained(this)));
|
|
|
| stub_.serialization_context()->group_controller =
|
| endpoint_client_->group_controller();
|
| @@ -126,7 +125,14 @@ class AssociatedBinding {
|
| void Close() {
|
| DCHECK(endpoint_client_);
|
| endpoint_client_.reset();
|
| - connection_error_handler_.Reset();
|
| + }
|
| +
|
| + // Similar to the method above, but also specifies a disconnect reason.
|
| + void CloseWithReason(uint32_t custom_reason, const std::string& description) {
|
| + DCHECK(endpoint_client_);
|
| + endpoint_client_->control_message_proxy()->SendDisconnectReason(
|
| + custom_reason, description);
|
| + Close();
|
| }
|
|
|
| // Unbinds and returns the associated interface request so it can be
|
| @@ -139,7 +145,6 @@ class AssociatedBinding {
|
| request.Bind(endpoint_client_->PassHandle());
|
|
|
| endpoint_client_.reset();
|
| - connection_error_handler_.Reset();
|
|
|
| return request;
|
| }
|
| @@ -151,7 +156,13 @@ class AssociatedBinding {
|
| // AssociatedBinding is unbound or closed.
|
| void set_connection_error_handler(const base::Closure& error_handler) {
|
| DCHECK(is_bound());
|
| - connection_error_handler_ = error_handler;
|
| + endpoint_client_->set_connection_error_handler(error_handler);
|
| + }
|
| +
|
| + void set_connection_error_with_reason_handler(
|
| + const ConnectionErrorWithReasonCallback& error_handler) {
|
| + DCHECK(is_bound());
|
| + endpoint_client_->set_connection_error_with_reason_handler(error_handler);
|
| }
|
|
|
| // Returns the interface implementation that was previously specified.
|
| @@ -175,16 +186,10 @@ class AssociatedBinding {
|
| }
|
|
|
| private:
|
| - void RunConnectionErrorHandler() {
|
| - if (!connection_error_handler_.is_null())
|
| - connection_error_handler_.Run();
|
| - }
|
| -
|
| std::unique_ptr<InterfaceEndpointClient> endpoint_client_;
|
|
|
| typename Interface::Stub_ stub_;
|
| Interface* impl_;
|
| - base::Closure connection_error_handler_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(AssociatedBinding);
|
| };
|
|
|