Commit 01c8157e authored by fdoray's avatar fdoray Committed by Commit bot

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-Commit-Position: refs/heads/master@{#401371}
parent a9d6c7d3
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "tools/gn/build_settings.h" #include "tools/gn/build_settings.h"
#include "tools/gn/err.h" #include "tools/gn/err.h"
#include "tools/gn/filesystem_utils.h" #include "tools/gn/filesystem_utils.h"
...@@ -238,8 +239,8 @@ void LoaderImpl::BackgroundLoadFile(const Settings* settings, ...@@ -238,8 +239,8 @@ void LoaderImpl::BackgroundLoadFile(const Settings* settings,
const LocationRange& origin, const LocationRange& origin,
const ParseNode* root) { const ParseNode* root) {
if (!root) { if (!root) {
main_loop_->PostTask(FROM_HERE, main_loop_->task_runner()->PostTask(
base::Bind(&LoaderImpl::DecrementPendingLoads, this)); FROM_HERE, base::Bind(&LoaderImpl::DecrementPendingLoads, this));
return; return;
} }
...@@ -279,7 +280,8 @@ void LoaderImpl::BackgroundLoadFile(const Settings* settings, ...@@ -279,7 +280,8 @@ void LoaderImpl::BackgroundLoadFile(const Settings* settings,
trace.Done(); 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( void LoaderImpl::BackgroundLoadBuildConfig(
...@@ -287,8 +289,8 @@ void LoaderImpl::BackgroundLoadBuildConfig( ...@@ -287,8 +289,8 @@ void LoaderImpl::BackgroundLoadBuildConfig(
const Scope::KeyValueMap& toolchain_overrides, const Scope::KeyValueMap& toolchain_overrides,
const ParseNode* root) { const ParseNode* root) {
if (!root) { if (!root) {
main_loop_->PostTask(FROM_HERE, main_loop_->task_runner()->PostTask(
base::Bind(&LoaderImpl::DecrementPendingLoads, this)); FROM_HERE, base::Bind(&LoaderImpl::DecrementPendingLoads, this));
return; return;
} }
...@@ -337,9 +339,9 @@ void LoaderImpl::BackgroundLoadBuildConfig( ...@@ -337,9 +339,9 @@ void LoaderImpl::BackgroundLoadBuildConfig(
} }
} }
main_loop_->PostTask(FROM_HERE, main_loop_->task_runner()->PostTask(
base::Bind(&LoaderImpl::DidLoadBuildConfig, this, FROM_HERE, base::Bind(&LoaderImpl::DidLoadBuildConfig, this,
settings->toolchain_label())); settings->toolchain_label()));
} }
void LoaderImpl::DidLoadFile() { void LoaderImpl::DidLoadFile() {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/build_settings.h" #include "tools/gn/build_settings.h"
#include "tools/gn/err.h" #include "tools/gn/err.h"
...@@ -146,12 +147,12 @@ TEST_F(LoaderTest, Foo) { ...@@ -146,12 +147,12 @@ TEST_F(LoaderTest, Foo) {
// Completing the build config load should kick off the root build file load. // Completing the build config load should kick off the root build file load.
mock_ifm_.IssueAllPending(); mock_ifm_.IssueAllPending();
scheduler_.main_loop()->RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_TRUE(mock_ifm_.HasOnePending(root_build)); EXPECT_TRUE(mock_ifm_.HasOnePending(root_build));
// Load the root build file. // Load the root build file.
mock_ifm_.IssueAllPending(); mock_ifm_.IssueAllPending();
scheduler_.main_loop()->RunUntilIdle(); base::RunLoop().RunUntilIdle();
// Schedule some other file to load in another toolchain. // Schedule some other file to load in another toolchain.
Label second_tc(SourceDir("//tc2/"), "tc2"); Label second_tc(SourceDir("//tc2/"), "tc2");
...@@ -162,7 +163,7 @@ TEST_F(LoaderTest, Foo) { ...@@ -162,7 +163,7 @@ TEST_F(LoaderTest, Foo) {
// Running the toolchain file should schedule the build config file to load // Running the toolchain file should schedule the build config file to load
// for that toolchain. // for that toolchain.
mock_ifm_.IssueAllPending(); mock_ifm_.IssueAllPending();
scheduler_.main_loop()->RunUntilIdle(); base::RunLoop().RunUntilIdle();
// We have to tell it we have a toolchain definition now (normally the // We have to tell it we have a toolchain definition now (normally the
// builder would do this). // builder would do this).
...@@ -179,7 +180,7 @@ TEST_F(LoaderTest, Foo) { ...@@ -179,7 +180,7 @@ TEST_F(LoaderTest, Foo) {
// Running the build config file should make our third file pending. // Running the build config file should make our third file pending.
mock_ifm_.IssueAllPending(); mock_ifm_.IssueAllPending();
scheduler_.main_loop()->RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_TRUE(mock_ifm_.HasTwoPending(second_file, third_file)); EXPECT_TRUE(mock_ifm_.HasTwoPending(second_file, third_file));
EXPECT_FALSE(scheduler_.is_failed()); EXPECT_FALSE(scheduler_.is_failed());
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "tools/gn/standard_out.h" #include "tools/gn/standard_out.h"
...@@ -101,9 +102,9 @@ void Scheduler::Log(const std::string& verb, const std::string& msg) { ...@@ -101,9 +102,9 @@ void Scheduler::Log(const std::string& verb, const std::string& msg) {
} else { } else {
// The run loop always joins on the sub threads, so the lifetime of this // The run loop always joins on the sub threads, so the lifetime of this
// object outlives the invocations of this function, hence "unretained". // object outlives the invocations of this function, hence "unretained".
main_loop_.PostTask(FROM_HERE, main_loop_.task_runner()->PostTask(
base::Bind(&Scheduler::LogOnMainThread, FROM_HERE, base::Bind(&Scheduler::LogOnMainThread,
base::Unretained(this), verb, msg)); base::Unretained(this), verb, msg));
} }
} }
...@@ -122,9 +123,9 @@ void Scheduler::FailWithError(const Err& err) { ...@@ -122,9 +123,9 @@ void Scheduler::FailWithError(const Err& err) {
} else { } else {
// The run loop always joins on the sub threads, so the lifetime of this // The run loop always joins on the sub threads, so the lifetime of this
// object outlives the invocations of this function, hence "unretained". // object outlives the invocations of this function, hence "unretained".
main_loop_.PostTask(FROM_HERE, main_loop_.task_runner()->PostTask(
base::Bind(&Scheduler::FailWithErrorOnMainThread, FROM_HERE, base::Bind(&Scheduler::FailWithErrorOnMainThread,
base::Unretained(this), err)); base::Unretained(this), err));
} }
} }
...@@ -210,9 +211,9 @@ void Scheduler::DecrementWorkCount() { ...@@ -210,9 +211,9 @@ void Scheduler::DecrementWorkCount() {
if (base::MessageLoop::current() == &main_loop_) { if (base::MessageLoop::current() == &main_loop_) {
OnComplete(); OnComplete();
} else { } else {
main_loop_.PostTask(FROM_HERE, main_loop_.task_runner()->PostTask(
base::Bind(&Scheduler::OnComplete, FROM_HERE,
base::Unretained(this))); base::Bind(&Scheduler::OnComplete, base::Unretained(this)));
} }
} }
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/process/launch.h" #include "base/process/launch.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
...@@ -142,8 +143,9 @@ void ItemDefinedCallback(base::MessageLoop* main_loop, ...@@ -142,8 +143,9 @@ void ItemDefinedCallback(base::MessageLoop* main_loop,
scoped_refptr<Builder> builder, scoped_refptr<Builder> builder,
std::unique_ptr<Item> item) { std::unique_ptr<Item> item) {
DCHECK(item); DCHECK(item);
main_loop->PostTask(FROM_HERE, base::Bind(&Builder::ItemDefined, builder, main_loop->task_runner()->PostTask(
base::Passed(&item))); FROM_HERE,
base::Bind(&Builder::ItemDefined, builder, base::Passed(&item)));
} }
void DecrementWorkCount() { void DecrementWorkCount() {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/posix/global_descriptors.h" #include "base/posix/global_descriptors.h"
#include "base/run_loop.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
...@@ -157,7 +158,7 @@ void ReplayProcess::Run() { ...@@ -157,7 +158,7 @@ void ReplayProcess::Run() {
base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMilliseconds(1),
base::Bind(&ReplayProcess::SendNextMessage, base::Bind(&ReplayProcess::SendNextMessage,
base::Unretained(this))); base::Unretained(this)));
base::MessageLoop::current()->Run(); base::RunLoop().Run();
} }
bool ReplayProcess::OnMessageReceived(const IPC::Message& msg) { bool ReplayProcess::OnMessageReceived(const IPC::Message& msg) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment