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" |
11 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" | 11 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" |
12 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 | 14 |
15 // AssociatedInterfaceRequest represents an associated interface request. It is | 15 // AssociatedInterfaceRequest represents an associated interface request. It is |
16 // similar to InterfaceRequest except that it doesn't own a message pipe handle. | 16 // similar to InterfaceRequest except that it doesn't own a message pipe handle. |
17 template <typename Interface> | 17 template <typename Interface> |
18 class AssociatedInterfaceRequest { | 18 class AssociatedInterfaceRequest { |
19 DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(AssociatedInterfaceRequest); | |
20 | |
21 public: | 19 public: |
22 // Constructs an empty AssociatedInterfaceRequest, representing that the | 20 // Constructs an empty AssociatedInterfaceRequest, representing that the |
23 // client is not requesting an implementation of Interface. | 21 // client is not requesting an implementation of Interface. |
24 AssociatedInterfaceRequest() {} | 22 AssociatedInterfaceRequest() {} |
25 AssociatedInterfaceRequest(decltype(nullptr)) {} | 23 AssociatedInterfaceRequest(decltype(nullptr)) {} |
26 | 24 |
27 // Takes the interface endpoint handle from another | 25 // Takes the interface endpoint handle from another |
28 // AssociatedInterfaceRequest. | 26 // AssociatedInterfaceRequest. |
29 AssociatedInterfaceRequest(AssociatedInterfaceRequest&& other) { | 27 AssociatedInterfaceRequest(AssociatedInterfaceRequest&& other) { |
30 handle_ = std::move(other.handle_); | 28 handle_ = std::move(other.handle_); |
(...skipping 30 matching lines...) Expand all Loading... |
61 if (this == &other) | 59 if (this == &other) |
62 return true; | 60 return true; |
63 | 61 |
64 // Now that the two refer to different objects, they are equivalent if | 62 // Now that the two refer to different objects, they are equivalent if |
65 // and only if they are both invalid. | 63 // and only if they are both invalid. |
66 return !is_pending() && !other.is_pending(); | 64 return !is_pending() && !other.is_pending(); |
67 } | 65 } |
68 | 66 |
69 private: | 67 private: |
70 ScopedInterfaceEndpointHandle handle_; | 68 ScopedInterfaceEndpointHandle handle_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfaceRequest); |
71 }; | 71 }; |
72 | 72 |
73 // Makes an AssociatedInterfaceRequest bound to the specified associated | 73 // Makes an AssociatedInterfaceRequest bound to the specified associated |
74 // endpoint. | 74 // endpoint. |
75 template <typename Interface> | 75 template <typename Interface> |
76 AssociatedInterfaceRequest<Interface> MakeAssociatedRequest( | 76 AssociatedInterfaceRequest<Interface> MakeAssociatedRequest( |
77 ScopedInterfaceEndpointHandle handle) { | 77 ScopedInterfaceEndpointHandle handle) { |
78 AssociatedInterfaceRequest<Interface> request; | 78 AssociatedInterfaceRequest<Interface> request; |
79 request.Bind(std::move(handle)); | 79 request.Bind(std::move(handle)); |
80 return request; | 80 return request; |
81 } | 81 } |
82 | 82 |
83 } // namespace mojo | 83 } // namespace mojo |
84 | 84 |
85 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_ | 85 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_ |
OLD | NEW |