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