Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
|
yzshen1
2017/02/09 00:36:52
Please put this file in the lib/ directory.
scottmg
2017/02/09 01:15:08
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mojo/public/cpp/bindings/associated_binding.h" | |
| 6 | |
| 7 namespace mojo { | |
| 8 | |
| 9 AssociatedBindingBase::AssociatedBindingBase() {} | |
| 10 | |
| 11 AssociatedBindingBase::~AssociatedBindingBase() {} | |
| 12 | |
| 13 void AssociatedBindingBase::AddFilter(std::unique_ptr<MessageReceiver> filter) { | |
| 14 DCHECK(endpoint_client_); | |
| 15 endpoint_client_->AddFilter(std::move(filter)); | |
| 16 } | |
| 17 | |
| 18 void AssociatedBindingBase::Close() { | |
| 19 endpoint_client_.reset(); | |
| 20 } | |
| 21 | |
| 22 void AssociatedBindingBase::CloseWithReason(uint32_t custom_reason, | |
| 23 const std::string& description) { | |
| 24 if (endpoint_client_) | |
| 25 endpoint_client_->CloseWithReason(custom_reason, description); | |
| 26 Close(); | |
| 27 } | |
| 28 | |
| 29 void AssociatedBindingBase::set_connection_error_handler(const base::Closure& er ror_handler) { | |
|
yzshen1
2017/02/09 00:36:52
Please run git cl format.
scottmg
2017/02/09 01:15:08
Oops, done.
| |
| 30 DCHECK(is_bound()); | |
| 31 endpoint_client_->set_connection_error_handler(error_handler); | |
| 32 } | |
| 33 | |
| 34 void AssociatedBindingBase::set_connection_error_with_reason_handler( | |
| 35 const ConnectionErrorWithReasonCallback& error_handler) { | |
| 36 DCHECK(is_bound()); | |
| 37 endpoint_client_->set_connection_error_with_reason_handler(error_handler); | |
| 38 } | |
| 39 | |
| 40 void AssociatedBindingBase::FlushForTesting() { | |
| 41 endpoint_client_->control_message_proxy()->FlushForTesting(); | |
| 42 } | |
| 43 | |
| 44 void AssociatedBindingBase::BindImpl( | |
| 45 ScopedInterfaceEndpointHandle handle, | |
| 46 MessageReceiverWithResponderStatus* receiver, | |
| 47 std::unique_ptr<MessageReceiver> payload_validator, | |
| 48 bool expect_sync_requests, | |
| 49 scoped_refptr<base::SingleThreadTaskRunner> runner, | |
| 50 uint32_t interface_version) { | |
| 51 DCHECK(handle.is_local()) | |
| 52 << "The AssociatedInterfaceRequest is supposed to be used at the " | |
| 53 << "other side of the message pipe."; | |
| 54 | |
| 55 if (!handle.is_valid() || !handle.is_local()) { | |
| 56 endpoint_client_.reset(); | |
| 57 return; | |
| 58 } | |
| 59 | |
| 60 endpoint_client_.reset(new InterfaceEndpointClient( | |
| 61 std::move(handle), receiver, std::move(payload_validator), | |
| 62 expect_sync_requests, std::move(runner), interface_version)); | |
| 63 } | |
| 64 | |
| 65 } // namespace mojo | |
| OLD | NEW |