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_REQUEST_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void Bind(ScopedInterfaceEndpointHandle handle) { | 50 void Bind(ScopedInterfaceEndpointHandle handle) { |
51 handle_ = std::move(handle); | 51 handle_ = std::move(handle); |
52 } | 52 } |
53 | 53 |
54 ScopedInterfaceEndpointHandle PassHandle() { | 54 ScopedInterfaceEndpointHandle PassHandle() { |
55 return std::move(handle_); | 55 return std::move(handle_); |
56 } | 56 } |
57 | 57 |
58 const ScopedInterfaceEndpointHandle& handle() const { return handle_; } | 58 const ScopedInterfaceEndpointHandle& handle() const { return handle_; } |
59 | 59 |
| 60 bool Equals(const AssociatedInterfaceRequest& other) const { |
| 61 if (this == &other) |
| 62 return true; |
| 63 |
| 64 // Now that the two refer to different objects, they are equivalent if |
| 65 // and only if they are both invalid. |
| 66 return !is_pending() && !other.is_pending(); |
| 67 } |
| 68 |
60 private: | 69 private: |
61 ScopedInterfaceEndpointHandle handle_; | 70 ScopedInterfaceEndpointHandle handle_; |
62 }; | 71 }; |
63 | 72 |
64 // Makes an AssociatedInterfaceRequest bound to the specified associated | 73 // Makes an AssociatedInterfaceRequest bound to the specified associated |
65 // endpoint. | 74 // endpoint. |
66 template <typename Interface> | 75 template <typename Interface> |
67 AssociatedInterfaceRequest<Interface> MakeAssociatedRequest( | 76 AssociatedInterfaceRequest<Interface> MakeAssociatedRequest( |
68 ScopedInterfaceEndpointHandle handle) { | 77 ScopedInterfaceEndpointHandle handle) { |
69 AssociatedInterfaceRequest<Interface> request; | 78 AssociatedInterfaceRequest<Interface> request; |
70 request.Bind(std::move(handle)); | 79 request.Bind(std::move(handle)); |
71 return request; | 80 return request; |
72 } | 81 } |
73 | 82 |
74 } // namespace mojo | 83 } // namespace mojo |
75 | 84 |
76 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_ | 85 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_ |
OLD | NEW |