ApplicationConnection devolution, part 2.4.

A.k.a. nuke InterfaceFactory, part 4.

I took care of ContentHandlerFactory in a way that seems OK, but may not
be optimal design-wise (to be considered later -- I'll actually need to
think about its design).

R=vardhan@google.com

Review URL: https://codereview.chromium.org/1979683002 .
diff --git a/examples/forwarding_content_handler/forwarding_content_handler.cc b/examples/forwarding_content_handler/forwarding_content_handler.cc
index f7cfaca..87730f2 100644
--- a/examples/forwarding_content_handler/forwarding_content_handler.cc
+++ b/examples/forwarding_content_handler/forwarding_content_handler.cc
@@ -59,7 +59,8 @@
  private:
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->AddService(&content_handler_factory_);
+    connection->GetServiceProviderImpl().AddService<ContentHandler>(
+        content_handler_factory_.GetInterfaceRequestHandler());
     return true;
   }
 
diff --git a/examples/recursive_content_handler/recursive_content_handler.cc b/examples/recursive_content_handler/recursive_content_handler.cc
index 874856c..e246a1f 100644
--- a/examples/recursive_content_handler/recursive_content_handler.cc
+++ b/examples/recursive_content_handler/recursive_content_handler.cc
@@ -24,7 +24,8 @@
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(
       ApplicationConnection* connection) override {
-    connection->AddService(&content_handler_factory_);
+    connection->GetServiceProviderImpl().AddService<ContentHandler>(
+        content_handler_factory_.GetInterfaceRequestHandler());
     return true;
   }
 
diff --git a/mojo/application/content_handler_factory.cc b/mojo/application/content_handler_factory.cc
index 34c0ee4..b3c7a26 100644
--- a/mojo/application/content_handler_factory.cc
+++ b/mojo/application/content_handler_factory.cc
@@ -113,10 +113,22 @@
 }  // namespace
 
 ContentHandlerFactory::ContentHandlerFactory(Delegate* delegate)
-    : delegate_(delegate) {
+    : delegate_(delegate) {}
+
+ContentHandlerFactory::~ContentHandlerFactory() {}
+
+void ContentHandlerFactory::Create(
+    const ConnectionContext& connection_context,
+    InterfaceRequest<ContentHandler> content_handler_request) {
+  new ContentHandlerImpl(delegate_, content_handler_request.Pass());
 }
 
-ContentHandlerFactory::~ContentHandlerFactory() {
+ServiceProviderImpl::InterfaceRequestHandler<ContentHandler>
+ContentHandlerFactory::GetInterfaceRequestHandler() {
+  return [this](const ConnectionContext& connection_context,
+                InterfaceRequest<ContentHandler> content_handler_request) {
+    Create(connection_context, content_handler_request.Pass());
+  };
 }
 
 void ContentHandlerFactory::ManagedDelegate::RunApplication(
@@ -129,9 +141,4 @@
     loop.Run();
 }
 
-void ContentHandlerFactory::Create(const ConnectionContext& connection_context,
-                                   InterfaceRequest<ContentHandler> request) {
-  new ContentHandlerImpl(delegate_, request.Pass());
-}
-
 }  // namespace mojo
diff --git a/mojo/application/content_handler_factory.h b/mojo/application/content_handler_factory.h
index 0d1d3e9..86293df 100644
--- a/mojo/application/content_handler_factory.h
+++ b/mojo/application/content_handler_factory.h
@@ -6,14 +6,17 @@
 #define MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_
 
 #include "base/memory/scoped_ptr.h"
-#include "mojo/public/cpp/application/interface_factory.h"
+#include "mojo/public/cpp/application/service_provider_impl.h"
 #include "mojo/public/interfaces/application/shell.mojom.h"
 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h"
 #include "mojo/services/network/interfaces/url_loader.mojom.h"
 
 namespace mojo {
 
-class ContentHandlerFactory : public InterfaceFactory<ContentHandler> {
+struct ConnectionContext;
+
+// TODO(vtl): Should this even be a class, now that InterfaceFactory is no more?
+class ContentHandlerFactory {
  public:
   class HandledApplicationHolder {
    public:
@@ -47,13 +50,17 @@
   };
 
   explicit ContentHandlerFactory(Delegate* delegate);
-  ~ContentHandlerFactory() override;
+  ~ContentHandlerFactory();
+
+  // Creates a content handler for the given connection (context and request).
+  void Create(const ConnectionContext& connection_context,
+              InterfaceRequest<ContentHandler> content_handler_request);
+
+  // For use with |ServiceProviderImpl::AddService<ContentHandler>()|.
+  ServiceProviderImpl::InterfaceRequestHandler<ContentHandler>
+  GetInterfaceRequestHandler();
 
  private:
-  // From InterfaceFactory:
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<ContentHandler> request) override;
-
   Delegate* delegate_;
 
   DISALLOW_COPY_AND_ASSIGN(ContentHandlerFactory);
diff --git a/services/dart/content_handler_main.cc b/services/dart/content_handler_main.cc
index a8c6d2a..44acb66 100644
--- a/services/dart/content_handler_main.cc
+++ b/services/dart/content_handler_main.cc
@@ -242,9 +242,11 @@
                                           .connection_context()
                                           .connection_url);
     if (default_strict_ || strict) {
-      connection->AddService(&strict_content_handler_factory_);
+      connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+          strict_content_handler_factory_.GetInterfaceRequestHandler());
     } else {
-      connection->AddService(&content_handler_factory_);
+      connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+          content_handler_factory_.GetInterfaceRequestHandler());
     }
     return true;
   }
diff --git a/services/java_handler/java_handler.cc b/services/java_handler/java_handler.cc
index 6493233..d8e2d91 100644
--- a/services/java_handler/java_handler.cc
+++ b/services/java_handler/java_handler.cc
@@ -120,7 +120,8 @@
 
 bool JavaHandler::ConfigureIncomingConnection(
     mojo::ApplicationConnection* connection) {
-  connection->AddService(&content_handler_factory_);
+  connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+      content_handler_factory_.GetInterfaceRequestHandler());
   return true;
 }
 
diff --git a/services/js/content_handler_main.cc b/services/js/content_handler_main.cc
index 43cbcb8..e102661 100644
--- a/services/js/content_handler_main.cc
+++ b/services/js/content_handler_main.cc
@@ -32,7 +32,8 @@
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService(&content_handler_factory_);
+    connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+        content_handler_factory_.GetInterfaceRequestHandler());
     return true;
   }
 
diff --git a/services/nacl/nonsfi/content_handler_main_nexe.cc b/services/nacl/nonsfi/content_handler_main_nexe.cc
index 441ceda..003bfbe 100644
--- a/services/nacl/nonsfi/content_handler_main_nexe.cc
+++ b/services/nacl/nonsfi/content_handler_main_nexe.cc
@@ -28,7 +28,8 @@
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService(&content_handler_factory_);
+    connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+        content_handler_factory_.GetInterfaceRequestHandler());
     return true;
   }
 
diff --git a/services/nacl/nonsfi/content_handler_main_pexe.cc b/services/nacl/nonsfi/content_handler_main_pexe.cc
index 7fcc2a1..4e0bb76 100644
--- a/services/nacl/nonsfi/content_handler_main_pexe.cc
+++ b/services/nacl/nonsfi/content_handler_main_pexe.cc
@@ -51,7 +51,8 @@
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService(&content_handler_factory_);
+    connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+        content_handler_factory_.GetInterfaceRequestHandler());
     return true;
   }
 
diff --git a/services/nacl/sfi/content_handler_main.cc b/services/nacl/sfi/content_handler_main.cc
index a5ebec6..dcca4a7 100644
--- a/services/nacl/sfi/content_handler_main.cc
+++ b/services/nacl/sfi/content_handler_main.cc
@@ -105,7 +105,8 @@
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService(&content_handler_factory_);
+    connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+        content_handler_factory_.GetInterfaceRequestHandler());
     return true;
   }
 
diff --git a/services/python/content_handler/content_handler_main.cc b/services/python/content_handler/content_handler_main.cc
index be6897d..d4d6f0a 100644
--- a/services/python/content_handler/content_handler_main.cc
+++ b/services/python/content_handler/content_handler_main.cc
@@ -215,10 +215,13 @@
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
     if (IsDebug(connection->GetServiceProviderImpl()
                     .connection_context()
-                    .connection_url))
-      connection->AddService(&debug_content_handler_factory_);
-    else
-      connection->AddService(&content_handler_factory_);
+                    .connection_url)) {
+      connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+          debug_content_handler_factory_.GetInterfaceRequestHandler());
+    } else {
+      connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+          content_handler_factory_.GetInterfaceRequestHandler());
+    }
     return true;
   }
 
diff --git a/shell/android/android_handler.cc b/shell/android/android_handler.cc
index c52b340..2f0097f 100644
--- a/shell/android/android_handler.cc
+++ b/shell/android/android_handler.cc
@@ -132,7 +132,8 @@
 
 bool AndroidHandler::ConfigureIncomingConnection(
     mojo::ApplicationConnection* connection) {
-  connection->AddService(&content_handler_factory_);
+  connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+      content_handler_factory_.GetInterfaceRequestHandler());
   return true;
 }