ApplicationConnection devolution, part 2.2.

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

R=vardhan@google.com

Review URL: https://codereview.chromium.org/1981513002 .
diff --git a/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_app.cc b/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_app.cc
index 9dcf03f..ea4df32 100644
--- a/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_app.cc
+++ b/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_app.cc
@@ -24,22 +24,22 @@
 
 bool AuthenticatingURLLoaderInterceptorApp::ConfigureIncomingConnection(
     ApplicationConnection* connection) {
-  connection->AddService<AuthenticatingURLLoaderInterceptorMetaFactory>(this);
+  connection->GetServiceProviderImpl()
+      .AddService<AuthenticatingURLLoaderInterceptorMetaFactory>(
+          [this](const ConnectionContext& connection_context,
+                 InterfaceRequest<AuthenticatingURLLoaderInterceptorMetaFactory>
+                     request) {
+            GURL app_url(connection_context.remote_url);
+            GURL app_origin;
+            if (app_url.is_valid()) {
+              app_origin = app_url.GetOrigin();
+            }
+            new AuthenticatingURLLoaderInterceptorMetaFactoryImpl(
+                request.Pass(), app_, &tokens_[app_origin]);
+          });
   return true;
 }
 
-void AuthenticatingURLLoaderInterceptorApp::Create(
-    const mojo::ConnectionContext& connection_context,
-    InterfaceRequest<AuthenticatingURLLoaderInterceptorMetaFactory> request) {
-  GURL app_url(connection_context.remote_url);
-  GURL app_origin;
-  if (app_url.is_valid()) {
-    app_origin = app_url.GetOrigin();
-  }
-  new AuthenticatingURLLoaderInterceptorMetaFactoryImpl(request.Pass(), app_,
-                                                        &tokens_[app_origin]);
-}
-
 }  // namespace mojo
 
 MojoResult MojoMain(MojoHandle application_request) {
diff --git a/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_app.h b/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_app.h
index 10050fb..5a71455 100644
--- a/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_app.h
+++ b/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_app.h
@@ -8,15 +8,12 @@
 #include "base/macros.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/authenticating_url_loader_interceptor/interfaces/authenticating_url_loader_interceptor_meta_factory.mojom.h"
 #include "services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_meta_factory_impl.h"
 
 namespace mojo {
 
-class AuthenticatingURLLoaderInterceptorApp
-    : public ApplicationDelegate,
-      public InterfaceFactory<AuthenticatingURLLoaderInterceptorMetaFactory> {
+class AuthenticatingURLLoaderInterceptorApp : public ApplicationDelegate {
  public:
   AuthenticatingURLLoaderInterceptorApp();
   ~AuthenticatingURLLoaderInterceptorApp() override;
@@ -26,11 +23,6 @@
   void Initialize(ApplicationImpl* app) override;
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
 
-  // InterfaceFactory<AuthenticatingURLLoaderInterceptorMetaFactory>
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<AuthenticatingURLLoaderInterceptorMetaFactory>
-                  request) override;
-
   ApplicationImpl* app_;
   // Cache received tokens per origin of the connecting app and origin of the
   // loaded URL so that once a token has been requested it is not necessary to
diff --git a/services/authentication/main.cc b/services/authentication/main.cc
index bedd607..dc17369 100644
--- a/services/authentication/main.cc
+++ b/services/authentication/main.cc
@@ -9,7 +9,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/strong_binding.h"
 #include "mojo/public/cpp/system/macros.h"
 #include "mojo/services/authentication/interfaces/authentication.mojom.h"
@@ -18,9 +17,7 @@
 
 namespace authentication {
 
-class GoogleAccountManagerApp
-    : public mojo::ApplicationDelegate,
-      public mojo::InterfaceFactory<AuthenticationService> {
+class GoogleAccountManagerApp : public mojo::ApplicationDelegate {
  public:
   GoogleAccountManagerApp() {}
   ~GoogleAccountManagerApp() override {}
@@ -35,24 +32,23 @@
 
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService<AuthenticationService>(this);
+    connection->GetServiceProviderImpl().AddService<AuthenticationService>(
+        [this](const mojo::ConnectionContext& connection_context,
+               mojo::InterfaceRequest<AuthenticationService> request) {
+          mojo::files::Error error = mojo::files::Error::INTERNAL;
+          mojo::files::DirectoryPtr directory;
+          files_->OpenFileSystem("app_persistent_cache", GetProxy(&directory),
+                                 [&error](mojo::files::Error e) { error = e; });
+          CHECK(files_.WaitForIncomingResponse());
+          if (mojo::files::Error::OK != error) {
+            LOG(FATAL) << "Unable to initialize accounts DB";
+          }
+          new authentication::GoogleAuthenticationServiceImpl(
+              request.Pass(), app_url_, network_service_, directory);
+        });
     return true;
   }
 
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<AuthenticationService> request) override {
-    mojo::files::Error error = mojo::files::Error::INTERNAL;
-    mojo::files::DirectoryPtr directory;
-    files_->OpenFileSystem("app_persistent_cache", GetProxy(&directory),
-                           [&error](mojo::files::Error e) { error = e; });
-    CHECK(files_.WaitForIncomingResponse());
-    if (mojo::files::Error::OK != error) {
-      LOG(FATAL) << "Unable to initialize accounts DB";
-    }
-    new authentication::GoogleAuthenticationServiceImpl(
-        request.Pass(), app_url_, network_service_, directory);
-  }
-
  private:
   mojo::NetworkServicePtr network_service_;
   mojo::files::FilesPtr files_;
diff --git a/services/clipboard/main.cc b/services/clipboard/main.cc
index cdbb564..b6b3b5b 100644
--- a/services/clipboard/main.cc
+++ b/services/clipboard/main.cc
@@ -6,11 +6,9 @@
 #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/clipboard/clipboard_standalone_impl.h"
 
-class Delegate : public mojo::ApplicationDelegate,
-                 public mojo::InterfaceFactory<mojo::Clipboard> {
+class Delegate : public mojo::ApplicationDelegate {
  public:
   Delegate() {}
   ~Delegate() override {}
@@ -18,17 +16,15 @@
   // mojo::ApplicationDelegate implementation.
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService(this);
+    connection->GetServiceProviderImpl().AddService<mojo::Clipboard>(
+        [](const mojo::ConnectionContext& connection_context,
+           mojo::InterfaceRequest<mojo::Clipboard> clipboard_request) {
+          // TODO(erg): Write native implementations of the clipboard. For now,
+          // we just build a clipboard which doesn't interact with the system.
+          new clipboard::ClipboardStandaloneImpl(clipboard_request.Pass());
+        });
     return true;
   }
-
-  // mojo::InterfaceFactory<mojo::Clipboard> implementation.
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<mojo::Clipboard> request) override {
-    // TODO(erg): Write native implementations of the clipboard. For now, we
-    // just build a clipboard which doesn't interact with the system.
-    new clipboard::ClipboardStandaloneImpl(request.Pass());
-  }
 };
 
 MojoResult MojoMain(MojoHandle application_request) {
diff --git a/services/device_info/device_info.cc b/services/device_info/device_info.cc
index 59cfe33..84e66cd 100644
--- a/services/device_info/device_info.cc
+++ b/services/device_info/device_info.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/services/device_info/interfaces/device_info.mojom.h"
 
 namespace mojo {
@@ -19,9 +18,7 @@
 
 // This is a native Mojo application which implements |DeviceInfo| interface for
 // Linux.
-class DeviceInfo : public ApplicationDelegate,
-                   public mojo::DeviceInfo,
-                   public InterfaceFactory<mojo::DeviceInfo> {
+class DeviceInfo : public ApplicationDelegate, public mojo::DeviceInfo {
  public:
   // We look for the 'DISPLAY' environment variable. If present, then we assume
   // it to be a desktop, else we assume it to be a commandline
@@ -33,16 +30,14 @@
   // |ApplicationDelegate| override.
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService<mojo::DeviceInfo>(this);
+    connection->GetServiceProviderImpl().AddService<mojo::DeviceInfo>(
+        [this](const ConnectionContext& connection_context,
+               InterfaceRequest<mojo::DeviceInfo> device_info_request) {
+          binding_.AddBinding(this, device_info_request.Pass());
+        });
     return true;
   }
 
-  // |InterfaceFactory<DeviceInfo>| implementation.
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<mojo::DeviceInfo> request) override {
-    binding_.AddBinding(this, request.Pass());
-  }
-
  private:
   mojo::BindingSet<mojo::DeviceInfo> binding_;
 };
diff --git a/services/files/main.cc b/services/files/main.cc
index b8a2ce0..6d368de 100644
--- a/services/files/main.cc
+++ b/services/files/main.cc
@@ -7,14 +7,13 @@
 #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/files.mojom.h"
 #include "services/files/files_impl.h"
 
 namespace mojo {
 namespace files {
 
-class FilesApp : public ApplicationDelegate, public InterfaceFactory<Files> {
+class FilesApp : public ApplicationDelegate {
  public:
   FilesApp() {}
   ~FilesApp() override {}
@@ -22,16 +21,14 @@
  private:
   // |ApplicationDelegate| override:
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->AddService<Files>(this);
+    connection->GetServiceProviderImpl().AddService<Files>(
+        [](const ConnectionContext& connection_context,
+           InterfaceRequest<Files> files_request) {
+          new FilesImpl(connection_context, files_request.Pass());
+        });
     return true;
   }
 
-  // |InterfaceFactory<Files>| implementation:
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<Files> request) override {
-    new FilesImpl(connection_context, request.Pass());
-  }
-
   DISALLOW_COPY_AND_ASSIGN(FilesApp);
 };
 
diff --git a/services/gfx/compositor/compositor_app.cc b/services/gfx/compositor/compositor_app.cc
index a85b0f9..858c443 100644
--- a/services/gfx/compositor/compositor_app.cc
+++ b/services/gfx/compositor/compositor_app.cc
@@ -36,15 +36,15 @@
 
 bool CompositorApp::ConfigureIncomingConnection(
     mojo::ApplicationConnection* connection) {
-  connection->AddService<mojo::gfx::composition::Compositor>(this);
+  connection->GetServiceProviderImpl()
+      .AddService<mojo::gfx::composition::Compositor>(
+          [this](const mojo::ConnectionContext& connection_context,
+                 mojo::InterfaceRequest<mojo::gfx::composition::Compositor>
+                     compositor_request) {
+            compositor_bindings_.AddBinding(new CompositorImpl(engine_.get()),
+                                            compositor_request.Pass());
+          });
   return true;
 }
 
-void CompositorApp::Create(
-    const mojo::ConnectionContext& connection_context,
-    mojo::InterfaceRequest<mojo::gfx::composition::Compositor> request) {
-  compositor_bindings_.AddBinding(new CompositorImpl(engine_.get()),
-                                  request.Pass());
-}
-
 }  // namespace compositor
diff --git a/services/gfx/compositor/compositor_app.h b/services/gfx/compositor/compositor_app.h
index 51fab87..fc55367 100644
--- a/services/gfx/compositor/compositor_app.h
+++ b/services/gfx/compositor/compositor_app.h
@@ -12,16 +12,13 @@
 #include "mojo/common/strong_binding_set.h"
 #include "mojo/common/tracing_impl.h"
 #include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/interface_factory.h"
 #include "mojo/services/gfx/composition/interfaces/compositor.mojom.h"
 #include "services/gfx/compositor/compositor_engine.h"
 
 namespace compositor {
 
 // Compositor application entry point.
-class CompositorApp
-    : public mojo::ApplicationDelegate,
-      public mojo::InterfaceFactory<mojo::gfx::composition::Compositor> {
+class CompositorApp : public mojo::ApplicationDelegate {
  public:
   CompositorApp();
   ~CompositorApp() override;
@@ -32,11 +29,6 @@
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override;
 
-  // |InterfaceFactory<Compositor>|:
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<mojo::gfx::composition::Compositor>
-                  request) override;
-
   mojo::ApplicationImpl* app_impl_;
   mojo::TracingImpl tracing_;
 
diff --git a/services/http_server/http_server_app.cc b/services/http_server/http_server_app.cc
index a1e6841..b449b73 100644
--- a/services/http_server/http_server_app.cc
+++ b/services/http_server/http_server_app.cc
@@ -8,15 +8,13 @@
 #include "mojo/public/cpp/application/application_delegate.h"
 #include "mojo/public/cpp/application/application_impl.h"
 #include "mojo/public/cpp/application/application_runner.h"
-#include "mojo/public/cpp/application/interface_factory.h"
 #include "mojo/services/http_server/interfaces/http_server_factory.mojom.h"
 #include "services/http_server/http_server_factory_impl.h"
 #include "services/http_server/http_server_impl.h"
 
 namespace http_server {
 
-class HttpServerApp : public mojo::ApplicationDelegate,
-                      public mojo::InterfaceFactory<HttpServerFactory> {
+class HttpServerApp : public mojo::ApplicationDelegate {
  public:
   HttpServerApp() {}
   ~HttpServerApp() override {}
@@ -27,20 +25,17 @@
   // ApplicationDelegate:
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService(this);
+    connection->GetServiceProviderImpl().AddService<HttpServerFactory>([this](
+        const mojo::ConnectionContext& connection_context,
+        mojo::InterfaceRequest<HttpServerFactory> http_server_factory_request) {
+      if (!http_server_factory_)
+        http_server_factory_.reset(new HttpServerFactoryImpl(app_));
+
+      http_server_factory_->AddBinding(http_server_factory_request.Pass());
+    });
     return true;
   }
 
-  // InterfaceFactory<HttpServerFactory>:
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<HttpServerFactory> request) override {
-    if (!http_server_factory_) {
-      http_server_factory_.reset(new HttpServerFactoryImpl(app_));
-    }
-
-    http_server_factory_->AddBinding(request.Pass());
-  }
-
   mojo::ApplicationImpl* app_;
   std::unique_ptr<HttpServerFactoryImpl> http_server_factory_;
 };
diff --git a/services/icu_data/icu_data_impl.cc b/services/icu_data/icu_data_impl.cc
index 7192928..2a34755 100644
--- a/services/icu_data/icu_data_impl.cc
+++ b/services/icu_data/icu_data_impl.cc
@@ -7,16 +7,13 @@
 #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/public/cpp/bindings/interface_ptr.h"
 #include "mojo/services/icu_data/interfaces/icu_data.mojom.h"
 #include "services/icu_data/kICUData.h"
 
 namespace icu_data {
 
-class ICUDataImpl : public mojo::ApplicationDelegate,
-                    public ICUData,
-                    public mojo::InterfaceFactory<ICUData> {
+class ICUDataImpl : public mojo::ApplicationDelegate, public ICUData {
  public:
   ICUDataImpl() {}
   ~ICUDataImpl() override {}
@@ -24,14 +21,13 @@
   // mojo::ApplicationDelegate implementation.
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService(this);
-    return true;
-  }
+    connection->GetServiceProviderImpl().AddService<ICUData>(
+        [this](const mojo::ConnectionContext& connection_context,
+               mojo::InterfaceRequest<ICUData> icu_data_request) {
+          bindings_.AddBinding(this, icu_data_request.Pass());
+        });
 
-  // mojo::InterfaceFactory<mojo::ICUData> implementation.
-  void Create(const mojo::ConnectionContext& connection,
-              mojo::InterfaceRequest<ICUData> request) override {
-    bindings_.AddBinding(this, request.Pass());
+    return true;
   }
 
   void Map(const mojo::String& sha1hash,
diff --git a/services/keyboard/linux/main.cc b/services/keyboard/linux/main.cc
index 397a4f2..6ca21bd 100644
--- a/services/keyboard/linux/main.cc
+++ b/services/keyboard/linux/main.cc
@@ -10,7 +10,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/services/native_viewport/interfaces/native_viewport_event_dispatcher.mojom.h"
 #include "services/keyboard/linux/keyboard_service_impl.h"
 
@@ -22,7 +21,7 @@
       mojo::InterfaceRequest<KeyboardServiceFactory> request)
     : binding_(this, request.Pass()) {}
 
-  // |InterfaceFactory<KeyboardService>| implementation:
+  // |keyboard::KeyboardServiceFactory| implementation:
   void CreateKeyboardService(
       mojo::InterfaceRequest<mojo::NativeViewportEventDispatcher> dispatcher,
       mojo::InterfaceRequest<KeyboardService> request) override {
@@ -35,9 +34,7 @@
   DISALLOW_COPY_AND_ASSIGN(KeyboardServiceFactoryImpl);
 };
 
-class KeyboardServiceApp
-  : public mojo::ApplicationDelegate,
-    public mojo::InterfaceFactory<KeyboardServiceFactory> {
+class KeyboardServiceApp : public mojo::ApplicationDelegate {
  public:
   KeyboardServiceApp() {}
   ~KeyboardServiceApp() override {}
@@ -47,18 +44,16 @@
   // |ApplicationDelegate| override:
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService<KeyboardServiceFactory>(this);
+    connection->GetServiceProviderImpl().AddService<KeyboardServiceFactory>([](
+        const mojo::ConnectionContext& connection_context,
+        mojo::InterfaceRequest<KeyboardServiceFactory>
+            keyboard_service_factory_request) {
+      new KeyboardServiceFactoryImpl(keyboard_service_factory_request.Pass());
+    });
     return true;
   }
 
-  // |InterfaceFactory<KeyboardService>| implementation:
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<KeyboardServiceFactory> request) override {
-    new KeyboardServiceFactoryImpl(request.Pass());
-  }
-
  private:
-
   DISALLOW_COPY_AND_ASSIGN(KeyboardServiceApp);
 };
 
diff --git a/services/log/main.cc b/services/log/main.cc
index f87f0a3..2b5c92c 100644
--- a/services/log/main.cc
+++ b/services/log/main.cc
@@ -10,7 +10,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/public/cpp/system/macros.h"
 #include "mojo/services/log/interfaces/log.mojom.h"
 #include "services/log/log_impl.h"
@@ -20,7 +19,7 @@
 
 // Provides the mojo.log.Log service.  Binds a new Log implementation for each
 // Log interface request.
-class LogApp : public ApplicationDelegate, public InterfaceFactory<Log> {
+class LogApp : public ApplicationDelegate {
  public:
   LogApp() {}
   ~LogApp() override {}
@@ -28,20 +27,17 @@
  private:
   // |ApplicationDelegate| override:
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->AddService<Log>(this);
+    connection->GetServiceProviderImpl().AddService<Log>(
+        [](const ConnectionContext& connection_context,
+           InterfaceRequest<Log> log_request) {
+          LogImpl::Create(connection_context, std::move(log_request),
+                          [](const std::string& message) {
+                            fprintf(stderr, "%s\n", message.c_str());
+                          });
+        });
     return true;
   }
 
-  // |InterfaceFactory<Log>| implementation:
-  // We maintain a separate |LogImpl| for each incoming connection.
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<Log> request) override {
-    LogImpl::Create(connection_context, std::move(request),
-                    [](const std::string& message) {
-                      fprintf(stderr, "%s\n", message.c_str());
-                    });
-  }
-
   MOJO_DISALLOW_COPY_AND_ASSIGN(LogApp);
 };
 
diff --git a/services/media/audio/audio_server_app.cc b/services/media/audio/audio_server_app.cc
index c59df0f..7eba44e 100644
--- a/services/media/audio/audio_server_app.cc
+++ b/services/media/audio/audio_server_app.cc
@@ -9,8 +9,6 @@
 #include "mojo/public/cpp/application/application_impl.h"
 #include "services/media/audio/audio_server_app.h"
 
-#define VERBOSE 0
-
 namespace mojo {
 namespace media {
 namespace audio {
@@ -24,18 +22,17 @@
 
 bool AudioServerApp::ConfigureIncomingConnection(
     ApplicationConnection* connection) {
-  connection->AddService(this);
+  connection->GetServiceProviderImpl().AddService<AudioServer>(
+      [this](const ConnectionContext& connection_context,
+             InterfaceRequest<AudioServer> audio_server_request) {
+        bindings_.AddBinding(&server_impl_, audio_server_request.Pass());
+      });
   return true;
 }
 
 void AudioServerApp::Quit() {
 }
 
-void AudioServerApp::Create(const ConnectionContext& connection_context,
-                            InterfaceRequest<AudioServer> request) {
-  bindings_.AddBinding(&server_impl_, request.Pass());
-}
-
 }  // namespace audio
 }  // namespace media
 }  // namespace mojo
diff --git a/services/media/audio/audio_server_app.h b/services/media/audio/audio_server_app.h
index c98cc30..8fba580 100644
--- a/services/media/audio/audio_server_app.h
+++ b/services/media/audio/audio_server_app.h
@@ -7,7 +7,6 @@
 
 #include "mojo/common/binding_set.h"
 #include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/interface_factory.h"
 #include "mojo/services/media/audio/interfaces/audio_server.mojom.h"
 #include "services/media/audio/audio_server_impl.h"
 
@@ -15,8 +14,7 @@
 namespace media {
 namespace audio {
 
-class AudioServerApp : public ApplicationDelegate,
-                       public InterfaceFactory<AudioServer> {
+class AudioServerApp : public ApplicationDelegate {
  public:
   AudioServerApp();
   ~AudioServerApp() override;
@@ -26,10 +24,6 @@
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
   void Quit() override;
 
-  // InterfaceFactory<AudioServer>
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<AudioServer> request) override;
-
  private:
   AudioServerImpl server_impl_;
   BindingSet<AudioServer> bindings_;
diff --git a/services/media/factory_service/factory_service.cc b/services/media/factory_service/factory_service.cc
index d6be517..feff176 100644
--- a/services/media/factory_service/factory_service.cc
+++ b/services/media/factory_service/factory_service.cc
@@ -30,15 +30,14 @@
 
 bool MediaFactoryService::ConfigureIncomingConnection(
     ApplicationConnection* connection) {
-  connection->AddService<MediaFactory>(this);
+  connection->GetServiceProviderImpl().AddService<MediaFactory>(
+      [this](const ConnectionContext& connection_context,
+             InterfaceRequest<MediaFactory> media_factory_request) {
+        bindings_.AddBinding(this, media_factory_request.Pass());
+      });
   return true;
 }
 
-void MediaFactoryService::Create(const ConnectionContext& connection_context,
-                                 InterfaceRequest<MediaFactory> request) {
-  bindings_.AddBinding(this, request.Pass());
-}
-
 void MediaFactoryService::CreatePlayer(InterfaceHandle<SeekingReader> reader,
                                        InterfaceRequest<MediaPlayer> player) {
   products_.insert(std::static_pointer_cast<ProductBase>(
diff --git a/services/media/factory_service/factory_service.h b/services/media/factory_service/factory_service.h
index f115c5e..9bb5d03 100644
--- a/services/media/factory_service/factory_service.h
+++ b/services/media/factory_service/factory_service.h
@@ -16,7 +16,6 @@
 namespace media {
 
 class MediaFactoryService : public ApplicationDelegate,
-                            public InterfaceFactory<MediaFactory>,
                             public MediaFactory {
  public:
   // Provides common behavior for all objects created by the factory service.
@@ -79,10 +78,6 @@
 
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
 
-  // InterfaceFactory<MediaFactory> implementation.
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<MediaFactory> request) override;
-
   // MediaFactory implementation.
   void CreatePlayer(InterfaceHandle<SeekingReader> reader,
                     InterfaceRequest<MediaPlayer> player) override;
diff --git a/services/nacl/nonsfi/pnacl_compile.cc b/services/nacl/nonsfi/pnacl_compile.cc
index 6985511..5240c12 100644
--- a/services/nacl/nonsfi/pnacl_compile.cc
+++ b/services/nacl/nonsfi/pnacl_compile.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/strong_binding.h"
 #include "services/nacl/nonsfi/kPnaclTranslatorCompile.h"
 #include "services/nacl/nonsfi/pnacl_compile.mojom.h"
@@ -42,22 +41,19 @@
   StrongBinding<PexeCompilerInit> strong_binding_;
 };
 
-class MultiPexeCompiler : public ApplicationDelegate,
-                          public InterfaceFactory<PexeCompilerInit> {
+class MultiPexeCompiler : public ApplicationDelegate {
  public:
   MultiPexeCompiler() {}
 
   // From ApplicationDelegate
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->AddService<PexeCompilerInit>(this);
+    connection->GetServiceProviderImpl().AddService<PexeCompilerInit>(
+        [](const ConnectionContext& connection_context,
+           InterfaceRequest<PexeCompilerInit> request) {
+          new StrongBindingPexeCompilerImpl(request.Pass());
+        });
     return true;
   }
-
-  // From InterfaceFactory
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<PexeCompilerInit> request) override {
-    new StrongBindingPexeCompilerImpl(request.Pass());
-  }
 };
 
 }  // namespace nacl
diff --git a/services/nacl/nonsfi/pnacl_link.cc b/services/nacl/nonsfi/pnacl_link.cc
index 299a190..e2d3fad 100644
--- a/services/nacl/nonsfi/pnacl_link.cc
+++ b/services/nacl/nonsfi/pnacl_link.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/strong_binding.h"
 #include "services/nacl/nonsfi/kLdNexe.h"
 #include "services/nacl/nonsfi/pnacl_link.mojom.h"
@@ -39,22 +38,19 @@
   StrongBinding<PexeLinkerInit> strong_binding_;
 };
 
-class MultiPexeLinker : public ApplicationDelegate,
-                        public InterfaceFactory<PexeLinkerInit> {
+class MultiPexeLinker : public ApplicationDelegate {
  public:
   MultiPexeLinker() {}
 
   // From ApplicationDelegate
   bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->AddService<PexeLinkerInit>(this);
+    connection->GetServiceProviderImpl().AddService<PexeLinkerInit>(
+        [](const ConnectionContext& connection_context,
+           InterfaceRequest<PexeLinkerInit> request) {
+          new StrongBindingPexeLinkerImpl(request.Pass());
+        });
     return true;
   }
-
-  // From InterfaceFactory
-  void Create(const ConnectionContext& connection_context,
-              InterfaceRequest<PexeLinkerInit> request) override {
-    new StrongBindingPexeLinkerImpl(request.Pass());
-  }
 };
 
 }  // namespace nacl
diff --git a/services/native_support/main.cc b/services/native_support/main.cc
index 11e8a7d..9fdbfb9 100644
--- a/services/native_support/main.cc
+++ b/services/native_support/main.cc
@@ -10,7 +10,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/native_support/interfaces/process.mojom.h"
 #include "services/native_support/process_impl.h"
 
@@ -19,8 +18,7 @@
 // TODO(vtl): Having to manually choose an arbitrary number is dumb.
 const size_t kMaxWorkerThreads = 16;
 
-class NativeSupportApp : public mojo::ApplicationDelegate,
-                         public mojo::InterfaceFactory<Process> {
+class NativeSupportApp : public mojo::ApplicationDelegate {
  public:
   NativeSupportApp() {}
   ~NativeSupportApp() override {
@@ -32,20 +30,18 @@
   // |mojo::ApplicationDelegate| override:
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override {
-    connection->AddService<Process>(this);
+    connection->GetServiceProviderImpl().AddService<Process>([this](
+        const mojo::ConnectionContext& connection_context,
+        mojo::InterfaceRequest<Process> process_request) {
+      if (!worker_pool_) {
+        worker_pool_ = new base::SequencedWorkerPool(kMaxWorkerThreads,
+                                                     "NativeSupportWorker");
+      }
+      new ProcessImpl(worker_pool_, connection_context, process_request.Pass());
+    });
     return true;
   }
 
-  // |InterfaceFactory<Process>| implementation:
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<Process> request) override {
-    if (!worker_pool_) {
-      worker_pool_ = new base::SequencedWorkerPool(kMaxWorkerThreads,
-                                                   "NativeSupportWorker");
-    }
-    new ProcessImpl(worker_pool_, connection_context, request.Pass());
-  }
-
   scoped_refptr<base::SequencedWorkerPool> worker_pool_;
 
   DISALLOW_COPY_AND_ASSIGN(NativeSupportApp);
diff --git a/services/native_viewport/app_delegate.cc b/services/native_viewport/app_delegate.cc
index 67e5ecb..e6ac534 100644
--- a/services/native_viewport/app_delegate.cc
+++ b/services/native_viewport/app_delegate.cc
@@ -5,6 +5,7 @@
 #include "services/native_viewport/app_delegate.h"
 
 #include <vector>
+
 #include "gpu/config/gpu_util.h"
 
 namespace native_viewport {
@@ -60,26 +61,24 @@
 
 bool NativeViewportAppDelegate::ConfigureIncomingConnection(
     mojo::ApplicationConnection* connection) {
-  connection->AddService<mojo::NativeViewport>(this);
-  connection->AddService<mojo::Gpu>(this);
+  connection->GetServiceProviderImpl().AddService<mojo::NativeViewport>([this](
+      const mojo::ConnectionContext& connection_context,
+      mojo::InterfaceRequest<mojo::NativeViewport> native_viewport_request) {
+    if (!gpu_state_.get())
+      gpu_state_ = new gles2::GpuState();
+    new NativeViewportImpl(application_, is_headless_, gpu_state_,
+                           native_viewport_request.Pass());
+  });
+
+  connection->GetServiceProviderImpl().AddService<mojo::Gpu>(
+      [this](const mojo::ConnectionContext& connection_context,
+             mojo::InterfaceRequest<mojo::Gpu> gpu_request) {
+        if (!gpu_state_.get())
+          gpu_state_ = new gles2::GpuState();
+        new gles2::GpuImpl(gpu_request.Pass(), gpu_state_);
+      });
+
   return true;
 }
 
-void NativeViewportAppDelegate::Create(
-    const mojo::ConnectionContext& connection_context,
-    mojo::InterfaceRequest<mojo::NativeViewport> request) {
-  if (!gpu_state_.get())
-    gpu_state_ = new gles2::GpuState;
-  new NativeViewportImpl(application_, is_headless_, gpu_state_,
-                         request.Pass());
-}
-
-void NativeViewportAppDelegate::Create(
-    const mojo::ConnectionContext& connection_context,
-    mojo::InterfaceRequest<mojo::Gpu> request) {
-  if (!gpu_state_.get())
-    gpu_state_ = new gles2::GpuState;
-  new gles2::GpuImpl(request.Pass(), gpu_state_);
-}
-
 }  // namespace native_viewport
diff --git a/services/native_viewport/app_delegate.h b/services/native_viewport/app_delegate.h
index 2362355..dc496e4 100644
--- a/services/native_viewport/app_delegate.h
+++ b/services/native_viewport/app_delegate.h
@@ -24,10 +24,7 @@
 
 namespace native_viewport {
 
-class NativeViewportAppDelegate
-    : public mojo::ApplicationDelegate,
-      public mojo::InterfaceFactory<mojo::NativeViewport>,
-      public mojo::InterfaceFactory<mojo::Gpu> {
+class NativeViewportAppDelegate : public mojo::ApplicationDelegate {
  public:
   NativeViewportAppDelegate();
   ~NativeViewportAppDelegate() override;
@@ -38,14 +35,6 @@
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override;
 
-  // mojo::InterfaceFactory<mojo::NativeViewport> implementation.
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<mojo::NativeViewport> request) override;
-
-  // mojo::InterfaceFactory<mojo::Gpu> implementation.
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<mojo::Gpu> request) override;
-
  private:
   void InitLogging(mojo::ApplicationImpl* application);
 
diff --git a/services/prediction/prediction_service_impl.cc b/services/prediction/prediction_service_impl.cc
index 210b965..574102a 100644
--- a/services/prediction/prediction_service_impl.cc
+++ b/services/prediction/prediction_service_impl.cc
@@ -2,13 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "services/prediction/prediction_service_impl.h"
+
 #include "mojo/application/application_runner_chromium.h"
 #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/bindings/strong_binding.h"
-#include "services/prediction/dictionary_service.h"
-#include "services/prediction/prediction_service_impl.h"
 
 namespace prediction {
 
@@ -23,7 +21,6 @@
 PredictionServiceImpl::~PredictionServiceImpl() {
 }
 
-// PredictionService implementation
 void PredictionServiceImpl::GetPredictionList(
     PredictionInfoPtr prediction_info,
     const GetPredictionListCallback& callback) {
@@ -33,26 +30,20 @@
   callback.Run(prediction_list.Pass());
 }
 
-PredictionServiceDelegate::PredictionServiceDelegate() {
-}
+PredictionServiceDelegate::PredictionServiceDelegate() {}
 
-PredictionServiceDelegate::~PredictionServiceDelegate() {
-}
+PredictionServiceDelegate::~PredictionServiceDelegate() {}
 
-// mojo::ApplicationDelegate implementation
 bool PredictionServiceDelegate::ConfigureIncomingConnection(
     mojo::ApplicationConnection* connection) {
-  connection->AddService<PredictionService>(this);
+  connection->GetServiceProviderImpl().AddService<PredictionService>(
+      [](const mojo::ConnectionContext& connection_context,
+         mojo::InterfaceRequest<PredictionService> prediction_service_request) {
+        new PredictionServiceImpl(prediction_service_request.Pass());
+      });
   return true;
 }
 
-// mojo::InterfaceRequest<PredictionService> implementation
-void PredictionServiceDelegate::Create(
-    const mojo::ConnectionContext& connection_context,
-    mojo::InterfaceRequest<PredictionService> request) {
-  new PredictionServiceImpl(request.Pass());
-}
-
 }  // namespace prediction
 
 MojoResult MojoMain(MojoHandle application_request) {
diff --git a/services/prediction/prediction_service_impl.h b/services/prediction/prediction_service_impl.h
index 64e2b50..6a1c51e 100644
--- a/services/prediction/prediction_service_impl.h
+++ b/services/prediction/prediction_service_impl.h
@@ -6,7 +6,10 @@
 #define SERVICES_PREDICTION_PREDICTION_SERVICE_IMPL_H_
 
 #include "base/memory/scoped_ptr.h"
+#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
 #include "mojo/services/prediction/interfaces/prediction.mojom.h"
+#include "services/prediction/dictionary_service.h"
 
 namespace prediction {
 
@@ -29,9 +32,7 @@
   DISALLOW_COPY_AND_ASSIGN(PredictionServiceImpl);
 };
 
-class PredictionServiceDelegate
-    : public mojo::ApplicationDelegate,
-      public mojo::InterfaceFactory<PredictionService> {
+class PredictionServiceDelegate : public mojo::ApplicationDelegate {
  public:
   PredictionServiceDelegate();
   ~PredictionServiceDelegate() override;
@@ -39,10 +40,6 @@
   // mojo::ApplicationDelegate implementation
   bool ConfigureIncomingConnection(
       mojo::ApplicationConnection* connection) override;
-
-  // mojo::InterfaceRequest<PredictionService> implementation
-  void Create(const mojo::ConnectionContext& connection_context,
-              mojo::InterfaceRequest<PredictionService> request) override;
 };
 
 }  // namespace prediction