ApplicationImpl::ConnectToServiceDeprecated() -> mojo::ConnectToService() conversion, part 3.

R=vardhan@google.com

Review URL: https://codereview.chromium.org/1919313002 .
diff --git a/services/test_service/test_service_impl.cc b/services/test_service/test_service_impl.cc
index aa0f4d5..27487c8 100644
--- a/services/test_service/test_service_impl.cc
+++ b/services/test_service/test_service_impl.cc
@@ -8,6 +8,7 @@
 #include "base/i18n/time_formatting.h"
 #include "base/strings/utf_string_conversions.h"
 #include "mojo/public/cpp/application/application_impl.h"
+#include "mojo/public/cpp/application/connect.h"
 #include "services/test_service/test_service_application.h"
 #include "services/test_service/test_time_service_impl.h"
 #include "services/test_service/tracked_service.h"
@@ -43,7 +44,7 @@
 void TestServiceImpl::ConnectToAppAndGetTime(
     const mojo::String& app_url,
     const mojo::Callback<void(int64_t)>& callback) {
-  app_impl_->ConnectToServiceDeprecated(app_url, &time_service_);
+  ConnectToService(app_impl_->shell(), app_url, GetProxy(&time_service_));
   if (tracking_) {
     tracking_->RecordNewRequest();
     time_service_->StartTrackingRequests(mojo::Callback<void()>());
@@ -54,8 +55,8 @@
 void TestServiceImpl::StartTrackingRequests(
     const mojo::Callback<void()>& callback) {
   TestRequestTrackerPtr tracker;
-  app_impl_->ConnectToServiceDeprecated("mojo:test_request_tracker_app",
-                                        &tracker);
+  ConnectToService(app_impl_->shell(), "mojo:test_request_tracker_app",
+                   GetProxy(&tracker));
   tracking_.reset(new TrackedService(tracker.Pass(), Name_, callback));
 }
 
diff --git a/services/test_service/test_time_service_impl.cc b/services/test_service/test_time_service_impl.cc
index f772d36..0f61f06 100644
--- a/services/test_service/test_time_service_impl.cc
+++ b/services/test_service/test_time_service_impl.cc
@@ -4,6 +4,7 @@
 
 #include "base/time/time.h"
 #include "mojo/public/cpp/application/application_impl.h"
+#include "mojo/public/cpp/application/connect.h"
 #include "services/test_service/test_request_tracker.mojom.h"
 #include "services/test_service/test_time_service_impl.h"
 #include "services/test_service/tracked_service.h"
@@ -23,8 +24,8 @@
 void TestTimeServiceImpl::StartTrackingRequests(
     const mojo::Callback<void()>& callback) {
   TestRequestTrackerPtr tracker;
-  app_impl_->ConnectToServiceDeprecated("mojo:test_request_tracker_app",
-                                        &tracker);
+  ConnectToService(app_impl_->shell(), "mojo:test_request_tracker_app",
+                   GetProxy(&tracker));
   tracking_.reset(new TrackedService(tracker.Pass(), Name_, callback));
 }
 
diff --git a/services/ui/launcher/launch_instance.cc b/services/ui/launcher/launch_instance.cc
index 4b87de4..47a7089 100644
--- a/services/ui/launcher/launch_instance.cc
+++ b/services/ui/launcher/launch_instance.cc
@@ -11,6 +11,7 @@
 #include "mojo/public/c/system/main.h"
 #include "mojo/public/cpp/application/application_connection.h"
 #include "mojo/public/cpp/application/application_impl.h"
+#include "mojo/public/cpp/application/connect.h"
 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h"
 #include "services/ui/launcher/launcher_view_tree.h"
 
@@ -30,22 +31,23 @@
   DVLOG(1) << "Launching " << app_url_;
   TRACE_EVENT0("launcher", __func__);
 
-  app_impl_->ConnectToServiceDeprecated("mojo:compositor_service",
-                                        &compositor_);
+  mojo::ConnectToService(app_impl_->shell(), "mojo:compositor_service",
+                         GetProxy(&compositor_));
   compositor_.set_connection_error_handler(base::Bind(
       &LaunchInstance::OnCompositorConnectionError, base::Unretained(this)));
 
-  app_impl_->ConnectToServiceDeprecated("mojo:view_manager_service",
-                                        &view_manager_);
+  mojo::ConnectToService(app_impl_->shell(), "mojo:view_manager_service",
+                         GetProxy(&view_manager_));
   view_manager_.set_connection_error_handler(base::Bind(
       &LaunchInstance::OnViewManagerConnectionError, base::Unretained(this)));
 
   InitViewport();
 
   mojo::ui::ViewProviderPtr client_view_provider;
-  app_impl_->ConnectToServiceDeprecated(app_url_, &client_view_provider);
+  mojo::ConnectToService(app_impl_->shell(), app_url_,
+                         GetProxy(&client_view_provider));
 
-  client_view_provider->CreateView(mojo::GetProxy(&client_view_owner_), nullptr,
+  client_view_provider->CreateView(GetProxy(&client_view_owner_), nullptr,
                                    nullptr);
 }
 
@@ -60,8 +62,8 @@
 }
 
 void LaunchInstance::InitViewport() {
-  app_impl_->ConnectToServiceDeprecated("mojo:native_viewport_service",
-                                        &viewport_);
+  mojo::ConnectToService(app_impl_->shell(), "mojo:native_viewport_service",
+                         GetProxy(&viewport_));
   viewport_.set_connection_error_handler(base::Bind(
       &LaunchInstance::OnViewportConnectionError, base::Unretained(this)));
 
diff --git a/services/ui/view_manager/view_associate_table.cc b/services/ui/view_manager/view_associate_table.cc
index f3913ca..2088696 100644
--- a/services/ui/view_manager/view_associate_table.cc
+++ b/services/ui/view_manager/view_associate_table.cc
@@ -8,6 +8,7 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
+#include "mojo/public/cpp/application/connect.h"
 #include "mojo/services/ui/views/cpp/formatting.h"
 
 namespace view_manager {
@@ -35,12 +36,12 @@
     associates_.emplace_back(new AssociateData(url, inspector));
     AssociateData* data = associates_.back().get();
 
-    app_impl->ConnectToServiceDeprecated(url, &data->associate);
+    mojo::ConnectToService(app_impl->shell(), url, GetProxy(&data->associate));
     data->associate.set_connection_error_handler(
         base::Bind(connection_error_callback, url));
 
     mojo::ui::ViewInspectorPtr inspector;
-    data->inspector_binding.Bind(mojo::GetProxy(&inspector));
+    data->inspector_binding.Bind(GetProxy(&inspector));
     data->associate->Connect(
         inspector.Pass(),
         base::Bind(&ViewAssociateTable::OnConnected, base::Unretained(this),
diff --git a/services/ui/view_manager/view_manager_app.cc b/services/ui/view_manager/view_manager_app.cc
index 07d2d89..a77b49a 100644
--- a/services/ui/view_manager/view_manager_app.cc
+++ b/services/ui/view_manager/view_manager_app.cc
@@ -15,6 +15,7 @@
 #include "mojo/public/c/system/main.h"
 #include "mojo/public/cpp/application/application_connection.h"
 #include "mojo/public/cpp/application/application_impl.h"
+#include "mojo/public/cpp/application/connect.h"
 #include "services/ui/view_manager/view_manager_impl.h"
 
 namespace view_manager {
@@ -36,7 +37,8 @@
 
   // Connect to compositor.
   mojo::gfx::composition::CompositorPtr compositor;
-  app_impl_->ConnectToServiceDeprecated("mojo:compositor_service", &compositor);
+  mojo::ConnectToService(app_impl_->shell(), "mojo:compositor_service",
+                         GetProxy(&compositor));
   compositor.set_connection_error_handler(base::Bind(
       &ViewManagerApp::OnCompositorConnectionError, base::Unretained(this)));
 
diff --git a/services/url_response_disk_cache/url_response_disk_cache_apptest.cc b/services/url_response_disk_cache/url_response_disk_cache_apptest.cc
index 765d070..adf7763 100644
--- a/services/url_response_disk_cache/url_response_disk_cache_apptest.cc
+++ b/services/url_response_disk_cache/url_response_disk_cache_apptest.cc
@@ -8,6 +8,7 @@
 #include "base/strings/stringprintf.h"
 #include "mojo/public/cpp/application/application_impl.h"
 #include "mojo/public/cpp/application/application_test_base.h"
+#include "mojo/public/cpp/application/connect.h"
 #include "mojo/public/cpp/system/data_pipe.h"
 #include "mojo/services/network/interfaces/url_loader.mojom.h"
 #include "mojo/services/url_response_disk_cache/interfaces/url_response_disk_cache.mojom.h"
@@ -23,9 +24,10 @@
   ~URLResponseDiskCacheAppTest() override {}
 
   void SetUp() override {
-    mojo::test::ApplicationTestBase::SetUp();
-    application_impl()->ConnectToServiceDeprecated(
-        "mojo:url_response_disk_cache", &url_response_disk_cache_);
+    test::ApplicationTestBase::SetUp();
+    ConnectToService(application_impl()->shell(),
+                     "mojo:url_response_disk_cache",
+                     GetProxy(&url_response_disk_cache_));
   }
 
  protected:
diff --git a/shell/android/android_handler.cc b/shell/android/android_handler.cc
index a092dea..b2c1118 100644
--- a/shell/android/android_handler.cc
+++ b/shell/android/android_handler.cc
@@ -20,6 +20,7 @@
 #include "mojo/data_pipe_utils/data_pipe_utils.h"
 #include "mojo/public/c/system/main.h"
 #include "mojo/public/cpp/application/application_impl.h"
+#include "mojo/public/cpp/application/connect.h"
 #include "shell/android/run_android_application_function.h"
 #include "shell/native_application_support.h"
 
@@ -125,8 +126,8 @@
 
 void AndroidHandler::Initialize(mojo::ApplicationImpl* app) {
   handler_task_runner_ = base::MessageLoop::current()->task_runner();
-  app->ConnectToServiceDeprecated("mojo:url_response_disk_cache",
-                                  &url_response_disk_cache_);
+  mojo::ConnectToService(app->shell(), "mojo:url_response_disk_cache",
+                         GetProxy(&url_response_disk_cache_));
 }
 
 bool AndroidHandler::ConfigureIncomingConnection(
diff --git a/shell/android/nfc_apptest.cc b/shell/android/nfc_apptest.cc
index 2e062ea..797ae68 100644
--- a/shell/android/nfc_apptest.cc
+++ b/shell/android/nfc_apptest.cc
@@ -6,6 +6,7 @@
 #include "base/message_loop/message_loop.h"
 #include "mojo/public/cpp/application/application_impl.h"
 #include "mojo/public/cpp/application/application_test_base.h"
+#include "mojo/public/cpp/application/connect.h"
 #include "mojo/public/cpp/bindings/callback.h"
 #include "mojo/public/cpp/environment/logging.h"
 #include "mojo/public/cpp/system/macros.h"
@@ -26,7 +27,7 @@
   // ApplicationTestBase:
   void SetUp() override {
     ApplicationTestBase::SetUp();
-    application_impl()->ConnectToServiceDeprecated("mojo:nfc", &nfc_);
+    ConnectToService(application_impl()->shell(), "mojo:nfc", GetProxy(&nfc_));
   }
 
   nfc::NfcPtr nfc_;
diff --git a/shell/shell_apptest.cc b/shell/shell_apptest.cc
index bf53dc5..f4b8154 100644
--- a/shell/shell_apptest.cc
+++ b/shell/shell_apptest.cc
@@ -80,8 +80,8 @@
   void SetUp() override {
     ShellAppTest::SetUp();
 
-    application_impl()->ConnectToServiceDeprecated("mojo:http_server",
-                                                   &http_server_factory_);
+    mojo::ConnectToService(application_impl()->shell(), "mojo:http_server",
+                           GetProxy(&http_server_factory_));
 
     mojo::NetAddressPtr local_address(mojo::NetAddress::New());
     local_address->family = mojo::NetAddressFamily::IPV4;
@@ -119,7 +119,8 @@
 // Test that we can load apps over http.
 TEST_F(ShellHTTPAppTest, Http) {
   PingablePtr pingable;
-  application_impl()->ConnectToServiceDeprecated(GetURL("app"), &pingable);
+  mojo::ConnectToService(application_impl()->shell(), GetURL("app"),
+                         GetProxy(&pingable));
   pingable->Ping("hello",
                  [this](const String& app_url, const String& connection_url,
                         const String& message) {
@@ -135,7 +136,8 @@
 // TODO(aa): Test that apps receive the correct URL parameters.
 TEST_F(ShellHTTPAppTest, Redirect) {
   PingablePtr pingable;
-  application_impl()->ConnectToServiceDeprecated(GetURL("redirect"), &pingable);
+  mojo::ConnectToService(application_impl()->shell(), GetURL("redirect"),
+                         GetProxy(&pingable));
   pingable->Ping("hello",
                  [this](const String& app_url, const String& connection_url,
                         const String& message) {
@@ -157,8 +159,10 @@
 TEST_F(ShellHTTPAppTest, MAYBE_QueryHandling) {
   PingablePtr pingable1;
   PingablePtr pingable2;
-  application_impl()->ConnectToServiceDeprecated(GetURL("app?foo"), &pingable1);
-  application_impl()->ConnectToServiceDeprecated(GetURL("app?bar"), &pingable2);
+  mojo::ConnectToService(application_impl()->shell(), GetURL("app?foo"),
+                         GetProxy(&pingable1));
+  mojo::ConnectToService(application_impl()->shell(), GetURL("app?bar"),
+                         GetProxy(&pingable2));
 
   int num_responses = 0;
   auto callbacks_builder = [this, &num_responses](int query_index) {
@@ -187,8 +191,8 @@
 // mojo: URLs can have querystrings too
 TEST_F(ShellAppTest, MojoURLQueryHandling) {
   PingablePtr pingable;
-  application_impl()->ConnectToServiceDeprecated("mojo:pingable_app?foo",
-                                                 &pingable);
+  mojo::ConnectToService(application_impl()->shell(), "mojo:pingable_app?foo",
+                         GetProxy(&pingable));
   auto callback = [](const String& app_url, const String& connection_url,
                      const String& message) {
     EXPECT_TRUE(base::EndsWith(app_url.To<base::StringPiece>(),