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