Skip to content

Commit

Permalink
Remove remaining calls to deprecated MessageLoop methods.
Browse files Browse the repository at this point in the history
This CL makes the following replacements everywhere:

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 |x| isn't MessageLoopForUI::current() or
    MessageLoopForIO::current()
----------------------------------------------------------

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

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.

TBR=garykac@chromium.org
BUG=616447

Review-Url: https://codereview.chromium.org/2104363004
Cr-Commit-Position: refs/heads/master@{#403716}
  • Loading branch information
fdoray authored and Commit bot committed Jul 4, 2016
1 parent 89d8be5 commit 6d056ff
Show file tree
Hide file tree
Showing 28 changed files with 91 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSampledFile) {
&item,
base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
base::Unretained(this)));
MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
EXPECT_FALSE(HasClientDownloadRequest());

Expand All @@ -881,7 +881,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSampledFile) {
&item,
base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
base::Unretained(this)));
MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
EXPECT_TRUE(HasClientDownloadRequest());
// Verify it's a "light" ping, check that URLs don't have paths, and
Expand All @@ -908,7 +908,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSampledFile) {
&item,
base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
base::Unretained(this)));
MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
EXPECT_FALSE(HasClientDownloadRequest());

Expand All @@ -920,7 +920,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSampledFile) {
&item,
base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
base::Unretained(this)));
MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
EXPECT_FALSE(HasClientDownloadRequest());
}
Expand Down
7 changes: 4 additions & 3 deletions chrome/test/chromedriver/server/chromedriver_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
Expand Down Expand Up @@ -207,7 +208,7 @@ void RunServer(uint16_t port,
HttpRequestHandlerFunc handle_request_func =
base::Bind(&HandleRequestOnCmdThread, &handler, whitelisted_ips);

io_thread.message_loop()->PostTask(
io_thread.message_loop()->task_runner()->PostTask(
FROM_HERE,
base::Bind(&StartServerOnIOThread, port, allow_remote,
base::Bind(&HandleRequestOnIOThread, cmd_loop.task_runner(),
Expand All @@ -218,8 +219,8 @@ void RunServer(uint16_t port,
// destroyed, which waits until all pending tasks have been completed.
// This assumes the response is sent synchronously as part of the IO task.
cmd_run_loop.Run();
io_thread.message_loop()
->PostTask(FROM_HERE, base::Bind(&StopServerOnIOThread));
io_thread.message_loop()->task_runner()->PostTask(
FROM_HERE, base::Bind(&StopServerOnIOThread));
}

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4952,7 +4952,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MultipleDedupes) {
personal_data_->AddProfile(Barney);
EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
.WillOnce(QuitMainMessageLoop());
base::MessageLoop::current()->Run();
base::RunLoop().Run();

// Make sure the 7 profiles were saved;
EXPECT_EQ(7U, personal_data_->GetProfiles().size());
Expand All @@ -4969,7 +4969,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_MultipleDedupes) {
personal_data_->ApplyDedupingRoutine();
EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
.WillOnce(QuitMainMessageLoop());
base::MessageLoop::current()->Run();
base::RunLoop().Run();

// Get the profiles, sorted by frecency to have a deterministic order.
std::vector<AutofillProfile*> profiles =
Expand Down Expand Up @@ -5042,7 +5042,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_FeatureDisabled) {

EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
.WillOnce(QuitMainMessageLoop());
base::MessageLoop::current()->Run();
base::RunLoop().Run();

// Make sure both profiles were saved.
EXPECT_EQ(2U, personal_data_->GetProfiles().size());
Expand Down Expand Up @@ -5073,7 +5073,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_OncePerVersion) {
personal_data_->AddProfile(profile2);
EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
.WillOnce(QuitMainMessageLoop());
base::MessageLoop::current()->Run();
base::RunLoop().Run();

EXPECT_EQ(2U, personal_data_->GetProfiles().size());

Expand All @@ -5085,7 +5085,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_OncePerVersion) {
EXPECT_TRUE(personal_data_->ApplyDedupingRoutine());
EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
.WillOnce(QuitMainMessageLoop());
base::MessageLoop::current()->Run();
base::RunLoop().Run();

std::vector<AutofillProfile*> profiles = personal_data_->GetProfiles();

Expand All @@ -5106,7 +5106,7 @@ TEST_F(PersonalDataManagerTest, ApplyDedupingRoutine_OncePerVersion) {
personal_data_->AddProfile(profile3);
EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
.WillOnce(QuitMainMessageLoop());
base::MessageLoop::current()->Run();
base::RunLoop().Run();

// Make sure |profile3| was saved.
EXPECT_EQ(2U, personal_data_->GetProfiles().size());
Expand Down
3 changes: 2 additions & 1 deletion components/precache/core/precache_fetcher_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/test/histogram_tester.h"
#include "base/threading/thread_task_runner_handle.h"
Expand Down Expand Up @@ -361,7 +362,7 @@ class PrecacheFetcherTest : public testing::Test {
}

// Check again after allowing the message loop to process some messages.
loop_.PostTask(
loop_.task_runner()->PostTask(
FROM_HERE,
base::Bind(
&PrecacheFetcherTest::CheckUntilParallelFetchesBeyondCapacity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/browser/fileapi/mock_url_request_delegate.h"
Expand Down Expand Up @@ -307,7 +308,7 @@ class ServiceWorkerURLRequestJobTest
// Simulate another worker kicking out the incumbent worker. PostTask since
// it might respond synchronously, and the MockURLRequestDelegate would
// complain that the message loop isn't being run.
base::MessageLoop::current()->PostTask(
base::MessageLoop::current()->task_runner()->PostTask(
FROM_HERE, base::Bind(&ServiceWorkerVersion::SetStatus, version_,
ServiceWorkerVersion::REDUNDANT));
base::RunLoop().RunUntilIdle();
Expand Down
3 changes: 2 additions & 1 deletion content/renderer/media/media_stream_audio_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
Expand Down Expand Up @@ -761,7 +762,7 @@ int MediaStreamAudioProcessor::ProcessData(const float* const* process_ptrs,
base::subtle::Release_Store(&typing_detected_, detected);
}

main_thread_message_loop_->PostTask(
main_thread_message_loop_->task_runner()->PostTask(
FROM_HERE, base::Bind(&MediaStreamAudioProcessor::UpdateAecStats, this));

// Return 0 if the volume hasn't been changed, and otherwise the new volume.
Expand Down
3 changes: 2 additions & 1 deletion ipc/ipc_sync_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/synchronization/waitable_event_watcher.h"
#include "base/threading/thread_local.h"
Expand Down Expand Up @@ -566,7 +567,7 @@ void SyncChannel::WaitForReplyWithNestedMessageLoop(SyncContext* context) {
{
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
base::MessageLoop::current()->Run();
base::RunLoop().Run();
}

sync_msg_queue->set_top_send_done_watcher(old_send_done_event_watcher);
Expand Down
9 changes: 5 additions & 4 deletions media/test/pipeline_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
Expand Down Expand Up @@ -789,7 +790,7 @@ class PipelineIntegrationTest : public PipelineIntegrationTestHost {
base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData,
base::Unretained(encrypted_media)));
}
message_loop_.Run();
base::RunLoop().Run();
return pipeline_status_;
}

Expand Down Expand Up @@ -1327,7 +1328,7 @@ TEST_F(PipelineIntegrationTest, MediaSource_Remove_Updates_BufferedRanges) {

source.RemoveRange(base::TimeDelta::FromMilliseconds(1000),
base::TimeDelta::FromMilliseconds(k320WebMFileDurationMs));
message_loop_.RunUntilIdle();
base::RunLoop().RunUntilIdle();

buffered_ranges = pipeline_->GetBufferedTimeRanges();
EXPECT_EQ(1u, buffered_ranges.size());
Expand Down Expand Up @@ -1363,7 +1364,7 @@ TEST_F(PipelineIntegrationTest, MediaSource_FillUp_Buffer) {
source.EvictCodedFrames(media_time, file->data_size());
ASSERT_TRUE(
source.AppendAtTime(media_time, file->data(), file->data_size()));
message_loop_.RunUntilIdle();
base::RunLoop().RunUntilIdle();

buffered_ranges = pipeline_->GetBufferedTimeRanges();
} while (buffered_ranges.size() == 1 &&
Expand Down Expand Up @@ -1420,7 +1421,7 @@ TEST_F(PipelineIntegrationTest,

source.EndOfStream();

message_loop_.Run();
base::RunLoop().Run();
EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, pipeline_status_);

EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/callback.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_task_runner_handle.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
Expand Down Expand Up @@ -91,9 +92,9 @@ class IntegerSenderConnectionImpl : public IntegerSenderConnection {
class AssociatedInterfaceTest : public testing::Test {
public:
AssociatedInterfaceTest() {}
~AssociatedInterfaceTest() override { loop_.RunUntilIdle(); }
~AssociatedInterfaceTest() override { base::RunLoop().RunUntilIdle(); }

void PumpMessages() { loop_.RunUntilIdle(); }
void PumpMessages() { base::RunLoop().RunUntilIdle(); }

template <typename T>
AssociatedInterfacePtrInfo<T> EmulatePassingAssociatedPtrInfo(
Expand Down Expand Up @@ -121,7 +122,7 @@ class AssociatedInterfaceTest : public testing::Test {
if (loop_.task_runner()->BelongsToCurrentThread()) {
run_loop->Quit();
} else {
loop_.PostTask(
loop_.task_runner()->PostTask(
FROM_HERE,
base::Bind(&AssociatedInterfaceTest::QuitRunLoop,
base::Unretained(this), base::Unretained(run_loop)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class BindingCallbackTest : public testing::Test {
int32_t last_client_callback_value_seen_;
sample::ProviderPtr interface_ptr_;

void PumpMessages() { loop_.RunUntilIdle(); }
void PumpMessages() { base::RunLoop().RunUntilIdle(); }

private:
base::MessageLoop loop_;
Expand Down
16 changes: 8 additions & 8 deletions mojo/public/cpp/bindings/tests/binding_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ TEST_F(BindingTest, DestroyClosesMessagePipe) {
ptr->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr,
SetFlagAndRunClosure<int32_t>(&called,
run_loop2.QuitClosure()));
loop().RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(called);
}

Expand Down Expand Up @@ -157,13 +157,13 @@ TEST_F(BindingTest, CloseDoesntCallConnectionErrorHandler) {
bool called = false;
binding.set_connection_error_handler(SetFlagAndRunClosure(&called));
binding.Close();
loop().RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(called);

// We can also close the other end, and the error handler still won't be
// called.
ptr.reset();
loop().RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(called);
}

Expand Down Expand Up @@ -228,7 +228,7 @@ TEST_F(BindingTest, Unbind) {
ptr->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr,
SetFlagAndRunClosure<int32_t>(&called,
run_loop.QuitClosure()));
loop().RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(called);

called = false;
Expand Down Expand Up @@ -277,7 +277,7 @@ TEST_F(BindingTest, PauseResume) {
SetFlagAndRunClosure<int32_t>(&called,
run_loop.QuitClosure()));
EXPECT_FALSE(called);
loop().RunUntilIdle();
base::RunLoop().RunUntilIdle();
// Frobinate() should not be called as the binding is paused.
EXPECT_FALSE(called);

Expand All @@ -300,7 +300,7 @@ TEST_F(BindingTest, ErrorHandleNotRunWhilePaused) {
binding.PauseIncomingMethodCallProcessing();

ptr.reset();
loop().RunUntilIdle();
base::RunLoop().RunUntilIdle();
// The connection error handle should not be called as the binding is paused.
EXPECT_FALSE(called);

Expand Down Expand Up @@ -368,7 +368,7 @@ TEST_F(StrongBindingTest, ConnectionErrorDestroysImpl) {
new ServiceImplWithBinding(&was_deleted, run_loop.QuitClosure(),
GetProxy(&ptr));

loop().RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(was_deleted);

ptr.reset();
Expand All @@ -395,7 +395,7 @@ TEST_F(StrongBindingTest, ExplicitDeleteImpl) {
impl->binding().set_connection_error_handler(
SetFlagAndRunClosure(&binding_error_handler_called));

loop().RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(ptr_error_handler_called);
EXPECT_FALSE(was_deleted);

Expand Down
2 changes: 1 addition & 1 deletion mojo/public/cpp/bindings/tests/handle_passing_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class HandlePassingTest : public testing::Test {

void TearDown() override { PumpMessages(); }

void PumpMessages() { loop_.RunUntilIdle(); }
void PumpMessages() { base::RunLoop().RunUntilIdle(); }

private:
base::MessageLoop loop_;
Expand Down
4 changes: 2 additions & 2 deletions mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ class IntegerAccessorImpl : public sample::IntegerAccessor {
class InterfacePtrTest : public testing::Test {
public:
InterfacePtrTest() {}
~InterfacePtrTest() override { loop_.RunUntilIdle(); }
~InterfacePtrTest() override { base::RunLoop().RunUntilIdle(); }

void PumpMessages() { loop_.RunUntilIdle(); }
void PumpMessages() { base::RunLoop().RunUntilIdle(); }

private:
base::MessageLoop loop_;
Expand Down
4 changes: 2 additions & 2 deletions mojo/public/cpp/bindings/tests/request_response_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ void RecordEnum(sample::Enum* storage,
class RequestResponseTest : public testing::Test {
public:
RequestResponseTest() {}
~RequestResponseTest() override { loop_.RunUntilIdle(); }
~RequestResponseTest() override { base::RunLoop().RunUntilIdle(); }

void PumpMessages() { loop_.RunUntilIdle(); }
void PumpMessages() { base::RunLoop().RunUntilIdle(); }

private:
base::MessageLoop loop_;
Expand Down
2 changes: 1 addition & 1 deletion mojo/public/cpp/bindings/tests/sync_method_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class TestSyncServiceThread {
class SyncMethodTest : public testing::Test {
public:
SyncMethodTest() {}
~SyncMethodTest() override { loop_.RunUntilIdle(); }
~SyncMethodTest() override { base::RunLoop().RunUntilIdle(); }

protected:
base::MessageLoop loop_;
Expand Down
4 changes: 2 additions & 2 deletions mojo/public/cpp/bindings/tests/union_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ void ExpectInt16(int16_t value, PodUnionPtr out) {
}

TEST(UnionTest, UnionInInterface) {
base::MessageLoop run_loop;
base::MessageLoop message_loop;
UnionInterfaceImpl impl;
UnionInterfacePtr ptr;
Binding<UnionInterface> bindings(&impl, GetProxy(&ptr));
Expand All @@ -1219,7 +1219,7 @@ TEST(UnionTest, UnionInInterface) {
pod->set_f_int16(16);

ptr->Echo(std::move(pod), base::Bind(&ExpectInt16, 16));
run_loop.RunUntilIdle();
base::RunLoop().RunUntilIdle();
}

} // namespace test
Expand Down
Loading

0 comments on commit 6d056ff

Please sign in to comment.