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

Unified Diff: mojo/public/cpp/bindings/strong_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
Index: mojo/public/cpp/bindings/strong_binding.h
diff --git a/mojo/public/cpp/bindings/strong_binding.h b/mojo/public/cpp/bindings/strong_binding.h
index e38c7ffe1ff539410772451a94109dd7ebe08c25..59097a13043d4dd3d3343df2cd05142d03266472 100644
--- a/mojo/public/cpp/bindings/strong_binding.h
+++ b/mojo/public/cpp/bindings/strong_binding.h
@@ -75,6 +75,8 @@ class StrongBinding {
// 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.
StrongBinding(
Interface* impl,
InterfacePtr<Interface>* ptr,
@@ -83,6 +85,20 @@ class StrongBinding {
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|.
+ StrongBinding(
+ Interface* impl,
+ InterfaceHandle<Interface>* ptr,
+ const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter())
+ : StrongBinding(impl) {
+ binding_.Bind(ptr, 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
@@ -115,6 +131,8 @@ class StrongBinding {
// 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()) {
@@ -123,6 +141,19 @@ class StrongBinding {
}
// 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>* ptr,
+ const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) {
+ assert(!binding_.is_bound());
+ binding_.Bind(ptr, 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/bindings/lib/bindings_serialization.h ('k') | mojo/public/cpp/bindings/tests/array_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698