Chromium Code Reviews| 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..fd424d06ca01875b1de21deb11e2f2453bb91b31 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,24 @@ 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 a InterfaceFactory<Foo> that binds instances of FooImpl to | 
| 
 
darin (slow to review)
2014/07/15 06:10:37
nit: "a" -> "an"
 
 | 
| +// 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) {} | 
| -// | 
| -// 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); | 
| +// connection->AddServiceFactory<Foo>(&my_foo_and_bar_factory_); | 
| +// connection->AddServiceFactory<Bar>(&my_foo_and_bar_factory_); | 
| 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) { | 
| 
 
darin (slow to review)
2014/07/15 06:10:37
you probably want to say somewhere that the Interf
 
 | 
| AddServiceConnector( | 
| - new internal::ServiceConnector<Impl, void>(Impl::Name_, NULL)); | 
| + new internal::InterfaceFactoryConnector<Interface>(factory)); | 
| } | 
| // Connect to the service implementing |Interface|. |