Convert //shell/... to use set_connection_error_handler() instead of set_error_handler().

(The latter is deprecated.)

R=rudominer@chromium.org

Review URL: https://codereview.chromium.org/1219683015 .
diff --git a/shell/application_manager/application_manager.cc b/shell/application_manager/application_manager.cc
index 5da52a7..105ae82 100644
--- a/shell/application_manager/application_manager.cc
+++ b/shell/application_manager/application_manager.cc
@@ -47,7 +47,7 @@
 
 }  // namespace
 
-class ApplicationManager::ContentHandlerConnection : public mojo::ErrorHandler {
+class ApplicationManager::ContentHandlerConnection {
  public:
   ContentHandlerConnection(ApplicationManager* manager,
                            const GURL& content_handler_url)
@@ -61,17 +61,16 @@
         mojo::InterfacePtrInfo<mojo::ContentHandler>(pipe.handle0.Pass(), 0u));
     services->ConnectToService(mojo::ContentHandler::Name_,
                                pipe.handle1.Pass());
-    content_handler_.set_error_handler(this);
+    content_handler_.set_connection_error_handler(
+        [this]() { manager_->OnContentHandlerError(this); });
   }
+  ~ContentHandlerConnection() {}
 
   mojo::ContentHandler* content_handler() { return content_handler_.get(); }
 
   GURL content_handler_url() { return content_handler_url_; }
 
  private:
-  // mojo::ErrorHandler implementation:
-  void OnConnectionError() override { manager_->OnContentHandlerError(this); }
-
   ApplicationManager* manager_;
   GURL content_handler_url_;
   mojo::ContentHandlerPtr content_handler_;
diff --git a/shell/application_manager/application_manager_unittest.cc b/shell/application_manager/application_manager_unittest.cc
index b346681..3167967 100644
--- a/shell/application_manager/application_manager_unittest.cc
+++ b/shell/application_manager/application_manager_unittest.cc
@@ -46,20 +46,6 @@
   base::MessageLoop::current()->QuitWhenIdle();
 }
 
-class QuitMessageLoopErrorHandler : public mojo::ErrorHandler {
- public:
-  QuitMessageLoopErrorHandler() {}
-  ~QuitMessageLoopErrorHandler() override {}
-
-  // |mojo::ErrorHandler| implementation:
-  void OnConnectionError() override {
-    base::MessageLoop::current()->QuitWhenIdle();
-  }
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(QuitMessageLoopErrorHandler);
-};
-
 class TestServiceImpl : public TestService {
  public:
   TestServiceImpl(TestContext* context, InterfaceRequest<TestService> request)
@@ -741,8 +727,8 @@
   // ApplicationManager, so this cannot succeed (but also shouldn't crash).
   TestCPtr c;
   application_manager_->ConnectToService(GURL(kTestAURLString), &c);
-  QuitMessageLoopErrorHandler quitter;
-  c.set_error_handler(&quitter);
+  c.set_connection_error_handler(
+      []() { base::MessageLoop::current()->QuitWhenIdle(); });
 
   loop_.Run();
   EXPECT_TRUE(c.encountered_error());
diff --git a/shell/application_manager/shell_impl.cc b/shell/application_manager/shell_impl.cc
index 0384ed7..131383e 100644
--- a/shell/application_manager/shell_impl.cc
+++ b/shell/application_manager/shell_impl.cc
@@ -22,7 +22,8 @@
       on_application_end_(on_application_end),
       application_(application.Pass()),
       binding_(this) {
-  binding_.set_error_handler(this);
+  binding_.set_connection_error_handler(
+      [this]() { manager_->OnShellImplError(this); });
 }
 
 ShellImpl::~ShellImpl() {
@@ -58,8 +59,4 @@
                                  exposed_services.Pass(), base::Closure());
 }
 
-void ShellImpl::OnConnectionError() {
-  manager_->OnShellImplError(this);
-}
-
 }  // namespace shell
diff --git a/shell/application_manager/shell_impl.h b/shell/application_manager/shell_impl.h
index eb3c78a..834f085 100644
--- a/shell/application_manager/shell_impl.h
+++ b/shell/application_manager/shell_impl.h
@@ -17,7 +17,7 @@
 
 class ApplicationManager;
 
-class ShellImpl : public mojo::Shell, public mojo::ErrorHandler {
+class ShellImpl : public mojo::Shell {
  public:
   ShellImpl(mojo::ApplicationPtr application,
             ApplicationManager* manager,
@@ -44,9 +44,6 @@
       mojo::InterfaceRequest<mojo::ServiceProvider> services,
       mojo::ServiceProviderPtr exposed_services) override;
 
-  // mojo::ErrorHandler implementation:
-  void OnConnectionError() override;
-
   ApplicationManager* const manager_;
   const Identity identity_;
   base::Closure on_application_end_;
diff --git a/shell/child_main.cc b/shell/child_main.cc
index 447a939..05abbc6 100644
--- a/shell/child_main.cc
+++ b/shell/child_main.cc
@@ -175,7 +175,7 @@
 
 // ChildControllerImpl ---------------------------------------------------------
 
-class ChildControllerImpl : public ChildController, public mojo::ErrorHandler {
+class ChildControllerImpl : public ChildController {
  public:
   ~ChildControllerImpl() override {
     DCHECK(thread_checker_.CalledOnValidThread());
@@ -210,14 +210,6 @@
     binding_.Bind(handle.Pass());
   }
 
-  // |mojo::ErrorHandler| methods:
-  void OnConnectionError() override {
-    // A connection error means the connection to the shell is lost. This is not
-    // recoverable.
-    LOG(ERROR) << "Connection error to the shell";
-    _exit(1);
-  }
-
   // |ChildController| methods:
   void StartApp(const mojo::String& app_path,
                 mojo::InterfaceRequest<mojo::Application> application_request,
@@ -243,7 +235,14 @@
         unblocker_(unblocker),
         channel_info_(nullptr),
         binding_(this) {
-    binding_.set_error_handler(this);
+    binding_.set_connection_error_handler([this]() { OnConnectionError(); });
+  }
+
+  void OnConnectionError() {
+    // A connection error means the connection to the shell is lost. This is not
+    // recoverable.
+    LOG(ERROR) << "Connection error to the shell";
+    _exit(1);
   }
 
   // Callback for |mojo::embedder::ConnectToMaster()|.
diff --git a/shell/child_process_host.cc b/shell/child_process_host.cc
index ec51ec5..b0bc6ad 100644
--- a/shell/child_process_host.cc
+++ b/shell/child_process_host.cc
@@ -60,7 +60,7 @@
   CHECK(channel_info_);
 
   controller_.Bind(mojo::InterfacePtrInfo<ChildController>(handle.Pass(), 0u));
-  controller_.set_error_handler(this);
+  controller_.set_connection_error_handler([this]() { OnConnectionError(); });
 
   CHECK(base::PostTaskAndReplyWithResult(
       context_->task_runners()->blocking_pool(), FROM_HERE,
diff --git a/shell/child_process_host.h b/shell/child_process_host.h
index 67f243d..d065ce6 100644
--- a/shell/child_process_host.h
+++ b/shell/child_process_host.h
@@ -27,10 +27,12 @@
 //
 // This class is not thread-safe. It should be created/used/destroyed on a
 // single thread.
-class ChildProcessHost : public mojo::ErrorHandler {
+class ChildProcessHost {
  public:
   explicit ChildProcessHost(Context* context);
-  ~ChildProcessHost() override;
+  // TODO(vtl): Virtual because |DidStart()| is, even though it shouldn't be
+  // (see |DidStart()|).
+  virtual ~ChildProcessHost();
 
   // |Start()|s the child process; calls |DidStart()| (on the thread on which
   // |Start()| was called) when the child has been started (or failed to start).
@@ -73,9 +75,7 @@
   base::Process DoLaunch(scoped_ptr<LaunchData> launch_data);
 
   void AppCompleted(int32_t result);
-
-  // |mojo::ErrorHandler| methods:
-  void OnConnectionError() override;
+  void OnConnectionError();
 
   Context* const context_;
 
diff --git a/shell/shell_test_base_unittest.cc b/shell/shell_test_base_unittest.cc
index 03d047d..89461c0 100644
--- a/shell/shell_test_base_unittest.cc
+++ b/shell/shell_test_base_unittest.cc
@@ -71,20 +71,6 @@
   TestTrackedRequestServicePtr request_tracking_;
 };
 
-class QuitMessageLoopErrorHandler : public mojo::ErrorHandler {
- public:
-  QuitMessageLoopErrorHandler() {}
-  ~QuitMessageLoopErrorHandler() override {}
-
-  // |mojo::ErrorHandler| implementation:
-  void OnConnectionError() override {
-    base::MessageLoop::current()->QuitWhenIdle();
-  }
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(QuitMessageLoopErrorHandler);
-};
-
 // Tests that we can connect to a single service within a single app.
 TEST_F(ShellTestBaseTest, ConnectBasic) {
   TestServicePtr service;
@@ -119,8 +105,8 @@
 
   // It may have quit before an error was processed.
   if (!test_service.encountered_error()) {
-    QuitMessageLoopErrorHandler quitter;
-    test_service.set_error_handler(&quitter);
+    test_service.set_connection_error_handler(
+        []() { base::MessageLoop::current()->QuitWhenIdle(); });
     message_loop()->Run();
     EXPECT_TRUE(test_service.encountered_error());
   }
@@ -162,8 +148,8 @@
   TestServicePtr test_service;
   ConnectToService(GURL("http://example.com/non_existent_service"),
                    &test_service);
-  QuitMessageLoopErrorHandler quitter;
-  test_service.set_error_handler(&quitter);
+  test_service.set_connection_error_handler(
+      []() { base::MessageLoop::current()->QuitWhenIdle(); });
   bool was_run = false;
   test_service->Ping(SetAndQuit<bool>(&was_run, true));
   message_loop()->Run();