ApplicationConnection devolution, part 2.5.

A.k.a. nuke InterfaceFactory, part 5 (the last one of this series).

InterfaceFactory is now gone (and so is InterfaceFactoryConnector).

And the pointlessness of ApplicationConnection is now totally obvious.

R=vardhan@google.com

Review URL: https://codereview.chromium.org/1977123002 .
diff --git a/mojo/public/cpp/application/BUILD.gn b/mojo/public/cpp/application/BUILD.gn
index 9bd8474..dda638c 100644
--- a/mojo/public/cpp/application/BUILD.gn
+++ b/mojo/public/cpp/application/BUILD.gn
@@ -12,11 +12,9 @@
     "application_impl.h",
     "connect.h",
     "connection_context.h",
-    "interface_factory.h",
     "lib/application_connection.cc",
     "lib/application_delegate.cc",
     "lib/application_impl.cc",
-    "lib/interface_factory_connector.h",
     "lib/service_connector_registry.cc",
     "lib/service_connector_registry.h",
     "lib/service_provider_impl.cc",
diff --git a/mojo/public/cpp/application/application_connection.h b/mojo/public/cpp/application/application_connection.h
index 49a0da8..e10b7b1 100644
--- a/mojo/public/cpp/application/application_connection.h
+++ b/mojo/public/cpp/application/application_connection.h
@@ -5,54 +5,20 @@
 #ifndef MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_
 #define MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_
 
-#include <memory>
-#include <string>
-
-#include "mojo/public/cpp/application/lib/interface_factory_connector.h"
 #include "mojo/public/cpp/application/service_provider_impl.h"
-#include "mojo/public/interfaces/application/service_provider.mojom.h"
 
 namespace mojo {
 
-struct ConnectionContext;
-class ServiceConnector;
-
 // Represents a connection to another application. An instance of this class is
 // passed to ApplicationDelegate's ConfigureIncomingConnection() method each
 // time a connection is made to this app, and is returned by the
 // ApplicationDelegate's ConnectToApplication() method when this app
 // connects to another.
-//
-// To use, define a class that implements your specific service API (e.g.,
-// FooImpl to implement a service named Foo). Then implement an
-// InterfaceFactory<Foo> that binds instances of FooImpl to
-// InterfaceRequest<Foo>s and register that on the connection like this:
-//
-//   connection->AddService(&factory);
-//
-// Or, if you have multiple factories implemented by the same type, explicitly
-// specify the interface to register the factory for:
-//
-//   connection->AddService<Foo>(&my_foo_and_bar_factory_);
-//   connection->AddService<Bar>(&my_foo_and_bar_factory_);
-//
-// The InterfaceFactory must outlive the ApplicationConnection.
-//
 // TODO(vtl): Don't get too attached to this class. I'm going to remove it.
 class ApplicationConnection {
  public:
   virtual ~ApplicationConnection();
 
-  // Makes Interface available as a service to the remote application.
-  // |factory| will create implementations of Interface on demand.
-  template <typename Interface>
-  void AddService(InterfaceFactory<Interface>* factory) {
-    GetServiceProviderImpl().AddServiceForName(
-        std::unique_ptr<ServiceConnector>(
-            new internal::InterfaceFactoryConnector<Interface>(factory)),
-        Interface::Name_);
-  }
-
   virtual ServiceProviderImpl& GetServiceProviderImpl() = 0;
 };
 
diff --git a/mojo/public/cpp/application/application_impl.h b/mojo/public/cpp/application/application_impl.h
index bd6f50c..b4038dc 100644
--- a/mojo/public/cpp/application/application_impl.h
+++ b/mojo/public/cpp/application/application_impl.h
@@ -26,11 +26,10 @@
 //
 // Typically, you create one or more classes implementing your APIs (e.g.,
 // FooImpl implementing Foo). See bindings/binding.h for more information. Then
-// you implement an mojo::ApplicationDelegate that either is or owns a
-// mojo::InterfaceFactory<Foo> and whose ConfigureIncomingConnection() adds that
-// factory to each connection. Finally, you instantiate your delegate and pass
-// it to an ApplicationRunner, which will create the ApplicationImpl and then
-// run a message (or run) loop.
+// you implement an mojo::ApplicationDelegate whose
+// ConfigureIncomingConnection() adds services to each connection. Finally, you
+// instantiate your delegate and pass it to an ApplicationRunner, which will
+// create the ApplicationImpl and then run a message (or run) loop.
 class ApplicationImpl : public Application {
  public:
   // Does not take ownership of |delegate|, which must remain valid for the
diff --git a/mojo/public/cpp/application/interface_factory.h b/mojo/public/cpp/application/interface_factory.h
deleted file mode 100644
index f459f6f..0000000
--- a/mojo/public/cpp/application/interface_factory.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_PUBLIC_CPP_APPLICATION_INTERFACE_FACTORY_H_
-#define MOJO_PUBLIC_CPP_APPLICATION_INTERFACE_FACTORY_H_
-
-#include "mojo/public/cpp/bindings/interface_request.h"
-
-namespace mojo {
-
-struct ConnectionContext;
-
-// Implement this class to provide implementations of a given interface and
-// bind them to incoming requests. The implementation of this class is
-// responsible for managing the lifetime of the implementations of the
-// interface.
-template <typename Interface>
-class InterfaceFactory {
- public:
-  virtual ~InterfaceFactory() {}
-  virtual void Create(const ConnectionContext& connection_context,
-                      InterfaceRequest<Interface> request) = 0;
-};
-
-}  // namespace mojo
-
-#endif  // MOJO_PUBLIC_CPP_APPLICATION_INTERFACE_FACTORY_H_
diff --git a/mojo/public/cpp/application/lib/interface_factory_connector.h b/mojo/public/cpp/application/lib/interface_factory_connector.h
deleted file mode 100644
index 0879636..0000000
--- a/mojo/public/cpp/application/lib/interface_factory_connector.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_INTERFACE_FACTORY_CONNECTOR_H_
-#define MOJO_PUBLIC_CPP_APPLICATION_LIB_INTERFACE_FACTORY_CONNECTOR_H_
-
-#include "mojo/public/cpp/application/interface_factory.h"
-#include "mojo/public/cpp/application/service_connector.h"
-#include "mojo/public/cpp/bindings/interface_request.h"
-
-namespace mojo {
-namespace internal {
-
-template <typename Interface>
-class InterfaceFactoryConnector : public ServiceConnector {
- public:
-  explicit InterfaceFactoryConnector(InterfaceFactory<Interface>* factory)
-      : factory_(factory) {}
-  ~InterfaceFactoryConnector() override {}
-
-  void ConnectToService(const ConnectionContext& connection_context,
-                        const std::string& interface_name,
-                        ScopedMessagePipeHandle client_handle) override {
-    factory_->Create(connection_context,
-                     InterfaceRequest<Interface>(client_handle.Pass()));
-  }
-
- private:
-  InterfaceFactory<Interface>* factory_;
-  MOJO_DISALLOW_COPY_AND_ASSIGN(InterfaceFactoryConnector);
-};
-
-}  // namespace internal
-}  // namespace mojo
-
-#endif  // MOJO_PUBLIC_CPP_APPLICATION_LIB_INTERFACE_FACTORY_CONNECTOR_H_