ApplicationConnection devolution, part 3.

Make ApplicationDelegate::ConfigureIncomingConnection() take a
ServiceProviderImpl* instead of an ApplicationConnection*.

(Maybe it should also be renamed, but we'll leave that battle for
another day.)

R=vardhan@google.com

Review URL: https://codereview.chromium.org/1979723002 .
diff --git a/examples/apptest/example_service_application.cc b/examples/apptest/example_service_application.cc
index de483b5..1e9a297 100644
--- a/examples/apptest/example_service_application.cc
+++ b/examples/apptest/example_service_application.cc
@@ -17,8 +17,8 @@
 ExampleServiceApplication::~ExampleServiceApplication() {}
 
 bool ExampleServiceApplication::ConfigureIncomingConnection(
-    ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<ExampleService>(
+    ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<ExampleService>(
       [](const ConnectionContext& connection_context,
          InterfaceRequest<ExampleService> example_service_request) {
         // Not leaked: ExampleServiceImpl is strongly bound to the pipe.
diff --git a/examples/apptest/example_service_application.h b/examples/apptest/example_service_application.h
index 3e8602e..2e65b03 100644
--- a/examples/apptest/example_service_application.h
+++ b/examples/apptest/example_service_application.h
@@ -21,7 +21,7 @@
  private:
   // ApplicationDelegate implementation.
   bool ConfigureIncomingConnection(
-      ApplicationConnection* connection) override;
+      ServiceProviderImpl* service_provider_impl) override;
 
   MOJO_DISALLOW_COPY_AND_ASSIGN(ExampleServiceApplication);
 };
diff --git a/examples/bank_app/bank.cc b/examples/bank_app/bank.cc
index ea70adc..9e14044 100644
--- a/examples/bank_app/bank.cc
+++ b/examples/bank_app/bank.cc
@@ -56,9 +56,8 @@
 
   // From ApplicationDelegate
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    std::string url =
-        connection->GetServiceProviderImpl().connection_context().remote_url;
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    std::string url = service_provider_impl->connection_context().remote_url;
     if (url.length() > 0) {
       vanadium::AppInstanceNamePtr app(vanadium::AppInstanceName::New());
       app->url = url;
@@ -77,7 +76,7 @@
       }
       MOJO_LOG(INFO) << "Customer " << user << " accessing bank";
     }
-    connection->GetServiceProviderImpl().AddService<Bank>(
+    service_provider_impl->AddService<Bank>(
         [this](const mojo::ConnectionContext& connection_context,
                mojo::InterfaceRequest<Bank> bank_request) {
           bindings_.AddBinding(&bank_impl_, bank_request.Pass());
diff --git a/examples/content_handler_demo/content_handler_demo.cc b/examples/content_handler_demo/content_handler_demo.cc
index d0b0552..fc12891 100644
--- a/examples/content_handler_demo/content_handler_demo.cc
+++ b/examples/content_handler_demo/content_handler_demo.cc
@@ -99,8 +99,9 @@
 
   void Initialize(ApplicationImpl* app) override {}
 
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<ContentHandler>(
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<ContentHandler>(
         [](const ConnectionContext& connection_context,
            InterfaceRequest<ContentHandler> content_handler_request) {
           new ContentHandlerImpl(content_handler_request.Pass());
diff --git a/examples/echo/README.md b/examples/echo/README.md
index 52c3ec3..ab8340e 100644
--- a/examples/echo/README.md
+++ b/examples/echo/README.md
@@ -134,7 +134,7 @@
 `ConfigureIncomingConnection` in the same way:
 
 ```
-connection->GetServiceProviderImpl().AddService<Echo>(
+service_provider_impl->AddService<Echo>(
     [this](const mojo::ConnectionContext& connection_context,
            mojo::InterfaceRequest<Echo> echo_request) {
       ...
diff --git a/examples/echo/echo_server.cc b/examples/echo/echo_server.cc
index 2da7ede..aa82a20 100644
--- a/examples/echo/echo_server.cc
+++ b/examples/echo/echo_server.cc
@@ -56,8 +56,8 @@
 
   // From ApplicationDelegate
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<Echo>(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<Echo>(
         [](const mojo::ConnectionContext& connection_context,
            mojo::InterfaceRequest<Echo> echo_request) {
           // This object will be deleted automatically because of the use of
@@ -76,8 +76,8 @@
 
   // From ApplicationDelegate
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<Echo>(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<Echo>(
         [this](const mojo::ConnectionContext& connection_context,
                mojo::InterfaceRequest<Echo> echo_request) {
           // All channels will connect to this singleton object, so just
@@ -105,8 +105,8 @@
 
   // From ApplicationDelegate
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<Echo>(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<Echo>(
         [this](const mojo::ConnectionContext& connection_context,
                mojo::InterfaceRequest<Echo> echo_request) {
           binding_.Bind(echo_request.Pass());
diff --git a/examples/echo_terminal/main.cc b/examples/echo_terminal/main.cc
index 14c7c3f..24be650 100644
--- a/examples/echo_terminal/main.cc
+++ b/examples/echo_terminal/main.cc
@@ -105,12 +105,11 @@
  private:
   // |ApplicationDelegate| override:
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl()
-        .AddService<mojo::terminal::TerminalClient>([this](
-            const mojo::ConnectionContext& connection_context,
-            mojo::InterfaceRequest<mojo::terminal::TerminalClient>
-                terminal_client_request) {
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->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;
diff --git a/examples/forwarding_content_handler/forwarding_content_handler.cc b/examples/forwarding_content_handler/forwarding_content_handler.cc
index 87730f2..cc6ff78 100644
--- a/examples/forwarding_content_handler/forwarding_content_handler.cc
+++ b/examples/forwarding_content_handler/forwarding_content_handler.cc
@@ -58,8 +58,9 @@
 
  private:
   // Overridden from ApplicationDelegate:
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<ContentHandler>(
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<ContentHandler>(
         content_handler_factory_.GetInterfaceRequestHandler());
     return true;
   }
diff --git a/examples/hello_mojo/hello_mojo_server.cc b/examples/hello_mojo/hello_mojo_server.cc
index 61a3c2e..7e48dec 100644
--- a/examples/hello_mojo/hello_mojo_server.cc
+++ b/examples/hello_mojo/hello_mojo_server.cc
@@ -44,8 +44,8 @@
 
   // |mojo::ApplicationDelegate| implementation:
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* application_connection) override {
-    application_connection->GetServiceProviderImpl().AddService<HelloMojo>(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<HelloMojo>(
         [](const mojo::ConnectionContext& connection_context,
            mojo::InterfaceRequest<HelloMojo> hello_mojo_request) {
           new HelloMojoImpl(std::move(hello_mojo_request));  // Owns itself.
diff --git a/examples/indirect_service/indirect_integer_service.cc b/examples/indirect_service/indirect_integer_service.cc
index c5bff99..ec7f589 100644
--- a/examples/indirect_service/indirect_integer_service.cc
+++ b/examples/indirect_service/indirect_integer_service.cc
@@ -52,8 +52,8 @@
 class IndirectIntegerServiceAppDelegate : public ApplicationDelegate {
  public:
   bool ConfigureIncomingConnection(
-      ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<IndirectIntegerService>(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<IndirectIntegerService>(
         [](const ConnectionContext& connection_context,
            InterfaceRequest<IndirectIntegerService> request) {
           new IndirectIntegerServiceImpl(request.Pass());
diff --git a/examples/indirect_service/integer_service.cc b/examples/indirect_service/integer_service.cc
index 6e8b6ac..e7979f9 100644
--- a/examples/indirect_service/integer_service.cc
+++ b/examples/indirect_service/integer_service.cc
@@ -32,8 +32,8 @@
 class IntegerServiceAppDelegate : public ApplicationDelegate {
  public:
   bool ConfigureIncomingConnection(
-      ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<IntegerService>(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<IntegerService>(
         [](const ConnectionContext& connection_context,
            InterfaceRequest<IntegerService> request) {
           new IntegerServiceImpl(request.Pass());
diff --git a/examples/media_test/media_test_app.cc b/examples/media_test/media_test_app.cc
index 4315a99..dc618f3 100644
--- a/examples/media_test/media_test_app.cc
+++ b/examples/media_test/media_test_app.cc
@@ -70,11 +70,6 @@
     Poll();
   }
 
-  bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    return true;
-  }
-
  private:
   static const char* kHome;
   static const char* kClearLine;
diff --git a/examples/native_run_app/native_run_app.cc b/examples/native_run_app/native_run_app.cc
index ba75d55..5e36ad4 100644
--- a/examples/native_run_app/native_run_app.cc
+++ b/examples/native_run_app/native_run_app.cc
@@ -235,8 +235,8 @@
   }
 
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<TerminalClient>(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<TerminalClient>(
         [this](const mojo::ConnectionContext& connection_context,
                mojo::InterfaceRequest<TerminalClient> terminal_client_request) {
           new TerminalClientImpl(terminal_client_request.Pass(),
diff --git a/examples/recursive_content_handler/recursive_content_handler.cc b/examples/recursive_content_handler/recursive_content_handler.cc
index e246a1f..4ee0178 100644
--- a/examples/recursive_content_handler/recursive_content_handler.cc
+++ b/examples/recursive_content_handler/recursive_content_handler.cc
@@ -23,8 +23,8 @@
  private:
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(
-      ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<ContentHandler>(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<ContentHandler>(
         content_handler_factory_.GetInterfaceRequestHandler());
     return true;
   }
diff --git a/examples/trace_me/trace_me_app.cc b/examples/trace_me/trace_me_app.cc
index 8415662..0f627ae 100644
--- a/examples/trace_me/trace_me_app.cc
+++ b/examples/trace_me/trace_me_app.cc
@@ -64,7 +64,7 @@
 
   // mojo:ApplicationDelegate:
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
+      mojo::ServiceProviderImpl* service_provider_impl) override {
     TRACE_EVENT0("trace_me", "connected");
     return true;
   }
diff --git a/mojo/public/cpp/application/application_delegate.h b/mojo/public/cpp/application/application_delegate.h
index 4bf9cf2..6da1c4d 100644
--- a/mojo/public/cpp/application/application_delegate.h
+++ b/mojo/public/cpp/application/application_delegate.h
@@ -7,6 +7,7 @@
 
 #include <string>
 
+#include "mojo/public/cpp/application/service_provider_impl.h"
 #include "mojo/public/cpp/system/macros.h"
 
 namespace mojo {
@@ -25,9 +26,10 @@
   virtual void Initialize(ApplicationImpl* app);
 
   // Override this method to configure what services a connection supports when
-  // being connected to from an app.
-  // Return false to reject the connection entirely.
-  virtual bool ConfigureIncomingConnection(ApplicationConnection* connection);
+  // being connected to from an app (|service_provider_impl| will never be
+  // null). Return false to reject the connection entirely.
+  virtual bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl);
 
   // Called before ApplicationImpl::Terminate(). After returning from this call
   // the delegate can no longer rely on the main run loop still running.
diff --git a/mojo/public/cpp/application/lib/application_delegate.cc b/mojo/public/cpp/application/lib/application_delegate.cc
index 7adeb1c..27f9db9 100644
--- a/mojo/public/cpp/application/lib/application_delegate.cc
+++ b/mojo/public/cpp/application/lib/application_delegate.cc
@@ -6,20 +6,17 @@
 
 namespace mojo {
 
-ApplicationDelegate::ApplicationDelegate() {
-}
-ApplicationDelegate::~ApplicationDelegate() {
-}
+ApplicationDelegate::ApplicationDelegate() {}
 
-void ApplicationDelegate::Initialize(ApplicationImpl* app) {
-}
+ApplicationDelegate::~ApplicationDelegate() {}
+
+void ApplicationDelegate::Initialize(ApplicationImpl* app) {}
 
 bool ApplicationDelegate::ConfigureIncomingConnection(
-    ApplicationConnection* connection) {
+    ServiceProviderImpl* service_provider_impl) {
   return true;
 }
 
-void ApplicationDelegate::Quit() {
-}
+void ApplicationDelegate::Quit() {}
 
 }  // namespace mojo
diff --git a/mojo/public/cpp/application/lib/application_impl.cc b/mojo/public/cpp/application/lib/application_impl.cc
index 289d4b3..0ad3a3f 100644
--- a/mojo/public/cpp/application/lib/application_impl.cc
+++ b/mojo/public/cpp/application/lib/application_impl.cc
@@ -75,7 +75,8 @@
           ConnectionContext(ConnectionContext::Type::INCOMING, requestor_url,
                             url),
           services.Pass()));
-  if (!delegate_->ConfigureIncomingConnection(registry.get()))
+  if (!delegate_->ConfigureIncomingConnection(
+          &registry->GetServiceProviderImpl()))
     return;
   incoming_service_registries_.push_back(std::move(registry));
 }
diff --git a/mojo/public/cpp/bindings/tests/versioning_test_service.cc b/mojo/public/cpp/bindings/tests/versioning_test_service.cc
index f815889..3474dd9 100644
--- a/mojo/public/cpp/bindings/tests/versioning_test_service.cc
+++ b/mojo/public/cpp/bindings/tests/versioning_test_service.cc
@@ -97,8 +97,9 @@
   HumanResourceSystemServer() {}
 
   // ApplicationDelegate implementation.
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<HumanResourceDatabase>(
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<HumanResourceDatabase>(
         [](const ConnectionContext& connection_context,
            InterfaceRequest<HumanResourceDatabase> hr_db_request) {
           // It will be deleted automatically when the underlying pipe
diff --git a/mojo/ui/content_viewer_app.cc b/mojo/ui/content_viewer_app.cc
index a56bbcb..edc5ad1 100644
--- a/mojo/ui/content_viewer_app.cc
+++ b/mojo/ui/content_viewer_app.cc
@@ -48,8 +48,8 @@
 }
 
 bool ContentViewerApp::ConfigureIncomingConnection(
-    mojo::ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<ContentHandler>([this](
+    ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<ContentHandler>([this](
       const ConnectionContext& connection_context,
       InterfaceRequest<ContentHandler> content_handler_request) {
     bindings_.AddBinding(
diff --git a/mojo/ui/content_viewer_app.h b/mojo/ui/content_viewer_app.h
index 0a1f0c1..e09a66a 100644
--- a/mojo/ui/content_viewer_app.h
+++ b/mojo/ui/content_viewer_app.h
@@ -28,7 +28,8 @@
 
   // |ApplicationDelegate|:
   void Initialize(ApplicationImpl* app) override;
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override;
 
   // Called to create the view provider application to view the content.
   //
diff --git a/mojo/ui/view_provider_app.cc b/mojo/ui/view_provider_app.cc
index 8a1fb1a..4de9593 100644
--- a/mojo/ui/view_provider_app.cc
+++ b/mojo/ui/view_provider_app.cc
@@ -51,8 +51,8 @@
 }
 
 bool ViewProviderApp::ConfigureIncomingConnection(
-    mojo::ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<ViewProvider>(
+    ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<ViewProvider>(
       [this](const ConnectionContext& connection_context,
              InterfaceRequest<ViewProvider> view_provider_request) {
         bindings_.AddBinding(
diff --git a/mojo/ui/view_provider_app.h b/mojo/ui/view_provider_app.h
index 60ae330..41c32f8 100644
--- a/mojo/ui/view_provider_app.h
+++ b/mojo/ui/view_provider_app.h
@@ -31,7 +31,8 @@
 
   // |ApplicationDelegate|:
   void Initialize(ApplicationImpl* app) override;
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override;
 
   // Called by the ViewProvider to create a view.
   // This method may be called multiple times in the case where the
diff --git a/services/asset_bundle/main.cc b/services/asset_bundle/main.cc
index 4ff8f17..1896263 100644
--- a/services/asset_bundle/main.cc
+++ b/services/asset_bundle/main.cc
@@ -20,8 +20,9 @@
 
  private:
   // |ApplicationDelegate| override:
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<AssetUnpacker>(
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<AssetUnpacker>(
         [this](const ConnectionContext& connection_context,
                InterfaceRequest<AssetUnpacker> asset_unpacker_request) {
           // Lazily initialize |sequenced_worker_pool_|. (We can't create it in
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 ea4df32..ffa7d09 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
@@ -23,20 +23,19 @@
 }
 
 bool AuthenticatingURLLoaderInterceptorApp::ConfigureIncomingConnection(
-    ApplicationConnection* connection) {
-  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]);
-          });
+    ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->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;
 }
 
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 5a71455..a8eadef 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
@@ -21,7 +21,8 @@
  private:
   // ApplicationDelegate
   void Initialize(ApplicationImpl* app) override;
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override;
 
   ApplicationImpl* app_;
   // Cache received tokens per origin of the connecting app and origin of the
diff --git a/services/authentication/main.cc b/services/authentication/main.cc
index dc17369..ff23499 100644
--- a/services/authentication/main.cc
+++ b/services/authentication/main.cc
@@ -31,8 +31,8 @@
   }
 
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<AuthenticationService>(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<AuthenticationService>(
         [this](const mojo::ConnectionContext& connection_context,
                mojo::InterfaceRequest<AuthenticationService> request) {
           mojo::files::Error error = mojo::files::Error::INTERNAL;
diff --git a/services/clipboard/main.cc b/services/clipboard/main.cc
index b6b3b5b..4ddbc31 100644
--- a/services/clipboard/main.cc
+++ b/services/clipboard/main.cc
@@ -15,8 +15,8 @@
 
   // mojo::ApplicationDelegate implementation.
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<mojo::Clipboard>(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<mojo::Clipboard>(
         [](const mojo::ConnectionContext& connection_context,
            mojo::InterfaceRequest<mojo::Clipboard> clipboard_request) {
           // TODO(erg): Write native implementations of the clipboard. For now,
diff --git a/services/dart/content_handler_main.cc b/services/dart/content_handler_main.cc
index 44acb66..957e690 100644
--- a/services/dart/content_handler_main.cc
+++ b/services/dart/content_handler_main.cc
@@ -237,15 +237,14 @@
 
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    bool strict = HasStrictQueryParam(connection->GetServiceProviderImpl()
-                                          .connection_context()
-                                          .connection_url);
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    bool strict = HasStrictQueryParam(
+        service_provider_impl->connection_context().connection_url);
     if (default_strict_ || strict) {
-      connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+      service_provider_impl->AddService<mojo::ContentHandler>(
           strict_content_handler_factory_.GetInterfaceRequestHandler());
     } else {
-      connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+      service_provider_impl->AddService<mojo::ContentHandler>(
           content_handler_factory_.GetInterfaceRequestHandler());
     }
     return true;
diff --git a/services/debugger/debugger.cc b/services/debugger/debugger.cc
index c43f144..e642f1a 100644
--- a/services/debugger/debugger.cc
+++ b/services/debugger/debugger.cc
@@ -69,11 +69,6 @@
                              [](bool result) { DCHECK(result); });
   }
 
-  bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    return true;
-  }
-
   // http_server::HttpHandler:
   void HandleRequest(http_server::HttpRequestPtr request,
                      const HandleRequestCallback& callback) override {
diff --git a/services/device_info/device_info.cc b/services/device_info/device_info.cc
index 84e66cd..01d46b2 100644
--- a/services/device_info/device_info.cc
+++ b/services/device_info/device_info.cc
@@ -29,8 +29,8 @@
 
   // |ApplicationDelegate| override.
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<mojo::DeviceInfo>(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<mojo::DeviceInfo>(
         [this](const ConnectionContext& connection_context,
                InterfaceRequest<mojo::DeviceInfo> device_info_request) {
           binding_.AddBinding(this, device_info_request.Pass());
diff --git a/services/files/main.cc b/services/files/main.cc
index 6d368de..c84b7ec 100644
--- a/services/files/main.cc
+++ b/services/files/main.cc
@@ -20,8 +20,9 @@
 
  private:
   // |ApplicationDelegate| override:
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<Files>(
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<Files>(
         [](const ConnectionContext& connection_context,
            InterfaceRequest<Files> files_request) {
           new FilesImpl(connection_context, files_request.Pass());
diff --git a/services/gfx/compositor/compositor_app.cc b/services/gfx/compositor/compositor_app.cc
index 858c443..555e4d7 100644
--- a/services/gfx/compositor/compositor_app.cc
+++ b/services/gfx/compositor/compositor_app.cc
@@ -35,15 +35,14 @@
 }
 
 bool CompositorApp::ConfigureIncomingConnection(
-    mojo::ApplicationConnection* connection) {
-  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());
-          });
+    mojo::ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->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;
 }
 
diff --git a/services/gfx/compositor/compositor_app.h b/services/gfx/compositor/compositor_app.h
index fc55367..ceb0428 100644
--- a/services/gfx/compositor/compositor_app.h
+++ b/services/gfx/compositor/compositor_app.h
@@ -27,7 +27,7 @@
   // |ApplicationDelegate|:
   void Initialize(mojo::ApplicationImpl* app_impl) override;
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override;
+      mojo::ServiceProviderImpl* service_provider_impl) 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 b449b73..2f1af79 100644
--- a/services/http_server/http_server_app.cc
+++ b/services/http_server/http_server_app.cc
@@ -24,8 +24,8 @@
  private:
   // ApplicationDelegate:
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<HttpServerFactory>([this](
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<HttpServerFactory>([this](
         const mojo::ConnectionContext& connection_context,
         mojo::InterfaceRequest<HttpServerFactory> http_server_factory_request) {
       if (!http_server_factory_)
diff --git a/services/icu_data/icu_data_impl.cc b/services/icu_data/icu_data_impl.cc
index 2a34755..bd2b65a 100644
--- a/services/icu_data/icu_data_impl.cc
+++ b/services/icu_data/icu_data_impl.cc
@@ -20,8 +20,8 @@
 
   // mojo::ApplicationDelegate implementation.
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<ICUData>(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<ICUData>(
         [this](const mojo::ConnectionContext& connection_context,
                mojo::InterfaceRequest<ICUData> icu_data_request) {
           bindings_.AddBinding(this, icu_data_request.Pass());
diff --git a/services/java_handler/java_handler.cc b/services/java_handler/java_handler.cc
index d8e2d91..1387c1a 100644
--- a/services/java_handler/java_handler.cc
+++ b/services/java_handler/java_handler.cc
@@ -119,8 +119,8 @@
 }
 
 bool JavaHandler::ConfigureIncomingConnection(
-    mojo::ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+    mojo::ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<mojo::ContentHandler>(
       content_handler_factory_.GetInterfaceRequestHandler());
   return true;
 }
diff --git a/services/java_handler/java_handler.h b/services/java_handler/java_handler.h
index 6e9b000..6f8c0ea 100644
--- a/services/java_handler/java_handler.h
+++ b/services/java_handler/java_handler.h
@@ -28,7 +28,7 @@
   // ApplicationDelegate:
   void Initialize(mojo::ApplicationImpl* app) override;
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override;
+      mojo::ServiceProviderImpl* service_provider_impl) override;
 
   // ContentHandlerFactory::Delegate:
   void RunApplication(
diff --git a/services/js/content_handler_main.cc b/services/js/content_handler_main.cc
index e102661..5f30561 100644
--- a/services/js/content_handler_main.cc
+++ b/services/js/content_handler_main.cc
@@ -31,8 +31,8 @@
 
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<mojo::ContentHandler>(
         content_handler_factory_.GetInterfaceRequestHandler());
     return true;
   }
diff --git a/services/keyboard/linux/main.cc b/services/keyboard/linux/main.cc
index 6ca21bd..19bd0ff 100644
--- a/services/keyboard/linux/main.cc
+++ b/services/keyboard/linux/main.cc
@@ -43,8 +43,8 @@
 
   // |ApplicationDelegate| override:
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<KeyboardServiceFactory>([](
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<KeyboardServiceFactory>([](
         const mojo::ConnectionContext& connection_context,
         mojo::InterfaceRequest<KeyboardServiceFactory>
             keyboard_service_factory_request) {
diff --git a/services/log/main.cc b/services/log/main.cc
index 2b5c92c..f9f8610 100644
--- a/services/log/main.cc
+++ b/services/log/main.cc
@@ -26,8 +26,9 @@
 
  private:
   // |ApplicationDelegate| override:
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<Log>(
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<Log>(
         [](const ConnectionContext& connection_context,
            InterfaceRequest<Log> log_request) {
           LogImpl::Create(connection_context, std::move(log_request),
diff --git a/services/media/audio/audio_server_app.cc b/services/media/audio/audio_server_app.cc
index 7eba44e..ef268c9 100644
--- a/services/media/audio/audio_server_app.cc
+++ b/services/media/audio/audio_server_app.cc
@@ -21,8 +21,8 @@
 }
 
 bool AudioServerApp::ConfigureIncomingConnection(
-    ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<AudioServer>(
+    ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<AudioServer>(
       [this](const ConnectionContext& connection_context,
              InterfaceRequest<AudioServer> audio_server_request) {
         bindings_.AddBinding(&server_impl_, audio_server_request.Pass());
diff --git a/services/media/audio/audio_server_app.h b/services/media/audio/audio_server_app.h
index 8fba580..87f6a39 100644
--- a/services/media/audio/audio_server_app.h
+++ b/services/media/audio/audio_server_app.h
@@ -21,7 +21,8 @@
 
   // ApplicationDelegate
   void Initialize(ApplicationImpl* app) override;
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override;
   void Quit() override;
 
  private:
diff --git a/services/media/factory_service/factory_service.cc b/services/media/factory_service/factory_service.cc
index feff176..6fe73f1 100644
--- a/services/media/factory_service/factory_service.cc
+++ b/services/media/factory_service/factory_service.cc
@@ -29,8 +29,8 @@
 }
 
 bool MediaFactoryService::ConfigureIncomingConnection(
-    ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<MediaFactory>(
+    ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<MediaFactory>(
       [this](const ConnectionContext& connection_context,
              InterfaceRequest<MediaFactory> media_factory_request) {
         bindings_.AddBinding(this, media_factory_request.Pass());
diff --git a/services/media/factory_service/factory_service.h b/services/media/factory_service/factory_service.h
index 9bb5d03..f2a7fd5 100644
--- a/services/media/factory_service/factory_service.h
+++ b/services/media/factory_service/factory_service.h
@@ -76,7 +76,8 @@
   // ApplicationDelegate implementation.
   void Initialize(ApplicationImpl* app) override;
 
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override;
 
   // MediaFactory implementation.
   void CreatePlayer(InterfaceHandle<SeekingReader> reader,
diff --git a/services/nacl/nonsfi/content_handler_main_nexe.cc b/services/nacl/nonsfi/content_handler_main_nexe.cc
index 003bfbe..207ecf0 100644
--- a/services/nacl/nonsfi/content_handler_main_nexe.cc
+++ b/services/nacl/nonsfi/content_handler_main_nexe.cc
@@ -27,8 +27,8 @@
 
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->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 4e0bb76..b992367 100644
--- a/services/nacl/nonsfi/content_handler_main_pexe.cc
+++ b/services/nacl/nonsfi/content_handler_main_pexe.cc
@@ -50,8 +50,8 @@
 
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<mojo::ContentHandler>(
         content_handler_factory_.GetInterfaceRequestHandler());
     return true;
   }
diff --git a/services/nacl/nonsfi/pnacl_compile.cc b/services/nacl/nonsfi/pnacl_compile.cc
index 5240c12..003184a 100644
--- a/services/nacl/nonsfi/pnacl_compile.cc
+++ b/services/nacl/nonsfi/pnacl_compile.cc
@@ -46,8 +46,9 @@
   MultiPexeCompiler() {}
 
   // From ApplicationDelegate
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<PexeCompilerInit>(
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<PexeCompilerInit>(
         [](const ConnectionContext& connection_context,
            InterfaceRequest<PexeCompilerInit> request) {
           new StrongBindingPexeCompilerImpl(request.Pass());
diff --git a/services/nacl/nonsfi/pnacl_link.cc b/services/nacl/nonsfi/pnacl_link.cc
index e2d3fad..7ac97ba 100644
--- a/services/nacl/nonsfi/pnacl_link.cc
+++ b/services/nacl/nonsfi/pnacl_link.cc
@@ -43,8 +43,9 @@
   MultiPexeLinker() {}
 
   // From ApplicationDelegate
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<PexeLinkerInit>(
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<PexeLinkerInit>(
         [](const ConnectionContext& connection_context,
            InterfaceRequest<PexeLinkerInit> request) {
           new StrongBindingPexeLinkerImpl(request.Pass());
diff --git a/services/nacl/sfi/content_handler_main.cc b/services/nacl/sfi/content_handler_main.cc
index dcca4a7..161c9c3 100644
--- a/services/nacl/sfi/content_handler_main.cc
+++ b/services/nacl/sfi/content_handler_main.cc
@@ -104,8 +104,8 @@
 
   // Overridden from ApplicationDelegate:
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<mojo::ContentHandler>(
         content_handler_factory_.GetInterfaceRequestHandler());
     return true;
   }
diff --git a/services/native_support/main.cc b/services/native_support/main.cc
index 9fdbfb9..98db478 100644
--- a/services/native_support/main.cc
+++ b/services/native_support/main.cc
@@ -29,8 +29,8 @@
  private:
   // |mojo::ApplicationDelegate| override:
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<Process>([this](
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<Process>([this](
         const mojo::ConnectionContext& connection_context,
         mojo::InterfaceRequest<Process> process_request) {
       if (!worker_pool_) {
diff --git a/services/native_viewport/app_delegate.cc b/services/native_viewport/app_delegate.cc
index e6ac534..0848298 100644
--- a/services/native_viewport/app_delegate.cc
+++ b/services/native_viewport/app_delegate.cc
@@ -60,8 +60,8 @@
 }
 
 bool NativeViewportAppDelegate::ConfigureIncomingConnection(
-    mojo::ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<mojo::NativeViewport>([this](
+    mojo::ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<mojo::NativeViewport>([this](
       const mojo::ConnectionContext& connection_context,
       mojo::InterfaceRequest<mojo::NativeViewport> native_viewport_request) {
     if (!gpu_state_.get())
@@ -70,7 +70,7 @@
                            native_viewport_request.Pass());
   });
 
-  connection->GetServiceProviderImpl().AddService<mojo::Gpu>(
+  service_provider_impl->AddService<mojo::Gpu>(
       [this](const mojo::ConnectionContext& connection_context,
              mojo::InterfaceRequest<mojo::Gpu> gpu_request) {
         if (!gpu_state_.get())
diff --git a/services/native_viewport/app_delegate.h b/services/native_viewport/app_delegate.h
index dc496e4..4c4390c 100644
--- a/services/native_viewport/app_delegate.h
+++ b/services/native_viewport/app_delegate.h
@@ -33,7 +33,7 @@
   void Initialize(mojo::ApplicationImpl* application) override;
 
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override;
+      mojo::ServiceProviderImpl* service_provider_impl) override;
 
  private:
   void InitLogging(mojo::ApplicationImpl* application);
diff --git a/services/native_viewport/ozone/app_delegate_ozone.cc b/services/native_viewport/ozone/app_delegate_ozone.cc
index 2750fc8..22d964f 100644
--- a/services/native_viewport/ozone/app_delegate_ozone.cc
+++ b/services/native_viewport/ozone/app_delegate_ozone.cc
@@ -24,8 +24,9 @@
 }
 
 bool NativeViewportOzoneAppDelegate::ConfigureIncomingConnection(
-    ApplicationConnection* connection) {
-  if (!NativeViewportAppDelegate::ConfigureIncomingConnection(connection))
+    ServiceProviderImpl* service_provider_impl) {
+  if (!NativeViewportAppDelegate::ConfigureIncomingConnection(
+          service_provider_impl))
     return false;
 
   auto ipc_init_helper = static_cast<ui::IpcInitHelperMojo*>(
diff --git a/services/native_viewport/ozone/app_delegate_ozone.h b/services/native_viewport/ozone/app_delegate_ozone.h
index 825f22a..c500206 100644
--- a/services/native_viewport/ozone/app_delegate_ozone.h
+++ b/services/native_viewport/ozone/app_delegate_ozone.h
@@ -15,7 +15,8 @@
   using NativeViewportAppDelegate::Create;
 
   void Initialize(mojo::ApplicationImpl* application) override;
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
+  bool ConfigureIncomingConnection(
+      mojo::ServiceProviderImpl* service_provider_impl) override;
 
  private:
   std::unique_ptr<DisplayManager> display_manager_;
diff --git a/services/prediction/prediction_service_impl.cc b/services/prediction/prediction_service_impl.cc
index 574102a..4c53f67 100644
--- a/services/prediction/prediction_service_impl.cc
+++ b/services/prediction/prediction_service_impl.cc
@@ -35,8 +35,8 @@
 PredictionServiceDelegate::~PredictionServiceDelegate() {}
 
 bool PredictionServiceDelegate::ConfigureIncomingConnection(
-    mojo::ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<PredictionService>(
+    mojo::ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<PredictionService>(
       [](const mojo::ConnectionContext& connection_context,
          mojo::InterfaceRequest<PredictionService> prediction_service_request) {
         new PredictionServiceImpl(prediction_service_request.Pass());
diff --git a/services/prediction/prediction_service_impl.h b/services/prediction/prediction_service_impl.h
index 6a1c51e..dc02b87 100644
--- a/services/prediction/prediction_service_impl.h
+++ b/services/prediction/prediction_service_impl.h
@@ -39,7 +39,7 @@
 
   // mojo::ApplicationDelegate implementation
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override;
+      mojo::ServiceProviderImpl* service_provider_impl) override;
 };
 
 }  // namespace prediction
diff --git a/services/python/content_handler/content_handler_main.cc b/services/python/content_handler/content_handler_main.cc
index d4d6f0a..e266495 100644
--- a/services/python/content_handler/content_handler_main.cc
+++ b/services/python/content_handler/content_handler_main.cc
@@ -212,14 +212,13 @@
 
  private:
   // Overridden from ApplicationDelegate:
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    if (IsDebug(connection->GetServiceProviderImpl()
-                    .connection_context()
-                    .connection_url)) {
-      connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+  bool ConfigureIncomingConnection(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    if (IsDebug(service_provider_impl->connection_context().connection_url)) {
+      service_provider_impl->AddService<mojo::ContentHandler>(
           debug_content_handler_factory_.GetInterfaceRequestHandler());
     } else {
-      connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+      service_provider_impl->AddService<mojo::ContentHandler>(
           content_handler_factory_.GetInterfaceRequestHandler());
     }
     return true;
diff --git a/services/test_service/test_request_tracker_application.cc b/services/test_service/test_request_tracker_application.cc
index b1f0715..c822601 100644
--- a/services/test_service/test_request_tracker_application.cc
+++ b/services/test_service/test_request_tracker_application.cc
@@ -26,20 +26,20 @@
 }
 
 bool TestRequestTrackerApplication::ConfigureIncomingConnection(
-    ApplicationConnection* connection) {
+    ServiceProviderImpl* service_provider_impl) {
   // Every instance of the service and recorder shares the context.
   // Note, this app is single-threaded, so this is thread safe.
-  connection->GetServiceProviderImpl().AddService<TestTimeService>(
+  service_provider_impl->AddService<TestTimeService>(
       [this](const ConnectionContext& connection_context,
              InterfaceRequest<TestTimeService> request) {
         new TestTimeServiceImpl(app_impl_, request.Pass());
       });
-  connection->GetServiceProviderImpl().AddService<TestRequestTracker>(
+  service_provider_impl->AddService<TestRequestTracker>(
       [this](const ConnectionContext& connection_context,
              InterfaceRequest<TestRequestTracker> request) {
         new TestRequestTrackerImpl(request.Pass(), &context_);
       });
-  connection->GetServiceProviderImpl().AddService<TestTrackedRequestService>(
+  service_provider_impl->AddService<TestTrackedRequestService>(
       [this](const ConnectionContext& connection_context,
              InterfaceRequest<TestTrackedRequestService> request) {
         new TestTrackedRequestServiceImpl(request.Pass(), &context_);
diff --git a/services/test_service/test_request_tracker_application.h b/services/test_service/test_request_tracker_application.h
index d936c48..53a01bf 100644
--- a/services/test_service/test_request_tracker_application.h
+++ b/services/test_service/test_request_tracker_application.h
@@ -23,7 +23,8 @@
   void Initialize(ApplicationImpl* app) override;
 
   // ApplicationDelegate methods:
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override;
 
  private:
   ApplicationImpl* app_impl_;
diff --git a/services/test_service/test_service_application.cc b/services/test_service/test_service_application.cc
index bf362d3..0c65da4 100644
--- a/services/test_service/test_service_application.cc
+++ b/services/test_service/test_service_application.cc
@@ -28,14 +28,14 @@
 }
 
 bool TestServiceApplication::ConfigureIncomingConnection(
-    ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<TestService>(
+    ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<TestService>(
       [this](const ConnectionContext& connection_context,
              InterfaceRequest<TestService> request) {
         new TestServiceImpl(app_impl_, this, request.Pass());
         AddRef();
       });
-  connection->GetServiceProviderImpl().AddService<TestTimeService>(
+  service_provider_impl->AddService<TestTimeService>(
       [this](const ConnectionContext& connection_context,
              InterfaceRequest<TestTimeService> request) {
         new TestTimeServiceImpl(app_impl_, request.Pass());
diff --git a/services/test_service/test_service_application.h b/services/test_service/test_service_application.h
index 625e4bb..277fa0c 100644
--- a/services/test_service/test_service_application.h
+++ b/services/test_service/test_service_application.h
@@ -23,7 +23,8 @@
   void Initialize(ApplicationImpl* app) override;
 
   // ApplicationDelegate implementation.
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override;
 
   void AddRef();
   void ReleaseRef();
diff --git a/services/tracing/tracing_app.cc b/services/tracing/tracing_app.cc
index 0413158..c1dead0 100644
--- a/services/tracing/tracing_app.cc
+++ b/services/tracing/tracing_app.cc
@@ -16,8 +16,8 @@
 TracingApp::~TracingApp() {}
 
 bool TracingApp::ConfigureIncomingConnection(
-    mojo::ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<TraceCollector>(
+    mojo::ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<TraceCollector>(
       [this](const mojo::ConnectionContext& connection_context,
              mojo::InterfaceRequest<TraceCollector> trace_collector_request) {
         if (collector_binding_.is_bound()) {
@@ -27,7 +27,7 @@
 
         collector_binding_.Bind(trace_collector_request.Pass());
       });
-  connection->GetServiceProviderImpl().AddService<TraceProviderRegistry>(
+  service_provider_impl->AddService<TraceProviderRegistry>(
       [this](const mojo::ConnectionContext& connection_context,
              mojo::InterfaceRequest<TraceProviderRegistry>
                  trace_provider_registry_request) {
diff --git a/services/tracing/tracing_app.h b/services/tracing/tracing_app.h
index 70c010e..d6a2b3b 100644
--- a/services/tracing/tracing_app.h
+++ b/services/tracing/tracing_app.h
@@ -30,7 +30,7 @@
  private:
   // mojo::ApplicationDelegate implementation.
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override;
+      mojo::ServiceProviderImpl* service_provider_impl) override;
 
   // TraceCollector implementation.
   void Start(mojo::ScopedDataPipeProducerHandle stream,
diff --git a/services/ui/input_manager/input_manager_app.cc b/services/ui/input_manager/input_manager_app.cc
index 0d2917d..5c48355 100644
--- a/services/ui/input_manager/input_manager_app.cc
+++ b/services/ui/input_manager/input_manager_app.cc
@@ -33,14 +33,13 @@
 }
 
 bool InputManagerApp::ConfigureIncomingConnection(
-    mojo::ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<mojo::ui::ViewAssociate>(
-      [this](const mojo::ConnectionContext& connection_context,
-             mojo::InterfaceRequest<mojo::ui::ViewAssociate>
-                 view_associate_request) {
-        input_associates_.AddBinding(new InputAssociate(),
-                                     view_associate_request.Pass());
-      });
+    mojo::ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<mojo::ui::ViewAssociate>([this](
+      const mojo::ConnectionContext& connection_context,
+      mojo::InterfaceRequest<mojo::ui::ViewAssociate> view_associate_request) {
+    input_associates_.AddBinding(new InputAssociate(),
+                                 view_associate_request.Pass());
+  });
   return true;
 }
 
diff --git a/services/ui/input_manager/input_manager_app.h b/services/ui/input_manager/input_manager_app.h
index 5c8a817..d0c13ac 100644
--- a/services/ui/input_manager/input_manager_app.h
+++ b/services/ui/input_manager/input_manager_app.h
@@ -25,7 +25,7 @@
   // |ApplicationDelegate|:
   void Initialize(mojo::ApplicationImpl* app_impl) override;
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override;
+      mojo::ServiceProviderImpl* service_provider_impl) override;
 
   mojo::ApplicationImpl* app_impl_;
   mojo::TracingImpl tracing_;
diff --git a/services/ui/launcher/launcher_app.cc b/services/ui/launcher/launcher_app.cc
index 9a6fe1f..31c16b2 100644
--- a/services/ui/launcher/launcher_app.cc
+++ b/services/ui/launcher/launcher_app.cc
@@ -37,12 +37,10 @@
 }
 
 bool LauncherApp::ConfigureIncomingConnection(
-    mojo::ApplicationConnection* connection) {
+    mojo::ServiceProviderImpl* service_provider_impl) {
   // Only present the launcher interface to the shell.
-  if (connection->GetServiceProviderImpl()
-          .connection_context()
-          .remote_url.empty()) {
-    connection->GetServiceProviderImpl().AddService<Launcher>(
+  if (service_provider_impl->connection_context().remote_url.empty()) {
+    service_provider_impl->AddService<Launcher>(
         [this](const mojo::ConnectionContext& connection_context,
                mojo::InterfaceRequest<Launcher> launcher_request) {
           bindings_.AddBinding(this, launcher_request.Pass());
diff --git a/services/ui/launcher/launcher_app.h b/services/ui/launcher/launcher_app.h
index f6a65d1..dcf0d48 100644
--- a/services/ui/launcher/launcher_app.h
+++ b/services/ui/launcher/launcher_app.h
@@ -25,7 +25,7 @@
   // |ApplicationDelegate|:
   void Initialize(mojo::ApplicationImpl* app_impl) override;
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override;
+      mojo::ServiceProviderImpl* service_provider_impl) override;
 
   // |Launcher|:
   void Launch(const mojo::String& application_url) override;
diff --git a/services/ui/view_manager/view_manager_app.cc b/services/ui/view_manager/view_manager_app.cc
index ae5c2eb..f7c7136 100644
--- a/services/ui/view_manager/view_manager_app.cc
+++ b/services/ui/view_manager/view_manager_app.cc
@@ -60,8 +60,8 @@
 }
 
 bool ViewManagerApp::ConfigureIncomingConnection(
-    mojo::ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<mojo::ui::ViewManager>([this](
+    mojo::ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<mojo::ui::ViewManager>([this](
       const mojo::ConnectionContext& connection_context,
       mojo::InterfaceRequest<mojo::ui::ViewManager> view_manager_request) {
     DCHECK(registry_);
diff --git a/services/ui/view_manager/view_manager_app.h b/services/ui/view_manager/view_manager_app.h
index 39c32cc..2c83451 100644
--- a/services/ui/view_manager/view_manager_app.h
+++ b/services/ui/view_manager/view_manager_app.h
@@ -27,7 +27,7 @@
   // |ApplicationDelegate|:
   void Initialize(mojo::ApplicationImpl* app_impl) override;
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override;
+      mojo::ServiceProviderImpl* service_provider_impl) override;
 
   void OnCompositorConnectionError();
   void OnAssociateConnectionError(const std::string& url);
diff --git a/services/url_response_disk_cache/url_response_disk_cache_app.cc b/services/url_response_disk_cache/url_response_disk_cache_app.cc
index a2f6ed8..84aa1b9 100644
--- a/services/url_response_disk_cache/url_response_disk_cache_app.cc
+++ b/services/url_response_disk_cache/url_response_disk_cache_app.cc
@@ -24,8 +24,8 @@
 }
 
 bool URLResponseDiskCacheApp::ConfigureIncomingConnection(
-    ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<URLResponseDiskCache>([this](
+    ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<URLResponseDiskCache>([this](
       const ConnectionContext& connection_context,
       InterfaceRequest<URLResponseDiskCache> request) {
     new URLResponseDiskCacheImpl(task_runner_, delegate_, db_,
diff --git a/services/url_response_disk_cache/url_response_disk_cache_app.h b/services/url_response_disk_cache/url_response_disk_cache_app.h
index 52d4e14..e6fb4c4 100644
--- a/services/url_response_disk_cache/url_response_disk_cache_app.h
+++ b/services/url_response_disk_cache/url_response_disk_cache_app.h
@@ -27,7 +27,8 @@
  private:
   // ApplicationDelegate:
   void Initialize(ApplicationImpl* app) override;
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
+  bool ConfigureIncomingConnection(
+      ServiceProviderImpl* service_provider_impl) override;
 
   scoped_refptr<base::TaskRunner> task_runner_;
   scoped_refptr<URLResponseDiskCacheDB> db_;
diff --git a/shell/android/android_handler.cc b/shell/android/android_handler.cc
index 2f0097f..5bb40600 100644
--- a/shell/android/android_handler.cc
+++ b/shell/android/android_handler.cc
@@ -131,8 +131,8 @@
 }
 
 bool AndroidHandler::ConfigureIncomingConnection(
-    mojo::ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<mojo::ContentHandler>(
+    mojo::ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<mojo::ContentHandler>(
       content_handler_factory_.GetInterfaceRequestHandler());
   return true;
 }
diff --git a/shell/android/android_handler.h b/shell/android/android_handler.h
index 2e5ef53..d9a96fe 100644
--- a/shell/android/android_handler.h
+++ b/shell/android/android_handler.h
@@ -29,7 +29,7 @@
   // mojo::ApplicationDelegate:
   void Initialize(mojo::ApplicationImpl* app) override;
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override;
+      mojo::ServiceProviderImpl* service_provider_impl) override;
 
   // mojo::ContentHandlerFactory::Delegate:
   void RunApplication(
diff --git a/shell/android/native_viewport_application_loader.cc b/shell/android/native_viewport_application_loader.cc
index 359f004..36e364b 100644
--- a/shell/android/native_viewport_application_loader.cc
+++ b/shell/android/native_viewport_application_loader.cc
@@ -28,8 +28,8 @@
 }
 
 bool NativeViewportApplicationLoader::ConfigureIncomingConnection(
-    ApplicationConnection* connection) {
-  connection->GetServiceProviderImpl().AddService<mojo::NativeViewport>(
+    mojo::ServiceProviderImpl* service_provider_impl) {
+  service_provider_impl->AddService<mojo::NativeViewport>(
       [this](const ConnectionContext& connection_context,
              InterfaceRequest<mojo::NativeViewport> native_viewport_request) {
         if (!gpu_state_)
@@ -37,7 +37,7 @@
         new native_viewport::NativeViewportImpl(app_.get(), false, gpu_state_,
                                                 native_viewport_request.Pass());
       });
-  connection->GetServiceProviderImpl().AddService<mojo::Gpu>(
+  service_provider_impl->AddService<mojo::Gpu>(
       [this](const ConnectionContext& connection_context,
              InterfaceRequest<mojo::Gpu> gpu_request) {
         if (!gpu_state_)
diff --git a/shell/android/native_viewport_application_loader.h b/shell/android/native_viewport_application_loader.h
index a1663b1..1087848 100644
--- a/shell/android/native_viewport_application_loader.h
+++ b/shell/android/native_viewport_application_loader.h
@@ -35,7 +35,7 @@
 
   // mojo::ApplicationDelegate implementation.
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override;
+      mojo::ServiceProviderImpl* service_provider_impl) override;
 
   scoped_refptr<gles2::GpuState> gpu_state_;
   scoped_ptr<mojo::ApplicationImpl> app_;
diff --git a/shell/application_manager/application_manager_unittest.cc b/shell/application_manager/application_manager_unittest.cc
index c8c677e..0337e85 100644
--- a/shell/application_manager/application_manager_unittest.cc
+++ b/shell/application_manager/application_manager_unittest.cc
@@ -121,8 +121,9 @@
   }
 
   // ApplicationDelegate implementation.
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<TestService>(
+  bool ConfigureIncomingConnection(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<TestService>(
         [this](const ConnectionContext& connection_context,
                InterfaceRequest<TestService> request) {
           new TestServiceImpl(context_, request.Pass());
@@ -305,9 +306,10 @@
     app_.reset(new ApplicationImpl(this, application_request.Pass()));
   }
 
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
+  bool ConfigureIncomingConnection(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
     const std::string& remote_url =
-        connection->GetServiceProviderImpl().connection_context().remote_url;
+        service_provider_impl->connection_context().remote_url;
     if (!requestor_url_.empty() && requestor_url_ != remote_url) {
       context_->set_tester_called_quit();
       context_->QuitSoon();
@@ -316,13 +318,13 @@
     }
     // If we're coming from A, then add B, otherwise A.
     if (remote_url == kTestAURLString) {
-      connection->GetServiceProviderImpl().AddService<TestB>(
+      service_provider_impl->AddService<TestB>(
           [this](const ConnectionContext& connection_context,
                  InterfaceRequest<TestB> test_b_request) {
             new TestBImpl(context_, test_b_request.Pass());
           });
     } else {
-      connection->GetServiceProviderImpl().AddService<TestA>(
+      service_provider_impl->AddService<TestA>(
           [this](const ConnectionContext& connection_context,
                  InterfaceRequest<TestA> test_a_request) {
             mojo::InterfaceHandle<mojo::ServiceProvider> incoming_sp_handle;
@@ -376,7 +378,8 @@
     base::MessageLoop::current()->Quit();
   }
 
-  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
+  bool ConfigureIncomingConnection(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
     configure_incoming_connection_called_ = true;
     base::MessageLoop::current()->Quit();
     return true;
diff --git a/shell/test/pingable_app.cc b/shell/test/pingable_app.cc
index f4520f6..c6a487d 100644
--- a/shell/test/pingable_app.cc
+++ b/shell/test/pingable_app.cc
@@ -50,8 +50,8 @@
   }
 
   bool ConfigureIncomingConnection(
-      mojo::ApplicationConnection* connection) override {
-    connection->GetServiceProviderImpl().AddService<Pingable>(
+      mojo::ServiceProviderImpl* service_provider_impl) override {
+    service_provider_impl->AddService<Pingable>(
         [this](const mojo::ConnectionContext& connection_context,
                mojo::InterfaceRequest<Pingable> pingable_request) {
           new PingableImpl(pingable_request.Pass(), app_url_,