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_PTR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 22 matching lines...) Expand all Loading... |
33 // to a message pipe. All calls to this class or the proxy should be from the | 33 // to a message pipe. All calls to this class or the proxy should be from the |
34 // same thread that bound it. If you need to move the proxy to a different | 34 // same thread that bound it. If you need to move the proxy to a different |
35 // thread, extract the InterfacePtrInfo (containing just the message pipe and | 35 // thread, extract the InterfacePtrInfo (containing just the message pipe and |
36 // any version information) using PassInterface(), pass it to a different | 36 // any version information) using PassInterface(), pass it to a different |
37 // thread, and create and bind a new InterfacePtr from that thread. If an | 37 // thread, and create and bind a new InterfacePtr from that thread. If an |
38 // InterfacePtr is not bound to a message pipe, it may be bound or destroyed on | 38 // InterfacePtr is not bound to a message pipe, it may be bound or destroyed on |
39 // any thread. | 39 // any thread. |
40 template <typename Interface> | 40 template <typename Interface> |
41 class InterfacePtr { | 41 class InterfacePtr { |
42 public: | 42 public: |
| 43 using InterfaceType = Interface; |
| 44 using PtrInfoType = InterfacePtrInfo<Interface>; |
| 45 |
43 // Constructs an unbound InterfacePtr. | 46 // Constructs an unbound InterfacePtr. |
44 InterfacePtr() {} | 47 InterfacePtr() {} |
45 InterfacePtr(decltype(nullptr)) {} | 48 InterfacePtr(decltype(nullptr)) {} |
46 | 49 |
47 // Takes over the binding of another InterfacePtr. | 50 // Takes over the binding of another InterfacePtr. |
48 InterfacePtr(InterfacePtr&& other) { | 51 InterfacePtr(InterfacePtr&& other) { |
49 internal_state_.Swap(&other.internal_state_); | 52 internal_state_.Swap(&other.internal_state_); |
50 } | 53 } |
51 | 54 |
52 // Takes over the binding of another InterfacePtr, and closes any message pipe | 55 // Takes over the binding of another InterfacePtr, and closes any message pipe |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 base::ThreadTaskRunnerHandle::Get()) { | 243 base::ThreadTaskRunnerHandle::Get()) { |
241 InterfacePtr<Interface> ptr; | 244 InterfacePtr<Interface> ptr; |
242 if (info.is_valid()) | 245 if (info.is_valid()) |
243 ptr.Bind(std::move(info), std::move(runner)); | 246 ptr.Bind(std::move(info), std::move(runner)); |
244 return std::move(ptr); | 247 return std::move(ptr); |
245 } | 248 } |
246 | 249 |
247 } // namespace mojo | 250 } // namespace mojo |
248 | 251 |
249 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ | 252 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ |
OLD | NEW |