Remove calls to deprecated MessageLoop methods in tools.

This CL makes the following replacements in
tools:

Before               After
----------------------------------------------------------
 x.PostTask()          x.task_runner()->PostTask()
   PostDelayedTask()                    PostDelayedTask()
   ReleaseSoon()                        ReleaseSoon()
   DeleteSoon()                         DeleteSoon()
x->PostTask()         y->task_runner()->PostTask()
   PostDelayedTask()                    PostDelayedTask()
   ReleaseSoon()                        ReleaseSoon()
   DeleteSoon()                         DeleteSoon()

 x.Run()              RunLoop().Run()
 x.RunUntilIdle()     RunLoop().RunUntilIdle()

x->Run()              RunLoop().Run()
x->RunUntilIdle()     RunLoop().RunUntilIdle()
    If |y| isn't MessageLoopForUI::current() or
    MessageLoopForIO::current()

 y.message_loop()->task_runner()
                      y.task_runner()
y->message_loop()->task_runner()
                      y->task_runner()
----------------------------------------------------------

|x| is a base::MessageLoop(ForUI|ForIO) or a pointer to
a base::MessageLoop(ForUI|ForIO). |y| is a base::Thread
or a pointer to a base::Thread.

This CL was generated using the MessageLoopDeprecatedMethods
clang-tidy fix available on the associated bug. Only files
that compile on Mac are affected. Follow-up CLs will make
these replacements for other platforms.

This CL doesn't change code behavior.

BUG=616447
R=thakis@chromium.org

Review-Url: https://codereview.chromium.org/2085023004
Cr-Original-Commit-Position: refs/heads/master@{#401371}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 01c8157ece1ba00df660bdf8c17cf01bae3cd230
diff --git a/tools/gn/loader.cc b/tools/gn/loader.cc
index e3165b9..69fb766 100644
--- a/tools/gn/loader.cc
+++ b/tools/gn/loader.cc
@@ -7,6 +7,7 @@
 #include "base/bind.h"
 #include "base/memory/ptr_util.h"
 #include "base/message_loop/message_loop.h"
+#include "base/single_thread_task_runner.h"
 #include "tools/gn/build_settings.h"
 #include "tools/gn/err.h"
 #include "tools/gn/filesystem_utils.h"
@@ -238,8 +239,8 @@
                                     const LocationRange& origin,
                                     const ParseNode* root) {
   if (!root) {
-    main_loop_->PostTask(FROM_HERE,
-        base::Bind(&LoaderImpl::DecrementPendingLoads, this));
+    main_loop_->task_runner()->PostTask(
+        FROM_HERE, base::Bind(&LoaderImpl::DecrementPendingLoads, this));
     return;
   }
 
@@ -279,7 +280,8 @@
 
   trace.Done();
 
-  main_loop_->PostTask(FROM_HERE, base::Bind(&LoaderImpl::DidLoadFile, this));
+  main_loop_->task_runner()->PostTask(
+      FROM_HERE, base::Bind(&LoaderImpl::DidLoadFile, this));
 }
 
 void LoaderImpl::BackgroundLoadBuildConfig(
@@ -287,8 +289,8 @@
     const Scope::KeyValueMap& toolchain_overrides,
     const ParseNode* root) {
   if (!root) {
-    main_loop_->PostTask(FROM_HERE,
-        base::Bind(&LoaderImpl::DecrementPendingLoads, this));
+    main_loop_->task_runner()->PostTask(
+        FROM_HERE, base::Bind(&LoaderImpl::DecrementPendingLoads, this));
     return;
   }
 
@@ -337,9 +339,9 @@
     }
   }
 
-  main_loop_->PostTask(FROM_HERE,
-      base::Bind(&LoaderImpl::DidLoadBuildConfig, this,
-                 settings->toolchain_label()));
+  main_loop_->task_runner()->PostTask(
+      FROM_HERE, base::Bind(&LoaderImpl::DidLoadBuildConfig, this,
+                            settings->toolchain_label()));
 }
 
 void LoaderImpl::DidLoadFile() {
diff --git a/tools/gn/loader_unittest.cc b/tools/gn/loader_unittest.cc
index 47d0f80..e8d809d 100644
--- a/tools/gn/loader_unittest.cc
+++ b/tools/gn/loader_unittest.cc
@@ -8,6 +8,7 @@
 
 #include "base/bind.h"
 #include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "tools/gn/build_settings.h"
 #include "tools/gn/err.h"
@@ -146,12 +147,12 @@
 
   // Completing the build config load should kick off the root build file load.
   mock_ifm_.IssueAllPending();
-  scheduler_.main_loop()->RunUntilIdle();
+  base::RunLoop().RunUntilIdle();
   EXPECT_TRUE(mock_ifm_.HasOnePending(root_build));
 
   // Load the root build file.
   mock_ifm_.IssueAllPending();
-  scheduler_.main_loop()->RunUntilIdle();
+  base::RunLoop().RunUntilIdle();
 
   // Schedule some other file to load in another toolchain.
   Label second_tc(SourceDir("//tc2/"), "tc2");
@@ -162,7 +163,7 @@
   // Running the toolchain file should schedule the build config file to load
   // for that toolchain.
   mock_ifm_.IssueAllPending();
-  scheduler_.main_loop()->RunUntilIdle();
+  base::RunLoop().RunUntilIdle();
 
   // We have to tell it we have a toolchain definition now (normally the
   // builder would do this).
@@ -179,7 +180,7 @@
 
   // Running the build config file should make our third file pending.
   mock_ifm_.IssueAllPending();
-  scheduler_.main_loop()->RunUntilIdle();
+  base::RunLoop().RunUntilIdle();
   EXPECT_TRUE(mock_ifm_.HasTwoPending(second_file, third_file));
 
   EXPECT_FALSE(scheduler_.is_failed());
diff --git a/tools/gn/scheduler.cc b/tools/gn/scheduler.cc
index b2e2a00..b5f3dd0 100644
--- a/tools/gn/scheduler.cc
+++ b/tools/gn/scheduler.cc
@@ -8,6 +8,7 @@
 
 #include "base/bind.h"
 #include "base/command_line.h"
+#include "base/single_thread_task_runner.h"
 #include "base/strings/string_number_conversions.h"
 #include "build/build_config.h"
 #include "tools/gn/standard_out.h"
@@ -101,9 +102,9 @@
   } else {
     // The run loop always joins on the sub threads, so the lifetime of this
     // object outlives the invocations of this function, hence "unretained".
-    main_loop_.PostTask(FROM_HERE,
-                        base::Bind(&Scheduler::LogOnMainThread,
-                                   base::Unretained(this), verb, msg));
+    main_loop_.task_runner()->PostTask(
+        FROM_HERE, base::Bind(&Scheduler::LogOnMainThread,
+                              base::Unretained(this), verb, msg));
   }
 }
 
@@ -122,9 +123,9 @@
   } else {
     // The run loop always joins on the sub threads, so the lifetime of this
     // object outlives the invocations of this function, hence "unretained".
-    main_loop_.PostTask(FROM_HERE,
-                        base::Bind(&Scheduler::FailWithErrorOnMainThread,
-                                   base::Unretained(this), err));
+    main_loop_.task_runner()->PostTask(
+        FROM_HERE, base::Bind(&Scheduler::FailWithErrorOnMainThread,
+                              base::Unretained(this), err));
   }
 }
 
@@ -210,9 +211,9 @@
     if (base::MessageLoop::current() == &main_loop_) {
       OnComplete();
     } else {
-      main_loop_.PostTask(FROM_HERE,
-                          base::Bind(&Scheduler::OnComplete,
-                                     base::Unretained(this)));
+      main_loop_.task_runner()->PostTask(
+          FROM_HERE,
+          base::Bind(&Scheduler::OnComplete, base::Unretained(this)));
     }
   }
 }
diff --git a/tools/gn/setup.cc b/tools/gn/setup.cc
index ea7cb24..5796ada 100644
--- a/tools/gn/setup.cc
+++ b/tools/gn/setup.cc
@@ -14,6 +14,7 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/process/launch.h"
+#include "base/single_thread_task_runner.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "base/strings/sys_string_conversions.h"
@@ -142,8 +143,9 @@
                          scoped_refptr<Builder> builder,
                          std::unique_ptr<Item> item) {
   DCHECK(item);
-  main_loop->PostTask(FROM_HERE, base::Bind(&Builder::ItemDefined, builder,
-                                            base::Passed(&item)));
+  main_loop->task_runner()->PostTask(
+      FROM_HERE,
+      base::Bind(&Builder::ItemDefined, builder, base::Passed(&item)));
 }
 
 void DecrementWorkCount() {