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

Unified Diff: mojo/public/cpp/application/lib/service_connector.h

Issue 380413003: Mojo: Use InterfaceFactory<Interface> for service registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: specify ownership in the Bind call Created 6 years, 5 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/application/lib/service_connector.h
diff --git a/mojo/public/cpp/application/lib/service_connector.h b/mojo/public/cpp/application/lib/service_connector.h
index d2de48b9b357b26518e51b15ca7626ed828273ea..08ac06bc11f64ab6edc39e2dc2905385167d1a85 100644
--- a/mojo/public/cpp/application/lib/service_connector.h
+++ b/mojo/public/cpp/application/lib/service_connector.h
@@ -9,6 +9,7 @@
#include <vector>
+#include "mojo/public/cpp/application/interface_provider.h"
#include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
namespace mojo {
@@ -135,6 +136,25 @@ class ServiceConnector : public internal::ServiceConnectorBase {
MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceConnector);
};
+template <typename Interface>
+class InterfaceProviderConnector : public ServiceConnectorBase {
+ public:
+ InterfaceProviderConnector(InterfaceProvider<Interface>* provider)
+ : ServiceConnectorBase(Interface::Name_), provider_(provider) {}
+ virtual ~InterfaceProviderConnector() {}
+
+ virtual void ConnectToService(const std::string& name,
+ ScopedMessagePipeHandle client_handle) {
+ InterfaceRequest<Interface> request;
+ request.Bind(client_handle.Pass());
+ provider_->BindToRequest(application_connection_, request.Pass());
+ }
+
+ private:
+ InterfaceProvider<Interface>* provider_;
+ MOJO_DISALLOW_COPY_AND_ASSIGN(InterfaceProviderConnector);
+};
+
} // namespace internal
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698