Remove calls to deprecated MessageLoop methods on Windows and Linux.

This Cl removes most calls to these methods on Windows and Linux:
- MessageLoop::PostTask
- MessageLoop::PostDelayedTask
- MessageLoop::ReleaseSoon
- MessageLoop::DeleteSoon
- MessageLoop::Run
- MessageLoop::RunUntilIdle

Also note that calls to thread->message_loop()->task_runner() have
been replaced with thread->task_runner() (|thread| is a base::Thread).

This CL was generated by running the clang-tidy checks available here
https://crbug.com/616447#c153 on Windows and Mac and by applying a few
manual fixes (e.g. to remove a call made from a macro in
audio_low_latency_input_win_unittest.cc).

BUG=616447
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation

Review-Url: https://codereview.chromium.org/2211473003
Cr-Original-Commit-Position: refs/heads/master@{#414442}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 6ef45cf47455fb44e8fa0ab5d1ba545c91429941
diff --git a/end_to_end_async_unittest.cc b/end_to_end_async_unittest.cc
index b02b043..2de55c3 100644
--- a/end_to_end_async_unittest.cc
+++ b/end_to_end_async_unittest.cc
@@ -13,6 +13,7 @@
 #include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/single_thread_task_runner.h"
 #include "base/stl_util.h"
 #include "base/test/test_timeouts.h"
 #include "base/threading/thread.h"
@@ -441,9 +442,8 @@
 
   // We shouldn't receive any responses. Wait for a while just to make sure.
   run_loop_.reset(new base::RunLoop);
-  message_loop_.PostDelayedTask(FROM_HERE,
-                                run_loop_->QuitClosure(),
-                                TestTimeouts::tiny_timeout());
+  message_loop_.task_runner()->PostDelayedTask(
+      FROM_HERE, run_loop_->QuitClosure(), TestTimeouts::tiny_timeout());
   run_loop_->Run();
   EXPECT_TRUE(response_strings_.empty());
 }
@@ -565,9 +565,8 @@
                             ObjectProxy::EmptyResponseCallback());
   // Post a delayed task to quit the message loop.
   run_loop_.reset(new base::RunLoop);
-  message_loop_.PostDelayedTask(FROM_HERE,
-                                run_loop_->QuitClosure(),
-                                TestTimeouts::tiny_timeout());
+  message_loop_.task_runner()->PostDelayedTask(
+      FROM_HERE, run_loop_->QuitClosure(), TestTimeouts::tiny_timeout());
   run_loop_->Run();
   // We cannot tell if the empty callback is called, but at least we can
   // check if the test does not crash.
diff --git a/mock_unittest.cc b/mock_unittest.cc
index ed78e2c..15bdf27 100644
--- a/mock_unittest.cc
+++ b/mock_unittest.cc
@@ -9,6 +9,7 @@
 #include "base/memory/ref_counted.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/single_thread_task_runner.h"
 #include "dbus/message.h"
 #include "dbus/mock_bus.h"
 #include "dbus/mock_exported_object.h"
@@ -121,11 +122,10 @@
       int timeout_ms,
       ObjectProxy::ResponseCallback response_callback) {
     Response* response = CreateMockProxyResponse(method_call, timeout_ms);
-    message_loop_.PostTask(FROM_HERE,
-                           base::Bind(&MockTest::RunResponseCallback,
-                                      base::Unretained(this),
-                                      response_callback,
-                                      response));
+    message_loop_.task_runner()->PostTask(
+        FROM_HERE,
+        base::Bind(&MockTest::RunResponseCallback, base::Unretained(this),
+                   response_callback, response));
   }
 
   // Runs the given response callback with the given response.
diff --git a/object_manager_unittest.cc b/object_manager_unittest.cc
index ae03776..d28368b 100644
--- a/object_manager_unittest.cc
+++ b/object_manager_unittest.cc
@@ -13,6 +13,7 @@
 #include "base/bind.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/single_thread_task_runner.h"
 #include "base/threading/thread.h"
 #include "base/threading/thread_restrictions.h"
 #include "dbus/bus.h"
@@ -404,10 +405,9 @@
   // after setting up the match rule for PropertiesChanged. We should process
   // the PropertiesChanged event right after that. If we don't receive it within
   // 2 seconds, then fail the test.
-  message_loop_.PostDelayedTask(
-      FROM_HERE,
-      base::Bind(&ObjectManagerTest::PropertiesChangedTestTimeout,
-                 base::Unretained(this)),
+  message_loop_.task_runner()->PostDelayedTask(
+      FROM_HERE, base::Bind(&ObjectManagerTest::PropertiesChangedTestTimeout,
+                            base::Unretained(this)),
       base::TimeDelta::FromSeconds(2));
 
   while (last_name_value_ != "ChangedTestServiceName" && !timeout_expired_) {
diff --git a/signal_sender_verification_unittest.cc b/signal_sender_verification_unittest.cc
index 3b2cf6f..320718d 100644
--- a/signal_sender_verification_unittest.cc
+++ b/signal_sender_verification_unittest.cc
@@ -10,6 +10,7 @@
 #include "base/metrics/histogram_samples.h"
 #include "base/metrics/statistics_recorder.h"
 #include "base/run_loop.h"
+#include "base/single_thread_task_runner.h"
 #include "base/test/test_timeouts.h"
 #include "base/threading/platform_thread.h"
 #include "base/threading/thread_restrictions.h"
@@ -117,7 +118,7 @@
   void OnOwnership(bool expected, bool success) {
     ASSERT_EQ(expected, success);
     // PostTask to quit the MessageLoop as this is called from D-Bus thread.
-    message_loop_.PostTask(
+    message_loop_.task_runner()->PostTask(
         FROM_HERE,
         base::Bind(&SignalSenderVerificationTest::OnOwnershipInternal,
                    base::Unretained(this)));
diff --git a/test_service.cc b/test_service.cc
index 4465c19..209b41d 100644
--- a/test_service.cc
+++ b/test_service.cc
@@ -12,6 +12,7 @@
 #include "base/bind.h"
 #include "base/guid.h"
 #include "base/run_loop.h"
+#include "base/single_thread_task_runner.h"
 #include "base/test/test_timeouts.h"
 #include "base/threading/platform_thread.h"
 #include "dbus/bus.h"
@@ -75,10 +76,9 @@
 }
 
 void TestService::ShutdownAndBlock() {
-  message_loop()->PostTask(
-      FROM_HERE,
-      base::Bind(&TestService::ShutdownAndBlockInternal,
-                 base::Unretained(this)));
+  message_loop()->task_runner()->PostTask(
+      FROM_HERE, base::Bind(&TestService::ShutdownAndBlockInternal,
+                            base::Unretained(this)));
 }
 
 bool TestService::HasDBusThread() {
@@ -93,19 +93,15 @@
 }
 
 void TestService::SendTestSignal(const std::string& message) {
-  message_loop()->PostTask(
-      FROM_HERE,
-      base::Bind(&TestService::SendTestSignalInternal,
-                 base::Unretained(this),
-                 message));
+  message_loop()->task_runner()->PostTask(
+      FROM_HERE, base::Bind(&TestService::SendTestSignalInternal,
+                            base::Unretained(this), message));
 }
 
 void TestService::SendTestSignalFromRoot(const std::string& message) {
-  message_loop()->PostTask(
-      FROM_HERE,
-      base::Bind(&TestService::SendTestSignalFromRootInternal,
-                 base::Unretained(this),
-                 message));
+  message_loop()->task_runner()->PostTask(
+      FROM_HERE, base::Bind(&TestService::SendTestSignalFromRootInternal,
+                            base::Unretained(this), message));
 }
 
 void TestService::SendTestSignalInternal(const std::string& message) {
@@ -132,11 +128,9 @@
 }
 
 void TestService::RequestOwnership(base::Callback<void(bool)> callback) {
-  message_loop()->PostTask(
-      FROM_HERE,
-      base::Bind(&TestService::RequestOwnershipInternal,
-                 base::Unretained(this),
-                 callback));
+  message_loop()->task_runner()->PostTask(
+      FROM_HERE, base::Bind(&TestService::RequestOwnershipInternal,
+                            base::Unretained(this), callback));
 }
 
 void TestService::RequestOwnershipInternal(
@@ -330,12 +324,10 @@
 void TestService::AsyncEcho(MethodCall* method_call,
                             ExportedObject::ResponseSender response_sender) {
   // Schedule a call to Echo() to send an asynchronous response after we return.
-  message_loop()->PostDelayedTask(FROM_HERE,
-                                  base::Bind(&TestService::Echo,
-                                             base::Unretained(this),
-                                             method_call,
-                                             response_sender),
-                                  TestTimeouts::tiny_timeout());
+  message_loop()->task_runner()->PostDelayedTask(
+      FROM_HERE, base::Bind(&TestService::Echo, base::Unretained(this),
+                            method_call, response_sender),
+      TestTimeouts::tiny_timeout());
 }
 
 void TestService::BrokenMethod(MethodCall* method_call,
@@ -648,11 +640,9 @@
 }
 
 void TestService::AddObject(const ObjectPath& object_path) {
-  message_loop()->PostTask(
-      FROM_HERE,
-      base::Bind(&TestService::AddObjectInternal,
-                 base::Unretained(this),
-                 object_path));
+  message_loop()->task_runner()->PostTask(
+      FROM_HERE, base::Bind(&TestService::AddObjectInternal,
+                            base::Unretained(this), object_path));
 }
 
 void TestService::AddObjectInternal(const ObjectPath& object_path) {
@@ -674,10 +664,9 @@
 }
 
 void TestService::RemoveObject(const ObjectPath& object_path) {
-  message_loop()->PostTask(FROM_HERE,
-                           base::Bind(&TestService::RemoveObjectInternal,
-                                      base::Unretained(this),
-                                      object_path));
+  message_loop()->task_runner()->PostTask(
+      FROM_HERE, base::Bind(&TestService::RemoveObjectInternal,
+                            base::Unretained(this), object_path));
 }
 
 void TestService::RemoveObjectInternal(const ObjectPath& object_path) {
@@ -694,11 +683,9 @@
 }
 
 void TestService::SendPropertyChangedSignal(const std::string& name) {
-  message_loop()->PostTask(
-      FROM_HERE,
-      base::Bind(&TestService::SendPropertyChangedSignalInternal,
-                 base::Unretained(this),
-                 name));
+  message_loop()->task_runner()->PostTask(
+      FROM_HERE, base::Bind(&TestService::SendPropertyChangedSignalInternal,
+                            base::Unretained(this), name));
 }
 
 void TestService::SendPropertyChangedSignalInternal(const std::string& name) {
@@ -725,7 +712,7 @@
 }
 
 void TestService::SendPropertyInvalidatedSignal() {
-  message_loop()->PostTask(
+  message_loop()->task_runner()->PostTask(
       FROM_HERE, base::Bind(&TestService::SendPropertyInvalidatedSignalInternal,
                             base::Unretained(this)));
 }