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 PtrInfoType = InterfacePtrInfo<Interface>; |
| 44 |
43 // Constructs an unbound InterfacePtr. | 45 // Constructs an unbound InterfacePtr. |
44 InterfacePtr() {} | 46 InterfacePtr() {} |
45 InterfacePtr(decltype(nullptr)) {} | 47 InterfacePtr(decltype(nullptr)) {} |
46 | 48 |
47 // Takes over the binding of another InterfacePtr. | 49 // Takes over the binding of another InterfacePtr. |
48 InterfacePtr(InterfacePtr&& other) { | 50 InterfacePtr(InterfacePtr&& other) { |
49 internal_state_.Swap(&other.internal_state_); | 51 internal_state_.Swap(&other.internal_state_); |
50 } | 52 } |
51 | 53 |
52 // Takes over the binding of another InterfacePtr, and closes any message pipe | 54 // 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()) { | 242 base::ThreadTaskRunnerHandle::Get()) { |
241 InterfacePtr<Interface> ptr; | 243 InterfacePtr<Interface> ptr; |
242 if (info.is_valid()) | 244 if (info.is_valid()) |
243 ptr.Bind(std::move(info), std::move(runner)); | 245 ptr.Bind(std::move(info), std::move(runner)); |
244 return std::move(ptr); | 246 return std::move(ptr); |
245 } | 247 } |
246 | 248 |
247 } // namespace mojo | 249 } // namespace mojo |
248 | 250 |
249 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ | 251 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ |
OLD | NEW |