| 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_IMPL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_IMPL_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_IMPL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_IMPL_H_ |
| 7 | 7 |
| 8 #include "mojo/public/cpp/bindings/binding.h" | 8 #include "mojo/public/cpp/bindings/binding.h" |
| 9 #include "mojo/public/cpp/bindings/interface_ptr_info.h" |
| 9 #include "mojo/public/cpp/bindings/interface_request.h" | 10 #include "mojo/public/cpp/bindings/interface_request.h" |
| 10 #include "mojo/public/cpp/environment/environment.h" | 11 #include "mojo/public/cpp/environment/environment.h" |
| 11 #include "mojo/public/cpp/system/macros.h" | 12 #include "mojo/public/cpp/system/macros.h" |
| 12 | 13 |
| 13 namespace mojo { | 14 namespace mojo { |
| 14 | 15 |
| 15 // DEPRECATED! Please use mojo::Binding instead of InterfaceImpl<> in new code. | 16 // DEPRECATED! Please use mojo::Binding instead of InterfaceImpl<> in new code. |
| 16 // | 17 // |
| 17 // InterfaceImpl<..> is designed to be the base class of an interface | 18 // InterfaceImpl<..> is designed to be the base class of an interface |
| 18 // implementation. It may be bound to a pipe or a proxy, see BindToPipe and | 19 // implementation. It may be bound to a pipe or a proxy, see BindToPipe and |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return instance; | 135 return instance; |
| 135 } | 136 } |
| 136 | 137 |
| 137 // Like BindToProxy but does not delete the instance after a channel error. | 138 // Like BindToProxy but does not delete the instance after a channel error. |
| 138 template <typename Impl, typename Interface> | 139 template <typename Impl, typename Interface> |
| 139 Impl* WeakBindToProxy( | 140 Impl* WeakBindToProxy( |
| 140 Impl* instance, | 141 Impl* instance, |
| 141 InterfacePtr<Interface>* ptr, | 142 InterfacePtr<Interface>* ptr, |
| 142 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { | 143 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
| 143 MessagePipe pipe; | 144 MessagePipe pipe; |
| 144 ptr->Bind(pipe.handle0.Pass(), waiter); | 145 ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u), waiter); |
| 145 instance->BindToHandle(pipe.handle1.Pass(), waiter); | 146 instance->BindToHandle(pipe.handle1.Pass(), waiter); |
| 146 return instance; | 147 return instance; |
| 147 } | 148 } |
| 148 | 149 |
| 149 // Takes an instance of an InterfaceImpl<..> subclass and binds it to the given | 150 // Takes an instance of an InterfaceImpl<..> subclass and binds it to the given |
| 150 // InterfaceRequest<..>. The instance is returned for convenience in member | 151 // InterfaceRequest<..>. The instance is returned for convenience in member |
| 151 // initializer lists, etc. If the pipe is closed, the instance's | 152 // initializer lists, etc. If the pipe is closed, the instance's |
| 152 // OnConnectionError method will be called and then the instance will be | 153 // OnConnectionError method will be called and then the instance will be |
| 153 // deleted. | 154 // deleted. |
| 154 // | 155 // |
| (...skipping 13 matching lines...) Expand all Loading... |
| 168 Impl* WeakBindToRequest( | 169 Impl* WeakBindToRequest( |
| 169 Impl* instance, | 170 Impl* instance, |
| 170 InterfaceRequest<Interface>* request, | 171 InterfaceRequest<Interface>* request, |
| 171 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { | 172 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
| 172 return WeakBindToPipe(instance, request->PassMessagePipe(), waiter); | 173 return WeakBindToPipe(instance, request->PassMessagePipe(), waiter); |
| 173 } | 174 } |
| 174 | 175 |
| 175 } // namespace mojo | 176 } // namespace mojo |
| 176 | 177 |
| 177 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_IMPL_H_ | 178 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_IMPL_H_ |
| OLD | NEW |