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

Unified Diff: mojo/public/cpp/application/connect.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/application_impl.h ('k') | mojo/public/cpp/application/lib/application_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/application/connect.h
diff --git a/mojo/public/cpp/application/connect.h b/mojo/public/cpp/application/connect.h
index 06b79e7e4e0cf0e085024bc759774d1b848d73ad..16efc2d98b5f8b761a923c1e4e747c8d310c4dc8 100644
--- a/mojo/public/cpp/application/connect.h
+++ b/mojo/public/cpp/application/connect.h
@@ -11,6 +11,10 @@
namespace mojo {
+// TODO(vardhan): Replaces uses of ConnectToService(.., InterfacePtr<>) with the
+// ConnectToService(.., InterfaceHandle<>) alternative instead, and get
+// rid of following 3 functions.
+
// Binds |ptr| to a remote implementation of Interface from |service_provider|.
template <typename Interface>
inline void ConnectToService(ServiceProvider* service_provider,
@@ -26,8 +30,8 @@ inline void ConnectToService(Shell* shell,
const std::string& application_url,
InterfacePtr<Interface>* ptr) {
ServiceProviderPtr service_provider;
- shell->ConnectToApplication(application_url,
- GetProxy(&service_provider), nullptr);
+ shell->ConnectToApplication(application_url, GetProxy(&service_provider),
+ nullptr);
ConnectToService(service_provider.get(), ptr);
}
@@ -42,6 +46,37 @@ inline void ConnectToService(ApplicationConnector* application_connector,
ConnectToService(service_provider.get(), ptr);
}
+// Binds |ptr| to a remote implementation of Interface from |service_provider|.
+template <typename Interface>
+inline void ConnectToService(ServiceProvider* service_provider,
+ InterfaceHandle<Interface>* ptr) {
+ MessagePipe pipe;
+ *ptr = InterfaceHandle<Interface>(pipe.handle0.Pass(), 0u);
+ service_provider->ConnectToService(Interface::Name_, pipe.handle1.Pass());
+}
+
+// Binds |ptr| to a remote implementation of Interface from |application_url|.
+template <typename Interface>
+inline void ConnectToService(Shell* shell,
+ const std::string& application_url,
+ InterfaceHandle<Interface>* ptr) {
+ ServiceProviderPtr service_provider;
+ shell->ConnectToApplication(application_url, GetProxy(&service_provider),
+ nullptr);
+ ConnectToService(service_provider.get(), ptr);
+}
+
+// Binds |ptr| to a remote implementation of Interface from |application_url|.
+template <typename Interface>
+inline void ConnectToService(ApplicationConnector* application_connector,
+ const std::string& application_url,
+ InterfaceHandle<Interface>* ptr) {
+ ServiceProviderPtr service_provider;
+ application_connector->ConnectToApplication(
+ application_url, GetProxy(&service_provider), nullptr);
+ ConnectToService(service_provider.get(), ptr);
+}
+
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_
« no previous file with comments | « mojo/public/cpp/application/application_impl.h ('k') | mojo/public/cpp/application/lib/application_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698