Index: mojo/public/cpp/application/application_connection.h |
diff --git a/mojo/public/cpp/application/application_connection.h b/mojo/public/cpp/application/application_connection.h |
index 2044af10a5a86cd935438839d92dc5a939abb25e..1784941896662e58c789f998f54d9387779454c0 100644 |
--- a/mojo/public/cpp/application/application_connection.h |
+++ b/mojo/public/cpp/application/application_connection.h |
@@ -7,6 +7,7 @@ |
#include <string> |
+#include "mojo/public/cpp/application/interface_factory.h" |
#include "mojo/public/cpp/application/lib/service_connector.h" |
namespace mojo { |
@@ -21,51 +22,26 @@ namespace mojo { |
// to implement a service named Foo. |
// That class must subclass an InterfaceImpl specialization. |
// |
-// If there is context that is to be shared amongst all instances, define a |
-// constructor with that class as its only argument, otherwise define an empty |
-// constructor. |
+// Then implement an InterfaceFactory<Foo> that binds instances of FooImpl to |
+// InterfaceRequest<Foo>s and register that on the connection. |
// |
-// class FooImpl : public InterfaceImpl<Foo> { |
-// public: |
-// explicit FooImpl(ApplicationConnnection* connection) {} |
-// }; |
+// connection->AddServiceFactory(&factory); |
// |
-// or |
+// Or if you have multiple factories implemented by the same type, explicitly |
+// specify the interface to register the factory for: |
// |
-// class BarImpl : public InterfaceImpl<Bar> { |
-// public: |
-// // contexts will remain valid for the lifetime of BarImpl. |
-// BarImpl(ApplicationConnnection* connection, BarContext* service_context) |
-// : connection_(connection), servicecontext_(context) {} |
+// connection->AddServiceFactory<Foo>(&my_foo_and_bar_factory_); |
+// connection->AddServiceFactory<Bar>(&my_foo_and_bar_factory_); |
// |
-// Create an ApplicationDelegate instance and pass it to the constructor |
-// of an ApplicationImpl. The delegate will be called when new connections are |
-// made to other applications. |
-// |
-// connection->AddService<FooImpl>(); |
-// |
-// BarContext context; |
-// connection->AddService<BarImpl>(&context); |
+// The InterfaceFactory must outlive the ApplicationConnection. |
tim (not reviewing)
2014/07/16 17:57:09
I'm a bit confused here. I don't see any changes t
jamesr
2014/07/17 22:22:50
Right, and the service connector maintains a raw p
|
class ApplicationConnection { |
public: |
virtual ~ApplicationConnection(); |
- // Impl’s constructor will receive two arguments: |
- // Impl::Impl(Application::Context* app_context, |
- // ServiceContext* svc_context) |
- template <typename Impl, typename ServiceContext> |
- void AddService(ServiceContext* context) { |
- AddServiceConnector( |
- new internal::ServiceConnector<Impl, ServiceContext>(Impl::Name_, |
- context)); |
- } |
- |
- // Impl’s constructor will receive one argument: |
- // Impl::Impl(Application::Context* app_context) |
- template <typename Impl> |
- void AddService() { |
+ template <typename Interface> |
+ void AddServiceFactory(InterfaceFactory<Interface>* factory) { |
AddServiceConnector( |
- new internal::ServiceConnector<Impl, void>(Impl::Name_, NULL)); |
+ new internal::InterfaceFactoryConnector<Interface>(factory)); |
} |
// Connect to the service implementing |Interface|. |