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 <utility> |
| 9 |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "mojo/public/cpp/bindings/callback.h" | 12 #include "mojo/public/cpp/bindings/callback.h" |
11 #include "mojo/public/cpp/bindings/interface_ptr_info.h" | 13 #include "mojo/public/cpp/bindings/interface_ptr_info.h" |
12 #include "mojo/public/cpp/bindings/lib/interface_ptr_state.h" | 14 #include "mojo/public/cpp/bindings/lib/interface_ptr_state.h" |
13 #include "mojo/public/cpp/environment/environment.h" | 15 #include "mojo/public/cpp/environment/environment.h" |
14 | 16 |
15 namespace mojo { | 17 namespace mojo { |
16 | 18 |
17 class AssociatedGroup; | 19 class AssociatedGroup; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // sufficient. | 69 // sufficient. |
68 // | 70 // |
69 // Calling with an invalid |info| (containing an invalid message pipe handle) | 71 // Calling with an invalid |info| (containing an invalid message pipe handle) |
70 // has the same effect as reset(). In this case, the InterfacePtr is not | 72 // has the same effect as reset(). In this case, the InterfacePtr is not |
71 // considered as bound. | 73 // considered as bound. |
72 void Bind( | 74 void Bind( |
73 InterfacePtrInfo<GenericInterface> info, | 75 InterfacePtrInfo<GenericInterface> info, |
74 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { | 76 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
75 reset(); | 77 reset(); |
76 if (info.is_valid()) | 78 if (info.is_valid()) |
77 internal_state_.Bind(info.Pass(), waiter); | 79 internal_state_.Bind(std::move(info), waiter); |
78 } | 80 } |
79 | 81 |
80 // Returns whether or not this InterfacePtr is bound to a message pipe. | 82 // Returns whether or not this InterfacePtr is bound to a message pipe. |
81 bool is_bound() const { return internal_state_.is_bound(); } | 83 bool is_bound() const { return internal_state_.is_bound(); } |
82 | 84 |
83 // Returns a raw pointer to the local proxy. Caller does not take ownership. | 85 // Returns a raw pointer to the local proxy. Caller does not take ownership. |
84 // Note that the local proxy is thread hostile, as stated above. | 86 // Note that the local proxy is thread hostile, as stated above. |
85 Interface* get() const { return internal_state_.instance(); } | 87 Interface* get() const { return internal_state_.instance(); } |
86 | 88 |
87 // Functions like a pointer to Interface. Must already be bound. | 89 // Functions like a pointer to Interface. Must already be bound. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 212 |
211 // If |info| is valid (containing a valid message pipe handle), returns an | 213 // If |info| is valid (containing a valid message pipe handle), returns an |
212 // InterfacePtr bound to it. Otherwise, returns an unbound InterfacePtr. The | 214 // InterfacePtr bound to it. Otherwise, returns an unbound InterfacePtr. The |
213 // specified |waiter| will be used as in the InterfacePtr::Bind() method. | 215 // specified |waiter| will be used as in the InterfacePtr::Bind() method. |
214 template <typename Interface> | 216 template <typename Interface> |
215 InterfacePtr<Interface> MakeProxy( | 217 InterfacePtr<Interface> MakeProxy( |
216 InterfacePtrInfo<Interface> info, | 218 InterfacePtrInfo<Interface> info, |
217 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { | 219 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
218 InterfacePtr<Interface> ptr; | 220 InterfacePtr<Interface> ptr; |
219 if (info.is_valid()) | 221 if (info.is_valid()) |
220 ptr.Bind(info.Pass(), waiter); | 222 ptr.Bind(std::move(info), waiter); |
221 return ptr.Pass(); | 223 return std::move(ptr); |
222 } | 224 } |
223 | 225 |
224 } // namespace mojo | 226 } // namespace mojo |
225 | 227 |
226 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ | 228 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ |
OLD | NEW |