Chromium Code Reviews| Index: mojo/public/cpp/bindings/binding.h |
| diff --git a/mojo/public/cpp/bindings/binding.h b/mojo/public/cpp/bindings/binding.h |
| index d556f0b86459b95a39dbba42db00422a28382483..20e325a54c0488bceb4c13a4ffe7c302ed7605fe 100644 |
| --- a/mojo/public/cpp/bindings/binding.h |
| +++ b/mojo/public/cpp/bindings/binding.h |
| @@ -82,6 +82,9 @@ class Binding { |
| // of the parameters. |impl| must outlive the binding. |ptr| only needs to |
| // last until the constructor returns. See class comment for definition of |
| // |waiter|. |
| + // TODO(vardhan): Considering deprecating this since it takes |InterfacePtr|. |
|
viettrungluu
2016/02/11 18:26:29
Deprecating this sounds good. Logically, its inter
vardhan
2016/02/11 22:47:53
oh true! but i guess this won't be a problem once
|
| + // It would be nice to only accept |InterfaceHandle<>| so that |Binding<>| |
| + // can abstract away details about the client's implementation. |
| Binding(Interface* impl, |
| InterfacePtr<Interface>* ptr, |
| const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) |
| @@ -89,6 +92,19 @@ class Binding { |
| Bind(ptr, waiter); |
| } |
| + // Constructs a completed binding of |impl| to a new message pipe, passing the |
| + // client end to |ptr|, which takes ownership of it. The caller is expected to |
| + // pass |ptr| on to the client of the service. Does not take ownership of any |
| + // of the parameters. |impl| must outlive the binding. |ptr| only needs to |
| + // last until the constructor returns. See class comment for definition of |
| + // |waiter|. |
| + Binding(Interface* impl, |
| + InterfaceHandle<Interface>* interface_handle, |
| + const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) |
| + : Binding(impl) { |
| + Bind(interface_handle, waiter); |
| + } |
| + |
| // Constructs a completed binding of |impl| to the message pipe endpoint in |
| // |request|, taking ownership of the endpoint. Does not take ownership of |
| // |impl|, which must outlive the binding. See class comment for definition of |
| @@ -131,6 +147,7 @@ class Binding { |
| // takes ownership of it. The caller is expected to pass |ptr| on to the |
| // eventual client of the service. Does not take ownership of |ptr|. See |
| // class comment for definition of |waiter|. |
| + // TODO(vardhan): Deprecate this? |
|
viettrungluu
2016/02/11 18:26:29
Ditto.
(Also, why are there two spaces after the
vardhan
2016/02/11 22:47:53
Done.
|
| void Bind( |
| InterfacePtr<Interface>* ptr, |
| const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
| @@ -142,6 +159,21 @@ class Binding { |
| } |
| // Completes a binding that was constructed with only an interface |
| + // implementation by creating a new message pipe, binding one end of it to the |
| + // previously specified implementation, and passing the other to |ptr|, which |
| + // takes ownership of it. The caller is expected to pass |ptr| on to the |
| + // eventual client of the service. Does not take ownership of |ptr|. See |
| + // class comment for definition of |waiter|. |
| + void Bind( |
| + InterfaceHandle<Interface>* interface_handle, |
| + const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
| + MessagePipe pipe; |
| + *interface_handle = |
| + InterfaceHandle<Interface>(pipe.handle0.Pass(), Interface::Version_); |
| + Bind(pipe.handle1.Pass(), waiter); |
| + } |
| + |
| + // Completes a binding that was constructed with only an interface |
| // implementation by removing the message pipe endpoint from |request| and |
| // binding it to the previously specified implementation. See class comment |
| // for definition of |waiter|. |