| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/public/cpp/bindings/associated_binding.h" | 5 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 6 #include "base/single_thread_task_runner.h" | 6 #include "base/single_thread_task_runner.h" |
| 7 | 7 |
| 8 namespace mojo { | 8 namespace mojo { |
| 9 | 9 |
| 10 AssociatedBindingBase::AssociatedBindingBase() {} | 10 AssociatedBindingBase::AssociatedBindingBase() {} |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 void AssociatedBindingBase::CloseWithReason(uint32_t custom_reason, | 23 void AssociatedBindingBase::CloseWithReason(uint32_t custom_reason, |
| 24 const std::string& description) { | 24 const std::string& description) { |
| 25 if (endpoint_client_) | 25 if (endpoint_client_) |
| 26 endpoint_client_->CloseWithReason(custom_reason, description); | 26 endpoint_client_->CloseWithReason(custom_reason, description); |
| 27 Close(); | 27 Close(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void AssociatedBindingBase::set_connection_error_handler( | 30 void AssociatedBindingBase::set_connection_error_handler( |
| 31 const base::Closure& error_handler) { | 31 base::OnceClosure error_handler) { |
| 32 DCHECK(is_bound()); | 32 DCHECK(is_bound()); |
| 33 endpoint_client_->set_connection_error_handler(error_handler); | 33 endpoint_client_->set_connection_error_handler(std::move(error_handler)); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void AssociatedBindingBase::set_connection_error_with_reason_handler( | 36 void AssociatedBindingBase::set_connection_error_with_reason_handler( |
| 37 const ConnectionErrorWithReasonCallback& error_handler) { | 37 ConnectionErrorWithReasonCallback error_handler) { |
| 38 DCHECK(is_bound()); | 38 DCHECK(is_bound()); |
| 39 endpoint_client_->set_connection_error_with_reason_handler(error_handler); | 39 endpoint_client_->set_connection_error_with_reason_handler( |
| 40 std::move(error_handler)); |
| 40 } | 41 } |
| 41 | 42 |
| 42 void AssociatedBindingBase::FlushForTesting() { | 43 void AssociatedBindingBase::FlushForTesting() { |
| 43 endpoint_client_->FlushForTesting(); | 44 endpoint_client_->FlushForTesting(); |
| 44 } | 45 } |
| 45 | 46 |
| 46 void AssociatedBindingBase::BindImpl( | 47 void AssociatedBindingBase::BindImpl( |
| 47 ScopedInterfaceEndpointHandle handle, | 48 ScopedInterfaceEndpointHandle handle, |
| 48 MessageReceiverWithResponderStatus* receiver, | 49 MessageReceiverWithResponderStatus* receiver, |
| 49 std::unique_ptr<MessageReceiver> payload_validator, | 50 std::unique_ptr<MessageReceiver> payload_validator, |
| 50 bool expect_sync_requests, | 51 bool expect_sync_requests, |
| 51 scoped_refptr<base::SingleThreadTaskRunner> runner, | 52 scoped_refptr<base::SingleThreadTaskRunner> runner, |
| 52 uint32_t interface_version) { | 53 uint32_t interface_version) { |
| 53 if (!handle.is_valid()) { | 54 if (!handle.is_valid()) { |
| 54 endpoint_client_.reset(); | 55 endpoint_client_.reset(); |
| 55 return; | 56 return; |
| 56 } | 57 } |
| 57 | 58 |
| 58 endpoint_client_.reset(new InterfaceEndpointClient( | 59 endpoint_client_.reset(new InterfaceEndpointClient( |
| 59 std::move(handle), receiver, std::move(payload_validator), | 60 std::move(handle), receiver, std::move(payload_validator), |
| 60 expect_sync_requests, std::move(runner), interface_version)); | 61 expect_sync_requests, std::move(runner), interface_version)); |
| 61 } | 62 } |
| 62 | 63 |
| 63 } // namespace mojo | 64 } // namespace mojo |
| OLD | NEW |