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 "mojo/public/cpp/bindings/interface_ptr.h" | 8 #include "mojo/public/cpp/bindings/interface_ptr.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
11 | 11 |
12 // Used in methods that return instances of remote objects. | 12 // Used in methods that return instances of remote objects. |
13 template <typename Interface> | 13 template <typename Interface> |
14 class InterfaceRequest { | 14 class InterfaceRequest { |
15 MOJO_MOVE_ONLY_TYPE(InterfaceRequest) | 15 MOJO_MOVE_ONLY_TYPE(InterfaceRequest) |
16 public: | 16 public: |
17 InterfaceRequest() {} | 17 InterfaceRequest() {} |
18 | 18 |
| 19 InterfaceRequest(decltype(nullptr)) {} |
19 InterfaceRequest(InterfaceRequest&& other) { handle_ = other.handle_.Pass(); } | 20 InterfaceRequest(InterfaceRequest&& other) { handle_ = other.handle_.Pass(); } |
| 21 InterfaceRequest& operator=(decltype(nullptr)) { |
| 22 handle_.reset(); |
| 23 return *this; |
| 24 } |
20 InterfaceRequest& operator=(InterfaceRequest&& other) { | 25 InterfaceRequest& operator=(InterfaceRequest&& other) { |
21 handle_ = other.handle_.Pass(); | 26 handle_ = other.handle_.Pass(); |
22 return *this; | 27 return *this; |
23 } | 28 } |
24 | 29 |
25 // Returns true if the request has yet to be completed. | 30 // Returns true if the request has yet to be completed. |
26 bool is_pending() const { return handle_.is_valid(); } | 31 bool is_pending() const { return handle_.is_valid(); } |
27 | 32 |
28 void Bind(ScopedMessagePipeHandle handle) { handle_ = handle.Pass(); } | 33 void Bind(ScopedMessagePipeHandle handle) { handle_ = handle.Pass(); } |
29 | 34 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 template <typename Interface> | 66 template <typename Interface> |
62 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { | 67 InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) { |
63 MessagePipe pipe; | 68 MessagePipe pipe; |
64 ptr->Bind(pipe.handle0.Pass()); | 69 ptr->Bind(pipe.handle0.Pass()); |
65 return MakeRequest<Interface>(pipe.handle1.Pass()); | 70 return MakeRequest<Interface>(pipe.handle1.Pass()); |
66 } | 71 } |
67 | 72 |
68 } // namespace mojo | 73 } // namespace mojo |
69 | 74 |
70 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ | 75 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_REQUEST_H_ |
OLD | NEW |