| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/lib/interface_endpoint_client.h" | 5 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 9 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 10 #include "mojo/public/cpp/bindings/associated_group.h" | 12 #include "mojo/public/cpp/bindings/associated_group.h" |
| 11 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" | 13 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" |
| 12 | 14 |
| 13 namespace mojo { | 15 namespace mojo { |
| 14 namespace internal { | 16 namespace internal { |
| 15 | 17 |
| 16 // ---------------------------------------------------------------------------- | 18 // ---------------------------------------------------------------------------- |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 Message* message) { | 88 Message* message) { |
| 87 return owner_->HandleValidatedMessage(message); | 89 return owner_->HandleValidatedMessage(message); |
| 88 } | 90 } |
| 89 | 91 |
| 90 // ---------------------------------------------------------------------------- | 92 // ---------------------------------------------------------------------------- |
| 91 | 93 |
| 92 InterfaceEndpointClient::InterfaceEndpointClient( | 94 InterfaceEndpointClient::InterfaceEndpointClient( |
| 93 ScopedInterfaceEndpointHandle handle, | 95 ScopedInterfaceEndpointHandle handle, |
| 94 MessageReceiverWithResponderStatus* receiver, | 96 MessageReceiverWithResponderStatus* receiver, |
| 95 scoped_ptr<MessageFilter> payload_validator) | 97 scoped_ptr<MessageFilter> payload_validator) |
| 96 : handle_(handle.Pass()), | 98 : handle_(std::move(handle)), |
| 97 incoming_receiver_(receiver), | 99 incoming_receiver_(receiver), |
| 98 payload_validator_(payload_validator.Pass()), | 100 payload_validator_(std::move(payload_validator)), |
| 99 thunk_(this), | 101 thunk_(this), |
| 100 next_request_id_(1), | 102 next_request_id_(1), |
| 101 encountered_error_(false), | 103 encountered_error_(false), |
| 102 weak_ptr_factory_(this) { | 104 weak_ptr_factory_(this) { |
| 103 DCHECK(handle_.is_valid()); | 105 DCHECK(handle_.is_valid()); |
| 104 DCHECK(handle_.is_local()); | 106 DCHECK(handle_.is_local()); |
| 105 | 107 |
| 106 // TODO(yzshen): the way to use validator (or message filter in general) | 108 // TODO(yzshen): the way to use validator (or message filter in general) |
| 107 // directly is a little awkward. | 109 // directly is a little awkward. |
| 108 payload_validator_->set_sink(&thunk_); | 110 payload_validator_->set_sink(&thunk_); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 126 | 128 |
| 127 ScopedInterfaceEndpointHandle InterfaceEndpointClient::PassHandle() { | 129 ScopedInterfaceEndpointHandle InterfaceEndpointClient::PassHandle() { |
| 128 DCHECK(thread_checker_.CalledOnValidThread()); | 130 DCHECK(thread_checker_.CalledOnValidThread()); |
| 129 DCHECK(!has_pending_responders()); | 131 DCHECK(!has_pending_responders()); |
| 130 | 132 |
| 131 if (!handle_.is_valid()) | 133 if (!handle_.is_valid()) |
| 132 return ScopedInterfaceEndpointHandle(); | 134 return ScopedInterfaceEndpointHandle(); |
| 133 | 135 |
| 134 handle_.router()->DetachEndpointClient(handle_); | 136 handle_.router()->DetachEndpointClient(handle_); |
| 135 | 137 |
| 136 return handle_.Pass(); | 138 return std::move(handle_); |
| 137 } | 139 } |
| 138 | 140 |
| 139 void InterfaceEndpointClient::RaiseError() { | 141 void InterfaceEndpointClient::RaiseError() { |
| 140 DCHECK(thread_checker_.CalledOnValidThread()); | 142 DCHECK(thread_checker_.CalledOnValidThread()); |
| 141 | 143 |
| 142 handle_.router()->RaiseError(); | 144 handle_.router()->RaiseError(); |
| 143 } | 145 } |
| 144 | 146 |
| 145 bool InterfaceEndpointClient::Accept(Message* message) { | 147 bool InterfaceEndpointClient::Accept(Message* message) { |
| 146 DCHECK(thread_checker_.CalledOnValidThread()); | 148 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } else { | 218 } else { |
| 217 if (!incoming_receiver_) | 219 if (!incoming_receiver_) |
| 218 return false; | 220 return false; |
| 219 | 221 |
| 220 return incoming_receiver_->Accept(message); | 222 return incoming_receiver_->Accept(message); |
| 221 } | 223 } |
| 222 } | 224 } |
| 223 | 225 |
| 224 } // namespace internal | 226 } // namespace internal |
| 225 } // namespace mojo | 227 } // namespace mojo |
| OLD | NEW |