Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: mojo/public/cpp/bindings/interface_request.h

Issue 2031823002: Mojo C++ bindings: more consistent Clone() and Equals(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/cpp/bindings/interface_ptr.h ('k') | mojo/public/cpp/bindings/lib/array_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/interface_ptr.h ('k') | mojo/public/cpp/bindings/lib/array_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698