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

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

Issue 1558333002: Rectify our use of std::nullptr_t, inclusions of <stddef.h>/<cstddef>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 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/struct_ptr.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 <cstddef>
9
8 #include "mojo/public/cpp/system/message_pipe.h" 10 #include "mojo/public/cpp/system/message_pipe.h"
9 11
10 namespace mojo { 12 namespace mojo {
11 13
12 template <typename I> 14 template <typename I>
13 class InterfacePtr; 15 class InterfacePtr;
14 16
15 template <typename I> 17 template <typename I>
16 class InterfacePtrInfo; 18 class InterfacePtrInfo;
17 19
18 // Represents a request from a remote client for an implementation of Interface 20 // Represents a request from a remote client for an implementation of Interface
19 // over a specified message pipe. The implementor of the interface should 21 // over a specified message pipe. The implementor of the interface should
20 // remove the message pipe by calling PassMessagePipe() and bind it to the 22 // remove the message pipe by calling PassMessagePipe() and bind it to the
21 // implementation. If this is not done, the InterfaceRequest will automatically 23 // implementation. If this is not done, the InterfaceRequest will automatically
22 // close the pipe on destruction. Can also represent the absence of a request 24 // close the pipe on destruction. Can also represent the absence of a request
23 // if the client did not provide a message pipe. 25 // if the client did not provide a message pipe.
24 template <typename Interface> 26 template <typename Interface>
25 class InterfaceRequest { 27 class InterfaceRequest {
26 public: 28 public:
27 // Constructs an empty InterfaceRequest, representing that the client is not 29 // Constructs an empty InterfaceRequest, representing that the client is not
28 // requesting an implementation of Interface. 30 // requesting an implementation of Interface.
29 InterfaceRequest() {} 31 InterfaceRequest() {}
30 InterfaceRequest(decltype(nullptr)) {} 32 InterfaceRequest(std::nullptr_t) {}
31 33
32 // Takes the message pipe from another InterfaceRequest. 34 // Takes the message pipe from another InterfaceRequest.
33 InterfaceRequest(InterfaceRequest&& other) { handle_ = other.handle_.Pass(); } 35 InterfaceRequest(InterfaceRequest&& other) { handle_ = other.handle_.Pass(); }
34 InterfaceRequest& operator=(InterfaceRequest&& other) { 36 InterfaceRequest& operator=(InterfaceRequest&& other) {
35 handle_ = other.handle_.Pass(); 37 handle_ = other.handle_.Pass();
36 return *this; 38 return *this;
37 } 39 }
38 40
39 // Assigning to nullptr resets the InterfaceRequest to an empty state, 41 // Assigning to nullptr resets the InterfaceRequest to an empty state,
40 // closing the message pipe currently bound to it (if any). 42 // closing the message pipe currently bound to it (if any).
41 InterfaceRequest& operator=(decltype(nullptr)) { 43 InterfaceRequest& operator=(std::nullptr_t) {
42 handle_.reset(); 44 handle_.reset();
43 return *this; 45 return *this;
44 } 46 }
45 47
46 // Binds the request to a message pipe over which Interface is to be 48 // Binds the request to a message pipe over which Interface is to be
47 // requested. If the request is already bound to a message pipe, the current 49 // requested. If the request is already bound to a message pipe, the current
48 // message pipe will be closed. 50 // message pipe will be closed.
49 void Bind(ScopedMessagePipeHandle handle) { handle_ = handle.Pass(); } 51 void Bind(ScopedMessagePipeHandle handle) { handle_ = handle.Pass(); }
50 52
51 // Indicates whether the request currently contains a valid message pipe. 53 // Indicates whether the request currently contains a valid message pipe.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 template <typename Interface> 118 template <typename Interface>
117 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { 119 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) {
118 MessagePipe pipe; 120 MessagePipe pipe;
119 ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u)); 121 ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u));
120 return MakeRequest<Interface>(pipe.handle1.Pass()); 122 return MakeRequest<Interface>(pipe.handle1.Pass());
121 } 123 }
122 124
123 } // namespace mojo 125 } // namespace mojo
124 126
125 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ 127 #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/struct_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698