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_REQUEST_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // requested. If the request is already bound to a message pipe, the current | 48 // requested. If the request is already bound to a message pipe, the current |
49 // message pipe will be closed. | 49 // message pipe will be closed. |
50 void Bind(ScopedMessagePipeHandle handle) { handle_ = std::move(handle); } | 50 void Bind(ScopedMessagePipeHandle handle) { handle_ = std::move(handle); } |
51 | 51 |
52 // Indicates whether the request currently contains a valid message pipe. | 52 // Indicates whether the request currently contains a valid message pipe. |
53 bool is_pending() const { return handle_.is_valid(); } | 53 bool is_pending() const { return handle_.is_valid(); } |
54 | 54 |
55 // Removes the message pipe from the request and returns it. | 55 // Removes the message pipe from the request and returns it. |
56 ScopedMessagePipeHandle PassMessagePipe() { return std::move(handle_); } | 56 ScopedMessagePipeHandle PassMessagePipe() { return std::move(handle_); } |
57 | 57 |
| 58 bool Equals(const InterfaceRequest& other) const { |
| 59 if (this == &other) |
| 60 return true; |
| 61 |
| 62 // Now that the two refer to different objects, they are equivalent if |
| 63 // and only if they are both invalid. |
| 64 return !is_pending() && !other.is_pending(); |
| 65 } |
| 66 |
58 private: | 67 private: |
59 ScopedMessagePipeHandle handle_; | 68 ScopedMessagePipeHandle handle_; |
60 }; | 69 }; |
61 | 70 |
62 // Makes an InterfaceRequest bound to the specified message pipe. If |handle| | 71 // Makes an InterfaceRequest bound to the specified message pipe. If |handle| |
63 // is empty or invalid, the resulting InterfaceRequest will represent the | 72 // is empty or invalid, the resulting InterfaceRequest will represent the |
64 // absence of a request. | 73 // absence of a request. |
65 template <typename Interface> | 74 template <typename Interface> |
66 InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle) { | 75 InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle) { |
67 InterfaceRequest<Interface> request; | 76 InterfaceRequest<Interface> request; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 bool FuseInterface(InterfaceRequest<Interface> request, | 138 bool FuseInterface(InterfaceRequest<Interface> request, |
130 InterfacePtrInfo<Interface> proxy_info) { | 139 InterfacePtrInfo<Interface> proxy_info) { |
131 MojoResult result = FuseMessagePipes(request.PassMessagePipe(), | 140 MojoResult result = FuseMessagePipes(request.PassMessagePipe(), |
132 proxy_info.PassHandle()); | 141 proxy_info.PassHandle()); |
133 return result == MOJO_RESULT_OK; | 142 return result == MOJO_RESULT_OK; |
134 } | 143 } |
135 | 144 |
136 } // namespace mojo | 145 } // namespace mojo |
137 | 146 |
138 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 147 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
OLD | NEW |