Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: mojo/public/cpp/bindings/binding.h

Issue 1682113003: Mojo C++ bindings: Generate InterfaceHandle<> instead of InterfacePtr<>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase ontop of master, address trung's comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/application/lib/service_registry.cc ('k') | mojo/public/cpp/bindings/interface_handle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..61630c799f9b26eb19bc4d990b515ae7dc254c68 100644
--- a/mojo/public/cpp/bindings/binding.h
+++ b/mojo/public/cpp/bindings/binding.h
@@ -82,6 +82,8 @@ 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): Deprecate this in favor of the |InterfaceHandle<>| overload
+ // below.
Binding(Interface* impl,
InterfacePtr<Interface>* ptr,
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter())
@@ -89,6 +91,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 +146,8 @@ 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 in favor of the |InterfaceHandle<>| overload
+ // below.
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|.
« no previous file with comments | « mojo/public/cpp/application/lib/service_registry.cc ('k') | mojo/public/cpp/bindings/interface_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698