ApplicationConnection devolution, part 2.1.

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

R=vardhan@google.com

Review URL: https://codereview.chromium.org/1975253002 .
diff --git a/examples/apptest/example_service_application.cc b/examples/apptest/example_service_application.cc
index 0487194..de483b5 100644
--- a/examples/apptest/example_service_application.cc
+++ b/examples/apptest/example_service_application.cc
@@ -18,17 +18,15 @@
 
 bool ExampleServiceApplication::ConfigureIncomingConnection(
     ApplicationConnection* connection) {
-  connection->AddService<ExampleService>(this);
+  connection->GetServiceProviderImpl().AddService<ExampleService>(
+      [](const ConnectionContext& connection_context,
+         InterfaceRequest<ExampleService> example_service_request) {
+        // Not leaked: ExampleServiceImpl is strongly bound to the pipe.
+        new ExampleServiceImpl(example_service_request.Pass());
+      });
   return true;
 }
 
-void ExampleServiceApplication::Create(
-    const ConnectionContext& connection_context,
-    InterfaceRequest<ExampleService> request) {
-  // Not leaked: ExampleServiceImpl is strongly bound to the pipe.
-  new ExampleServiceImpl(request.Pass());
-}
-
 }  // namespace mojo
 
 MojoResult MojoMain(MojoHandle application_request) {
diff --git a/examples/apptest/example_service_application.h b/examples/apptest/example_service_application.h
index e0a8cee..3e8602e 100644
--- a/examples/apptest/example_service_application.h
+++ b/examples/apptest/example_service_application.h
@@ -7,15 +7,13 @@
 
 #include "examples/apptest/example_service_impl.h"
 #include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/interface_factory.h"
 #include "mojo/public/cpp/system/macros.h"
 
 namespace mojo {
 
 class ApplicationConnection;
 
-class ExampleServiceApplication : public ApplicationDelegate,
-                                  public InterfaceFactory<ExampleService> {
+class ExampleServiceApplication : public ApplicationDelegate {
  public:
   ExampleServiceApplication();
   ~ExampleServiceApplication() override;
@@ -25,10 +23,6 @@
   bool ConfigureIncomingConnection(
       ApplicationConnection* connection) override;
 
-  // InterfaceFactory<ExampleService> implementation.
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<ExampleService> request) override;
-
   MOJO_DISALLOW_COPY_AND_ASSIGN(ExampleServiceApplication);
 };
 
diff --git a/examples/bank_app/bank.cc b/examples/bank_app/bank.cc
index 4593b13..ea70adc 100644
--- a/examples/bank_app/bank.cc
+++ b/examples/bank_app/bank.cc
@@ -12,7 +12,6 @@
 #include "mojo/public/cpp/application/application_impl.h"
 #include "mojo/public/cpp/application/application_runner.h"
 #include "mojo/public/cpp/application/connect.h"
-#include "mojo/public/cpp/application/interface_factory.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
 #include "mojo/public/cpp/utility/run_loop.h"
 #include "mojo/services/vanadium/security/interfaces/principal.mojom.h"
@@ -46,8 +45,7 @@
   std::string *user_;
 };
 
-class BankApp : public mojo::ApplicationDelegate,
-                public mojo::InterfaceFactory<Bank> {
+class BankApp : public mojo::ApplicationDelegate {
  public:
   BankApp() {}
 
@@ -79,15 +77,14 @@
       }
       MOJO_LOG(INFO) << "Customer " << user << " accessing bank";
     }
-    connection->AddService(this);
+    connection->GetServiceProviderImpl().AddService<Bank>(
+        [this](const mojo::ConnectionContext& connection_context,
+               mojo::InterfaceRequest<Bank> bank_request) {
+          bindings_.AddBinding(&bank_impl_, bank_request.Pass());
+        });
     return true;
   }
 
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<Bank> request) override {
-    bindings_.AddBinding(&bank_impl_, request.Pass());
-  }
-
  private:
   BankImpl bank_impl_;
   mojo::BindingSet<Bank> bindings_;
diff --git a/examples/content_handler_demo/content_handler_demo.cc b/examples/content_handler_demo/content_handler_demo.cc
index 24fbd52..d0b0552 100644
--- a/examples/content_handler_demo/content_handler_demo.cc
+++ b/examples/content_handler_demo/content_handler_demo.cc
@@ -92,8 +92,7 @@
   MOJO_DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl);
 };
 
-class ContentHandlerApp : public ApplicationDelegate,
-                          public InterfaceFactory<ContentHandler> {
+class ContentHandlerApp : public ApplicationDelegate {
  public:
   ContentHandlerApp() {}
   ~ContentHandlerApp() override {}
@@ -101,15 +100,14 @@
   void Initialize(ApplicationImpl* app) override {}
 
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->AddService(this);
+    connection->GetServiceProviderImpl().AddService<ContentHandler>(
+        [](const ConnectionContext& connection_context,
+           InterfaceRequest<ContentHandler> content_handler_request) {
+          new ContentHandlerImpl(content_handler_request.Pass());
+        });
     return true;
   }
 
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<ContentHandler> request) override {
-    new ContentHandlerImpl(request.Pass());
-  }
-
  private:
   MOJO_DISALLOW_COPY_AND_ASSIGN(ContentHandlerApp);
 };
diff --git a/examples/echo/README.md b/examples/echo/README.md
index 04c5c00..52c3ec3 100644
--- a/examples/echo/README.md
+++ b/examples/echo/README.md
@@ -127,23 +127,22 @@
 
 echo_server.cc contains three different types of servers, though only one can be
 used at a time. To try changing the server, uncomment one of the lines in
-MojoMain. These different `ApplicationDelegate` derivations demonstrate how
-differently the `InterfaceFactory` can be created.  Each server derives from
-`InterfaceFactory`, which implements an interface and binds it to incoming
-requests.
+MojoMain. These different `ApplicationDelegate` derivations demonstrate
+different ways in which incoming requests can be handled.
 
 All three servers, being `ApplicationDelegate` derivations, implement
 `ConfigureIncomingConnection` in the same way:
 
 ```
-connection->AddService<Echo>(this);
+connection->GetServiceProviderImpl().AddService<Echo>(
+    [this](const mojo::ConnectionContext& connection_context,
+           mojo::InterfaceRequest<Echo> echo_request) {
+      ...
+    });
 ```
 
-This should be read as "For any incoming connections to this server, use `this`
-as a factory to create the Echo interface".
-
-Each server's `Create` method will now be called when a new connection wants
-to access the Echo interface.
+This should be read as "For any incoming connections to this server, use the
+given lambda function use `this` to create the Echo interface".
 
 ### EchoImpl: The Interface Implementation
 
diff --git a/examples/echo/echo_server.cc b/examples/echo/echo_server.cc
index 7cd54d5..2da7ede 100644
--- a/examples/echo/echo_server.cc
+++ b/examples/echo/echo_server.cc
@@ -10,7 +10,6 @@
 #include "mojo/public/cpp/application/application_connection.h"
 #include "mojo/public/cpp/application/application_delegate.h"
 #include "mojo/public/cpp/application/application_runner.h"
-#include "mojo/public/cpp/application/interface_factory.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
 
 namespace mojo {
@@ -25,8 +24,8 @@
 //    StrongBinding.
 // 2. SingletonServer -- all requests are handled by one object. Connections are
 //    tracked using BindingSet.
-// 3. OneAtATimeServer -- each Create call from InterfaceFactory<> closes the
-//    old interface pipe and binds the new interface pipe.
+// 3. OneAtATimeServer -- each request "replaces" any previous request. Any old
+//    interface pipe is closed and the new interface pipe is bound.
 
 // EchoImpl defines our implementation of the Echo interface.
 // It is used by all three server variants.
@@ -51,49 +50,43 @@
 };
 
 // MultiServer creates a new object to handle each message pipe.
-class MultiServer : public mojo::ApplicationDelegate,
-                    public mojo::InterfaceFactory<Echo> {
+class MultiServer : public mojo::ApplicationDelegate {
  public:
   MultiServer() {}
 
   // From ApplicationDelegate
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService<Echo>(this);
+    connection->GetServiceProviderImpl().AddService<Echo>(
+        [](const mojo::ConnectionContext& connection_context,
+           mojo::InterfaceRequest<Echo> echo_request) {
+          // This object will be deleted automatically because of the use of
+          // StrongBinding<> for the declaration of |strong_binding_|.
+          new StrongBindingEchoImpl(echo_request.Pass());
+        });
     return true;
   }
-
-  // From InterfaceFactory<Echo>
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<Echo> request) override {
-    // This object will be deleted automatically because of the use of
-    // StrongBinding<> for the declaration of |strong_binding_|.
-    new StrongBindingEchoImpl(request.Pass());
-  }
 };
 
 // SingletonServer uses the same object to handle all message pipes. Useful
 // for stateless operation.
-class SingletonServer : public mojo::ApplicationDelegate,
-                        public mojo::InterfaceFactory<Echo> {
+class SingletonServer : public mojo::ApplicationDelegate {
  public:
   SingletonServer() {}
 
   // From ApplicationDelegate
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService<Echo>(this);
+    connection->GetServiceProviderImpl().AddService<Echo>(
+        [this](const mojo::ConnectionContext& connection_context,
+               mojo::InterfaceRequest<Echo> echo_request) {
+          // All channels will connect to this singleton object, so just
+          // add the binding to our collection.
+          bindings_.AddBinding(&echo_impl_, echo_request.Pass());
+        });
     return true;
   }
 
-  // From InterfaceFactory<Echo>
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<Echo> request) override {
-    // All channels will connect to this singleton object, so just
-    // add the binding to our collection.
-    bindings_.AddBinding(&echo_impl_, request.Pass());
-  }
-
  private:
   EchoImpl echo_impl_;
 
@@ -106,24 +99,21 @@
 // not reliable. There's a race condition because a second client could bind
 // to the server before the first client called EchoString(). Therefore, this
 // is an example of how not to write your code.
-class OneAtATimeServer : public mojo::ApplicationDelegate,
-                         public mojo::InterfaceFactory<Echo> {
+class OneAtATimeServer : public mojo::ApplicationDelegate {
  public:
   OneAtATimeServer() : binding_(&echo_impl_) {}
 
   // From ApplicationDelegate
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService<Echo>(this);
+    connection->GetServiceProviderImpl().AddService<Echo>(
+        [this](const mojo::ConnectionContext& connection_context,
+               mojo::InterfaceRequest<Echo> echo_request) {
+          binding_.Bind(echo_request.Pass());
+        });
     return true;
   }
 
-  // From InterfaceFactory<Echo>
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<Echo> request) override {
-    binding_.Bind(request.Pass());
-  }
-
  private:
   EchoImpl echo_impl_;
 
diff --git a/examples/echo_terminal/main.cc b/examples/echo_terminal/main.cc
index 348d96c..14c7c3f 100644
--- a/examples/echo_terminal/main.cc
+++ b/examples/echo_terminal/main.cc
@@ -13,7 +13,6 @@
 #include "mojo/public/c/system/main.h"
 #include "mojo/public/cpp/application/application_connection.h"
 #include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/interface_factory.h"
 #include "mojo/services/files/interfaces/file.mojom.h"
 #include "mojo/services/files/interfaces/types.mojom.h"
 #include "mojo/services/terminal/interfaces/terminal_client.mojom.h"
@@ -98,7 +97,6 @@
 
 class EchoTerminalApp
     : public mojo::ApplicationDelegate,
-      public mojo::InterfaceFactory<mojo::terminal::TerminalClient>,
       public mojo::terminal::TerminalClient {
  public:
   EchoTerminalApp() {}
@@ -108,17 +106,16 @@
   // |ApplicationDelegate| override:
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService<mojo::terminal::TerminalClient>(this);
+    connection->GetServiceProviderImpl()
+        .AddService<mojo::terminal::TerminalClient>([this](
+            const mojo::ConnectionContext& connection_context,
+            mojo::InterfaceRequest<mojo::terminal::TerminalClient>
+                terminal_client_request) {
+          terminal_clients_.AddBinding(this, terminal_client_request.Pass());
+        });
     return true;
   }
 
-  // |InterfaceFactory<mojo::terminal::TerminalClient>| implementation:
-  void Create(
-      const mojo::ConnectionContext& connection_context,
-      mojo::InterfaceRequest<mojo::terminal::TerminalClient> request) override {
-    terminal_clients_.AddBinding(this, request.Pass());
-  }
-
   // |mojo::terminal::TerminalClient| implementation:
   void ConnectToTerminal(
       mojo::InterfaceHandle<mojo::files::File> terminal) override {
diff --git a/examples/hello_mojo/hello_mojo_server.cc b/examples/hello_mojo/hello_mojo_server.cc
index 6d0060a..61a3c2e 100644
--- a/examples/hello_mojo/hello_mojo_server.cc
+++ b/examples/hello_mojo/hello_mojo_server.cc
@@ -11,7 +11,6 @@
 #include "mojo/public/cpp/application/application_connection.h"
 #include "mojo/public/cpp/application/application_delegate.h"
 #include "mojo/public/cpp/application/application_runner.h"
-#include "mojo/public/cpp/application/interface_factory.h"
 #include "mojo/public/cpp/bindings/interface_request.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
 #include "mojo/public/cpp/system/macros.h"
@@ -38,8 +37,7 @@
   MOJO_DISALLOW_COPY_AND_ASSIGN(HelloMojoImpl);
 };
 
-class HelloMojoServerApp : public mojo::ApplicationDelegate,
-                           public mojo::InterfaceFactory<HelloMojo> {
+class HelloMojoServerApp : public mojo::ApplicationDelegate {
  public:
   HelloMojoServerApp() {}
   ~HelloMojoServerApp() override {}
@@ -47,16 +45,14 @@
   // |mojo::ApplicationDelegate| implementation:
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* application_connection) override {
-    application_connection->AddService<HelloMojo>(this);
+    application_connection->GetServiceProviderImpl().AddService<HelloMojo>(
+        [](const mojo::ConnectionContext& connection_context,
+           mojo::InterfaceRequest<HelloMojo> hello_mojo_request) {
+          new HelloMojoImpl(std::move(hello_mojo_request));  // Owns itself.
+        });
     return true;
   }
 
-  // |mojo::InterfaceFactory<HelloMojo>| implementation:
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<HelloMojo> hello_mojo_request) override {
-    new HelloMojoImpl(std::move(hello_mojo_request));  // Owns itself.
-  }
-
  private:
   MOJO_DISALLOW_COPY_AND_ASSIGN(HelloMojoServerApp);
 };
diff --git a/examples/indirect_service/indirect_integer_service.cc b/examples/indirect_service/indirect_integer_service.cc
index 137eb10..c5bff99 100644
--- a/examples/indirect_service/indirect_integer_service.cc
+++ b/examples/indirect_service/indirect_integer_service.cc
@@ -49,22 +49,17 @@
   StrongBinding<IndirectIntegerService> binding_;
 };
 
-class IndirectIntegerServiceAppDelegate
-    : public ApplicationDelegate,
-      public InterfaceFactory<IndirectIntegerService> {
+class IndirectIntegerServiceAppDelegate : public ApplicationDelegate {
  public:
   bool ConfigureIncomingConnection(
       ApplicationConnection* connection) override {
-    connection->AddService(this);
+    connection->GetServiceProviderImpl().AddService<IndirectIntegerService>(
+        [](const ConnectionContext& connection_context,
+           InterfaceRequest<IndirectIntegerService> request) {
+          new IndirectIntegerServiceImpl(request.Pass());
+        });
     return true;
   }
-
- private:
-  // InterfaceFactory<IndirectIntegerService>
-  void Create(const mojo::ConnectionContext& connection_context,
-              InterfaceRequest<IndirectIntegerService> request) override {
-    new IndirectIntegerServiceImpl(request.Pass());
-  }
 };
 
 }  // namespace examples
diff --git a/examples/indirect_service/integer_service.cc b/examples/indirect_service/integer_service.cc
index 4927267..6e8b6ac 100644
--- a/examples/indirect_service/integer_service.cc
+++ b/examples/indirect_service/integer_service.cc
@@ -29,21 +29,17 @@
   StrongBinding<IntegerService> binding_;
 };
 
-class IntegerServiceAppDelegate : public ApplicationDelegate,
-                                  public InterfaceFactory<IntegerService> {
+class IntegerServiceAppDelegate : public ApplicationDelegate {
  public:
   bool ConfigureIncomingConnection(
       ApplicationConnection* connection) override {
-    connection->AddService(this);
+    connection->GetServiceProviderImpl().AddService<IntegerService>(
+        [](const ConnectionContext& connection_context,
+           InterfaceRequest<IntegerService> request) {
+          new IntegerServiceImpl(request.Pass());
+        });
     return true;
   }
-
- private:
-  // InterfaceFactory<IntegerService>
-  void Create(const mojo::ConnectionContext& connection_context,
-              InterfaceRequest<IntegerService> request) override {
-    new IntegerServiceImpl(request.Pass());
-  }
 };
 
 }  // namespace examples
diff --git a/examples/native_run_app/native_run_app.cc b/examples/native_run_app/native_run_app.cc
index 7a61636..ba75d55 100644
--- a/examples/native_run_app/native_run_app.cc
+++ b/examples/native_run_app/native_run_app.cc
@@ -28,7 +28,6 @@
 #include "mojo/public/cpp/application/application_delegate.h"
 #include "mojo/public/cpp/application/application_impl.h"
 #include "mojo/public/cpp/application/connect.h"
-#include "mojo/public/cpp/application/interface_factory.h"
 #include "mojo/public/cpp/bindings/interface_request.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
 #include "mojo/services/files/interfaces/files.mojom.h"
@@ -221,8 +220,7 @@
   DISALLOW_COPY_AND_ASSIGN(TerminalClientImpl);
 };
 
-class NativeRunApp : public mojo::ApplicationDelegate,
-                     public mojo::InterfaceFactory<TerminalClient> {
+class NativeRunApp : public mojo::ApplicationDelegate {
  public:
   NativeRunApp() : application_impl_(nullptr) {}
   ~NativeRunApp() override {}
@@ -238,16 +236,15 @@
 
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService<TerminalClient>(this);
+    connection->GetServiceProviderImpl().AddService<TerminalClient>(
+        [this](const mojo::ConnectionContext& connection_context,
+               mojo::InterfaceRequest<TerminalClient> terminal_client_request) {
+          new TerminalClientImpl(terminal_client_request.Pass(),
+                                 native_support_process_.get());
+        });
     return true;
   }
 
-  // |InterfaceFactory<TerminalClient>| implementation:
-  void Create(const mojo::ConnectionContext& /*connection_context*/,
-              mojo::InterfaceRequest<TerminalClient> request) override {
-    new TerminalClientImpl(request.Pass(), native_support_process_.get());
-  }
-
   mojo::ApplicationImpl* application_impl_;
   native_support::ProcessPtr native_support_process_;
 
diff --git a/mojo/public/cpp/bindings/tests/versioning_test_service.cc b/mojo/public/cpp/bindings/tests/versioning_test_service.cc
index 893a47d..f815889 100644
--- a/mojo/public/cpp/bindings/tests/versioning_test_service.cc
+++ b/mojo/public/cpp/bindings/tests/versioning_test_service.cc
@@ -9,7 +9,6 @@
 #include "mojo/public/cpp/application/application_connection.h"
 #include "mojo/public/cpp/application/application_delegate.h"
 #include "mojo/public/cpp/application/application_runner.h"
-#include "mojo/public/cpp/application/interface_factory.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
 #include "mojo/public/cpp/system/macros.h"
 #include "mojo/public/interfaces/bindings/tests/versioning_test_service.mojom.h"
@@ -93,25 +92,21 @@
   StrongBinding<HumanResourceDatabase> strong_binding_;
 };
 
-class HumanResourceSystemServer
-    : public ApplicationDelegate,
-      public InterfaceFactory<HumanResourceDatabase> {
+class HumanResourceSystemServer : public ApplicationDelegate {
  public:
   HumanResourceSystemServer() {}
 
   // ApplicationDelegate implementation.
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->AddService<HumanResourceDatabase>(this);
+    connection->GetServiceProviderImpl().AddService<HumanResourceDatabase>(
+        [](const ConnectionContext& connection_context,
+           InterfaceRequest<HumanResourceDatabase> hr_db_request) {
+          // It will be deleted automatically when the underlying pipe
+          // encounters a connection error.
+          new HumanResourceDatabaseImpl(hr_db_request.Pass());
+        });
     return true;
   }
-
-  // InterfaceFactory<HumanResourceDatabase> implementation.
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<HumanResourceDatabase> request) override {
-    // It will be deleted automatically when the underlying pipe encounters a
-    // connection error.
-    new HumanResourceDatabaseImpl(request.Pass());
-  }
 };
 
 }  // namespace versioning
diff --git a/mojo/ui/content_viewer_app.cc b/mojo/ui/content_viewer_app.cc
index 42d3192..a56bbcb 100644
--- a/mojo/ui/content_viewer_app.cc
+++ b/mojo/ui/content_viewer_app.cc
@@ -49,18 +49,16 @@
 
 bool ContentViewerApp::ConfigureIncomingConnection(
     mojo::ApplicationConnection* connection) {
-  connection->AddService<mojo::ContentHandler>(this);
+  connection->GetServiceProviderImpl().AddService<ContentHandler>([this](
+      const ConnectionContext& connection_context,
+      InterfaceRequest<ContentHandler> content_handler_request) {
+    bindings_.AddBinding(
+        new DelegatingContentHandler(this, connection_context.connection_url),
+        content_handler_request.Pass());
+  });
   return true;
 }
 
-void ContentViewerApp::Create(
-    const mojo::ConnectionContext& connection_context,
-    mojo::InterfaceRequest<mojo::ContentHandler> request) {
-  bindings_.AddBinding(
-      new DelegatingContentHandler(this, connection_context.connection_url),
-      request.Pass());
-}
-
 void ContentViewerApp::StartViewer(
     const std::string& content_handler_url,
     mojo::InterfaceRequest<mojo::Application> application_request,
diff --git a/mojo/ui/content_viewer_app.h b/mojo/ui/content_viewer_app.h
index 990c900..0a1f0c1 100644
--- a/mojo/ui/content_viewer_app.h
+++ b/mojo/ui/content_viewer_app.h
@@ -19,8 +19,7 @@
 // TODO(jeffbrown): Support creating the view provider application in a
 // separate thread if desired (often not the case).  This is one reason
 // we are not using the ContentHandlerFactory here.
-class ContentViewerApp : public ApplicationDelegate,
-                         public InterfaceFactory<ContentHandler> {
+class ContentViewerApp : public ApplicationDelegate {
  public:
   ContentViewerApp();
   ~ContentViewerApp() override;
@@ -50,10 +49,6 @@
  private:
   class DelegatingContentHandler;
 
-  // |InterfaceFactory<ContentHandler>|:
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<ContentHandler> request) override;
-
   void StartViewer(const std::string& content_handler_url,
                    InterfaceRequest<Application> application_request,
                    URLResponsePtr response);
diff --git a/mojo/ui/view_provider_app.cc b/mojo/ui/view_provider_app.cc
index 9df21e3..8a1fb1a 100644
--- a/mojo/ui/view_provider_app.cc
+++ b/mojo/ui/view_provider_app.cc
@@ -52,18 +52,16 @@
 
 bool ViewProviderApp::ConfigureIncomingConnection(
     mojo::ApplicationConnection* connection) {
-  connection->AddService<mojo::ui::ViewProvider>(this);
+  connection->GetServiceProviderImpl().AddService<ViewProvider>(
+      [this](const ConnectionContext& connection_context,
+             InterfaceRequest<ViewProvider> view_provider_request) {
+        bindings_.AddBinding(
+            new DelegatingViewProvider(this, connection_context.connection_url),
+            view_provider_request.Pass());
+      });
   return true;
 }
 
-void ViewProviderApp::Create(
-    const mojo::ConnectionContext& connection_context,
-    mojo::InterfaceRequest<mojo::ui::ViewProvider> request) {
-  bindings_.AddBinding(
-      new DelegatingViewProvider(this, connection_context.connection_url),
-      request.Pass());
-}
-
 void ViewProviderApp::CreateView(
     DelegatingViewProvider* provider,
     const std::string& view_provider_url,
diff --git a/mojo/ui/view_provider_app.h b/mojo/ui/view_provider_app.h
index 147fb1b..60ae330 100644
--- a/mojo/ui/view_provider_app.h
+++ b/mojo/ui/view_provider_app.h
@@ -22,8 +22,7 @@
 //
 // It is not necessary to use this class to implement all ViewProviders.
 // This class is merely intended to make the simple apps easier to write.
-class ViewProviderApp : public ApplicationDelegate,
-                        public InterfaceFactory<ui::ViewProvider> {
+class ViewProviderApp : public ApplicationDelegate {
  public:
   ViewProviderApp();
   ~ViewProviderApp() override;
@@ -57,10 +56,6 @@
  private:
   class DelegatingViewProvider;
 
-  // |InterfaceFactory<ViewProvider>|:
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<ViewProvider> request) override;
-
   void CreateView(DelegatingViewProvider* provider,
                   const std::string& view_provider_url,
                   InterfaceRequest<ViewOwner> view_owner_request,
diff --git a/services/asset_bundle/main.cc b/services/asset_bundle/main.cc
index 9d06e52..4ff8f17 100644
--- a/services/asset_bundle/main.cc
+++ b/services/asset_bundle/main.cc
@@ -8,14 +8,12 @@
 #include "mojo/public/c/system/main.h"
 #include "mojo/public/cpp/application/application_connection.h"
 #include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/interface_factory.h"
 #include "services/asset_bundle/asset_unpacker_impl.h"
 
 namespace mojo {
 namespace asset_bundle {
 
-class AssetBundleApp : public ApplicationDelegate,
-                       public InterfaceFactory<AssetUnpacker> {
+class AssetBundleApp : public ApplicationDelegate {
  public:
   AssetBundleApp() {}
   ~AssetBundleApp() override {}
@@ -23,29 +21,27 @@
  private:
   // |ApplicationDelegate| override:
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->AddService<AssetUnpacker>(this);
+    connection->GetServiceProviderImpl().AddService<AssetUnpacker>(
+        [this](const ConnectionContext& connection_context,
+               InterfaceRequest<AssetUnpacker> asset_unpacker_request) {
+          // Lazily initialize |sequenced_worker_pool_|. (We can't create it in
+          // the constructor, since AtExitManager is only created in
+          // ApplicationRunnerChromium::Run().)
+          if (!sequenced_worker_pool_) {
+            // TODO(vtl): What's the "right" way to choose the maximum number of
+            // threads?
+            sequenced_worker_pool_ =
+                new base::SequencedWorkerPool(4, "AssetBundleWorker");
+          }
+
+          new AssetUnpackerImpl(
+              asset_unpacker_request.Pass(),
+              sequenced_worker_pool_->GetTaskRunnerWithShutdownBehavior(
+                  base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
+        });
     return true;
   }
 
-  // |InterfaceFactory<AssetUnpacker>| implementation:
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<AssetUnpacker> request) override {
-    // Lazily initialize |sequenced_worker_pool_|. (We can't create it in the
-    // constructor, since AtExitManager is only created in
-    // ApplicationRunnerChromium::Run().)
-    if (!sequenced_worker_pool_) {
-      // TODO(vtl): What's the "right" way to choose the maximum number of
-      // threads?
-      sequenced_worker_pool_ =
-          new base::SequencedWorkerPool(4, "AssetBundleWorker");
-    }
-
-    new AssetUnpackerImpl(
-        request.Pass(),
-        sequenced_worker_pool_->GetTaskRunnerWithShutdownBehavior(
-            base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
-  }
-
   // We don't really need the "sequenced" part, but we need to be able to shut
   // down our worker pool.
   scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_;