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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> |
9 | 10 |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "mojo/public/cpp/bindings/associated_group.h" | 13 #include "mojo/public/cpp/bindings/associated_group.h" |
13 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" | 14 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" |
14 #include "mojo/public/cpp/bindings/associated_interface_request.h" | 15 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
15 #include "mojo/public/cpp/bindings/callback.h" | 16 #include "mojo/public/cpp/bindings/callback.h" |
16 #include "mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h" | 17 #include "mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h" |
17 | 18 |
18 namespace mojo { | 19 namespace mojo { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 void Bind(AssociatedInterfacePtrInfo<GenericInterface> info) { | 60 void Bind(AssociatedInterfacePtrInfo<GenericInterface> info) { |
60 reset(); | 61 reset(); |
61 | 62 |
62 bool is_local = | 63 bool is_local = |
63 internal::AssociatedInterfacePtrInfoHelper::GetHandle(&info).is_local(); | 64 internal::AssociatedInterfacePtrInfoHelper::GetHandle(&info).is_local(); |
64 | 65 |
65 DCHECK(is_local) << "The AssociatedInterfacePtrInfo is supposed to be used " | 66 DCHECK(is_local) << "The AssociatedInterfacePtrInfo is supposed to be used " |
66 "at the other side of the message pipe."; | 67 "at the other side of the message pipe."; |
67 | 68 |
68 if (info.is_valid() && is_local) | 69 if (info.is_valid() && is_local) |
69 internal_state_.Bind(info.Pass()); | 70 internal_state_.Bind(std::move(info)); |
70 } | 71 } |
71 | 72 |
72 bool is_bound() const { return internal_state_.is_bound(); } | 73 bool is_bound() const { return internal_state_.is_bound(); } |
73 | 74 |
74 Interface* get() const { return internal_state_.instance(); } | 75 Interface* get() const { return internal_state_.instance(); } |
75 | 76 |
76 // Functions like a pointer to Interface. Must already be bound. | 77 // Functions like a pointer to Interface. Must already be bound. |
77 Interface* operator->() const { return get(); } | 78 Interface* operator->() const { return get(); } |
78 Interface& operator*() const { return *get(); } | 79 Interface& operator*() const { return *get(); } |
79 | 80 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // until the request is bound to an implementation at the remote side. | 179 // until the request is bound to an implementation at the remote side. |
179 template <typename Interface> | 180 template <typename Interface> |
180 AssociatedInterfaceRequest<typename Interface::GenericInterface> GetProxy( | 181 AssociatedInterfaceRequest<typename Interface::GenericInterface> GetProxy( |
181 AssociatedInterfacePtr<Interface>* ptr, | 182 AssociatedInterfacePtr<Interface>* ptr, |
182 AssociatedGroup* group) { | 183 AssociatedGroup* group) { |
183 AssociatedInterfaceRequest<typename Interface::GenericInterface> request; | 184 AssociatedInterfaceRequest<typename Interface::GenericInterface> request; |
184 AssociatedInterfacePtrInfo<typename Interface::GenericInterface> ptr_info; | 185 AssociatedInterfacePtrInfo<typename Interface::GenericInterface> ptr_info; |
185 group->CreateAssociatedInterface(AssociatedGroup::WILL_PASS_REQUEST, | 186 group->CreateAssociatedInterface(AssociatedGroup::WILL_PASS_REQUEST, |
186 &ptr_info, &request); | 187 &ptr_info, &request); |
187 | 188 |
188 ptr->Bind(ptr_info.Pass()); | 189 ptr->Bind(std::move(ptr_info)); |
189 return request.Pass(); | 190 return std::move(request); |
190 } | 191 } |
191 | 192 |
192 } // namespace mojo | 193 } // namespace mojo |
193 | 194 |
194 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ | 195 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ |
OLD | NEW |