| 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_BINDING_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "mojo/public/c/environment/async_waiter.h" | 11 #include "mojo/public/c/environment/async_waiter.h" |
| 12 #include "mojo/public/cpp/bindings/callback.h" | 12 #include "mojo/public/cpp/bindings/callback.h" |
| 13 #include "mojo/public/cpp/bindings/interface_handle.h" |
| 13 #include "mojo/public/cpp/bindings/interface_ptr.h" | 14 #include "mojo/public/cpp/bindings/interface_ptr.h" |
| 14 #include "mojo/public/cpp/bindings/interface_ptr_info.h" | |
| 15 #include "mojo/public/cpp/bindings/interface_request.h" | 15 #include "mojo/public/cpp/bindings/interface_request.h" |
| 16 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" | 16 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" |
| 17 #include "mojo/public/cpp/bindings/lib/router.h" | 17 #include "mojo/public/cpp/bindings/lib/router.h" |
| 18 #include "mojo/public/cpp/environment/logging.h" | 18 #include "mojo/public/cpp/environment/logging.h" |
| 19 #include "mojo/public/cpp/system/core.h" | 19 #include "mojo/public/cpp/system/core.h" |
| 20 | 20 |
| 21 namespace mojo { | 21 namespace mojo { |
| 22 | 22 |
| 23 // Represents the binding of an interface implementation to a message pipe. | 23 // Represents the binding of an interface implementation to a message pipe. |
| 24 // When the |Binding| object is destroyed, the binding between the message pipe | 24 // When the |Binding| object is destroyed, the binding between the message pipe |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // implementation by creating a new message pipe, binding one end of it to the | 129 // implementation by creating a new message pipe, binding one end of it to the |
| 130 // previously specified implementation, and passing the other to |ptr|, which | 130 // previously specified implementation, and passing the other to |ptr|, which |
| 131 // takes ownership of it. The caller is expected to pass |ptr| on to the | 131 // takes ownership of it. The caller is expected to pass |ptr| on to the |
| 132 // eventual client of the service. Does not take ownership of |ptr|. See | 132 // eventual client of the service. Does not take ownership of |ptr|. See |
| 133 // class comment for definition of |waiter|. | 133 // class comment for definition of |waiter|. |
| 134 void Bind( | 134 void Bind( |
| 135 InterfacePtr<Interface>* ptr, | 135 InterfacePtr<Interface>* ptr, |
| 136 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { | 136 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
| 137 MessagePipe pipe; | 137 MessagePipe pipe; |
| 138 ptr->Bind( | 138 ptr->Bind( |
| 139 InterfacePtrInfo<Interface>(pipe.handle0.Pass(), Interface::Version_), | 139 InterfaceHandle<Interface>(pipe.handle0.Pass(), Interface::Version_), |
| 140 waiter); | 140 waiter); |
| 141 Bind(pipe.handle1.Pass(), waiter); | 141 Bind(pipe.handle1.Pass(), waiter); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Completes a binding that was constructed with only an interface | 144 // Completes a binding that was constructed with only an interface |
| 145 // implementation by removing the message pipe endpoint from |request| and | 145 // implementation by removing the message pipe endpoint from |request| and |
| 146 // binding it to the previously specified implementation. See class comment | 146 // binding it to the previously specified implementation. See class comment |
| 147 // for definition of |waiter|. | 147 // for definition of |waiter|. |
| 148 void Bind( | 148 void Bind( |
| 149 InterfaceRequest<Interface> request, | 149 InterfaceRequest<Interface> request, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 typename Interface::Stub_ stub_; | 208 typename Interface::Stub_ stub_; |
| 209 Interface* impl_; | 209 Interface* impl_; |
| 210 Closure connection_error_handler_; | 210 Closure connection_error_handler_; |
| 211 | 211 |
| 212 MOJO_DISALLOW_COPY_AND_ASSIGN(Binding); | 212 MOJO_DISALLOW_COPY_AND_ASSIGN(Binding); |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 } // namespace mojo | 215 } // namespace mojo |
| 216 | 216 |
| 217 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ | 217 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ |
| OLD | NEW |