OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_INTERFACE_PTR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 176 } |
177 | 177 |
178 // Returns the associated group that this object belongs to. Returns null if: | 178 // Returns the associated group that this object belongs to. Returns null if: |
179 // - this object is not bound; or | 179 // - this object is not bound; or |
180 // - the interface doesn't have methods to pass associated interface | 180 // - the interface doesn't have methods to pass associated interface |
181 // pointers or requests. | 181 // pointers or requests. |
182 AssociatedGroup* associated_group() { | 182 AssociatedGroup* associated_group() { |
183 return internal_state_.associated_group(); | 183 return internal_state_.associated_group(); |
184 } | 184 } |
185 | 185 |
| 186 bool Equals(const InterfacePtr& other) const { |
| 187 if (this == &other) |
| 188 return true; |
| 189 |
| 190 // Now that the two refer to different objects, they are equivalent if |
| 191 // and only if they are both null. |
| 192 return !(*this) && !other; |
| 193 } |
| 194 |
186 // DO NOT USE. Exposed only for internal use and for testing. | 195 // DO NOT USE. Exposed only for internal use and for testing. |
187 internal::InterfacePtrState<Interface, Interface::PassesAssociatedKinds_>* | 196 internal::InterfacePtrState<Interface, Interface::PassesAssociatedKinds_>* |
188 internal_state() { | 197 internal_state() { |
189 return &internal_state_; | 198 return &internal_state_; |
190 } | 199 } |
191 | 200 |
192 // Allow InterfacePtr<> to be used in boolean expressions, but not | 201 // Allow InterfacePtr<> to be used in boolean expressions, but not |
193 // implicitly convertible to a real bool (which is dangerous). | 202 // implicitly convertible to a real bool (which is dangerous). |
194 private: | 203 private: |
195 typedef internal::InterfacePtrState<Interface, | 204 typedef internal::InterfacePtrState<Interface, |
(...skipping 28 matching lines...) Expand all Loading... |
224 base::ThreadTaskRunnerHandle::Get()) { | 233 base::ThreadTaskRunnerHandle::Get()) { |
225 InterfacePtr<Interface> ptr; | 234 InterfacePtr<Interface> ptr; |
226 if (info.is_valid()) | 235 if (info.is_valid()) |
227 ptr.Bind(std::move(info), std::move(runner)); | 236 ptr.Bind(std::move(info), std::move(runner)); |
228 return std::move(ptr); | 237 return std::move(ptr); |
229 } | 238 } |
230 | 239 |
231 } // namespace mojo | 240 } // namespace mojo |
232 | 241 |
233 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ | 242 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ |
OLD | NEW |