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 |
19 public: | 21 public: |
20 // Constructs an empty AssociatedInterfaceRequest, representing that the | 22 // Constructs an empty AssociatedInterfaceRequest, representing that the |
21 // client is not requesting an implementation of Interface. | 23 // client is not requesting an implementation of Interface. |
22 AssociatedInterfaceRequest() {} | 24 AssociatedInterfaceRequest() {} |
23 AssociatedInterfaceRequest(decltype(nullptr)) {} | 25 AssociatedInterfaceRequest(decltype(nullptr)) {} |
24 | 26 |
25 // Takes the interface endpoint handle from another | 27 // Takes the interface endpoint handle from another |
26 // AssociatedInterfaceRequest. | 28 // AssociatedInterfaceRequest. |
27 AssociatedInterfaceRequest(AssociatedInterfaceRequest&& other) { | 29 AssociatedInterfaceRequest(AssociatedInterfaceRequest&& other) { |
28 handle_ = std::move(other.handle_); | 30 handle_ = std::move(other.handle_); |
(...skipping 30 matching lines...) Expand all Loading... |
59 if (this == &other) | 61 if (this == &other) |
60 return true; | 62 return true; |
61 | 63 |
62 // Now that the two refer to different objects, they are equivalent if | 64 // Now that the two refer to different objects, they are equivalent if |
63 // and only if they are both invalid. | 65 // and only if they are both invalid. |
64 return !is_pending() && !other.is_pending(); | 66 return !is_pending() && !other.is_pending(); |
65 } | 67 } |
66 | 68 |
67 private: | 69 private: |
68 ScopedInterfaceEndpointHandle handle_; | 70 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 |