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

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

Issue 2047633002: Revert of Remove base/move.h (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
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/macros.h"
11 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
12 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
13 #include "mojo/public/cpp/bindings/interface_ptr.h" 12 #include "mojo/public/cpp/bindings/interface_ptr.h"
14 13
15 namespace mojo { 14 namespace mojo {
16 15
17 // Represents a request from a remote client for an implementation of Interface 16 // Represents a request from a remote client for an implementation of Interface
18 // over a specified message pipe. The implementor of the interface should 17 // over a specified message pipe. The implementor of the interface should
19 // remove the message pipe by calling PassMessagePipe() and bind it to the 18 // remove the message pipe by calling PassMessagePipe() and bind it to the
20 // implementation. If this is not done, the InterfaceRequest will automatically 19 // implementation. If this is not done, the InterfaceRequest will automatically
21 // close the pipe on destruction. Can also represent the absence of a request 20 // close the pipe on destruction. Can also represent the absence of a request
22 // if the client did not provide a message pipe. 21 // if the client did not provide a message pipe.
23 template <typename Interface> 22 template <typename Interface>
24 class InterfaceRequest { 23 class InterfaceRequest {
24 MOVE_ONLY_TYPE_FOR_CPP_03(InterfaceRequest);
25 public: 25 public:
26 // Constructs an empty InterfaceRequest, representing that the client is not 26 // Constructs an empty InterfaceRequest, representing that the client is not
27 // requesting an implementation of Interface. 27 // requesting an implementation of Interface.
28 InterfaceRequest() {} 28 InterfaceRequest() {}
29 InterfaceRequest(decltype(nullptr)) {} 29 InterfaceRequest(decltype(nullptr)) {}
30 30
31 // Takes the message pipe from another InterfaceRequest. 31 // Takes the message pipe from another InterfaceRequest.
32 InterfaceRequest(InterfaceRequest&& other) { 32 InterfaceRequest(InterfaceRequest&& other) {
33 handle_ = std::move(other.handle_); 33 handle_ = std::move(other.handle_);
34 } 34 }
(...skipping 24 matching lines...) Expand all
59 if (this == &other) 59 if (this == &other)
60 return true; 60 return true;
61 61
62 // 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
63 // and only if they are both invalid. 63 // and only if they are both invalid.
64 return !is_pending() && !other.is_pending(); 64 return !is_pending() && !other.is_pending();
65 } 65 }
66 66
67 private: 67 private:
68 ScopedMessagePipeHandle handle_; 68 ScopedMessagePipeHandle handle_;
69
70 DISALLOW_COPY_AND_ASSIGN(InterfaceRequest);
71 }; 69 };
72 70
73 // Makes an InterfaceRequest bound to the specified message pipe. If |handle| 71 // Makes an InterfaceRequest bound to the specified message pipe. If |handle|
74 // is empty or invalid, the resulting InterfaceRequest will represent the 72 // is empty or invalid, the resulting InterfaceRequest will represent the
75 // absence of a request. 73 // absence of a request.
76 template <typename Interface> 74 template <typename Interface>
77 InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle) { 75 InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle) {
78 InterfaceRequest<Interface> request; 76 InterfaceRequest<Interface> request;
79 request.Bind(std::move(handle)); 77 request.Bind(std::move(handle));
80 return std::move(request); 78 return std::move(request);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 bool FuseInterface(InterfaceRequest<Interface> request, 138 bool FuseInterface(InterfaceRequest<Interface> request,
141 InterfacePtrInfo<Interface> proxy_info) { 139 InterfacePtrInfo<Interface> proxy_info) {
142 MojoResult result = FuseMessagePipes(request.PassMessagePipe(), 140 MojoResult result = FuseMessagePipes(request.PassMessagePipe(),
143 proxy_info.PassHandle()); 141 proxy_info.PassHandle());
144 return result == MOJO_RESULT_OK; 142 return result == MOJO_RESULT_OK;
145 } 143 }
146 144
147 } // namespace mojo 145 } // namespace mojo
148 146
149 #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_info.h ('k') | mojo/public/cpp/bindings/lib/filter_chain.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698