Skip to content

Commit

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

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=caitkp@chromium.org

Review-Url: https://codereview.chromium.org/2082333002
Cr-Commit-Position: refs/heads/master@{#401396}
  • Loading branch information
fdoray authored and Commit bot committed Jun 22, 2016
1 parent d546a9d commit c85099d
Show file tree
Hide file tree
Showing 44 changed files with 267 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <memory>
#include <utility>

#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -363,7 +364,7 @@ TEST_F(AutofillDownloadManagerTest, BackoffLogic_Query) {
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
base::TimeDelta::FromMilliseconds(1100));
base::MessageLoop::current()->Run();
base::RunLoop().Run();

// Get the retried request.
fetcher = factory.GetFetcherByID(1);
Expand Down Expand Up @@ -419,7 +420,7 @@ TEST_F(AutofillDownloadManagerTest, BackoffLogic_Upload) {
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
base::TimeDelta::FromMilliseconds(1100));
base::MessageLoop::current()->Run();
base::RunLoop().Run();

// Check that it was a failure.
EXPECT_EQ(AutofillDownloadManagerTest::REQUEST_UPLOAD_FAILED,
Expand Down
185 changes: 93 additions & 92 deletions components/autofill/core/browser/personal_data_manager_unittest.cc

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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/stl_util.h"
#include "base/strings/string16.h"
Expand Down Expand Up @@ -122,7 +123,7 @@ class WebDataServiceTest : public testing::Test {

base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
base::MessageLoop::current()->Run();
base::RunLoop().Run();
db_thread_.Stop();
}

Expand Down Expand Up @@ -226,7 +227,7 @@ TEST_F(WebDataServiceAutofillTest, FormFillAdd) {
name1_, base::string16(), limit, &consumer);

// The message loop will exit when the consumer is called.
base::MessageLoop::current()->Run();
base::RunLoop().Run();

EXPECT_EQ(handle, consumer.handle());
ASSERT_EQ(1U, consumer.result().size());
Expand Down Expand Up @@ -303,7 +304,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileAdd) {
// Check that it was added.
AutofillWebDataServiceConsumer<std::vector<AutofillProfile*> > consumer;
WebDataServiceBase::Handle handle = wds_->GetAutofillProfiles(&consumer);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle, consumer.handle());
ASSERT_EQ(1U, consumer.result().size());
EXPECT_EQ(profile, *consumer.result()[0]);
Expand All @@ -322,7 +323,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileRemove) {
// Check that it was added.
AutofillWebDataServiceConsumer<std::vector<AutofillProfile*> > consumer;
WebDataServiceBase::Handle handle = wds_->GetAutofillProfiles(&consumer);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle, consumer.handle());
ASSERT_EQ(1U, consumer.result().size());
EXPECT_EQ(profile, *consumer.result()[0]);
Expand All @@ -341,7 +342,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileRemove) {
// Check that it was removed.
AutofillWebDataServiceConsumer<std::vector<AutofillProfile*> > consumer2;
WebDataServiceBase::Handle handle2 = wds_->GetAutofillProfiles(&consumer2);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle2, consumer2.handle());
ASSERT_EQ(0U, consumer2.result().size());
}
Expand All @@ -366,7 +367,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileUpdate) {
// Check that they were added.
AutofillWebDataServiceConsumer<std::vector<AutofillProfile*> > consumer;
WebDataServiceBase::Handle handle = wds_->GetAutofillProfiles(&consumer);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle, consumer.handle());
ASSERT_EQ(2U, consumer.result().size());
EXPECT_EQ(profile2, *consumer.result()[0]);
Expand All @@ -388,7 +389,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileUpdate) {
// Check that the updates were made.
AutofillWebDataServiceConsumer<std::vector<AutofillProfile*> > consumer2;
WebDataServiceBase::Handle handle2 = wds_->GetAutofillProfiles(&consumer2);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle2, consumer2.handle());
ASSERT_EQ(2U, consumer2.result().size());
EXPECT_EQ(profile2_changed, *consumer2.result()[0]);
Expand All @@ -405,7 +406,7 @@ TEST_F(WebDataServiceAutofillTest, CreditAdd) {
// Check that it was added.
AutofillWebDataServiceConsumer<std::vector<CreditCard*> > consumer;
WebDataServiceBase::Handle handle = wds_->GetCreditCards(&consumer);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle, consumer.handle());
ASSERT_EQ(1U, consumer.result().size());
EXPECT_EQ(card, *consumer.result()[0]);
Expand All @@ -422,7 +423,7 @@ TEST_F(WebDataServiceAutofillTest, CreditCardRemove) {
// Check that it was added.
AutofillWebDataServiceConsumer<std::vector<CreditCard*> > consumer;
WebDataServiceBase::Handle handle = wds_->GetCreditCards(&consumer);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle, consumer.handle());
ASSERT_EQ(1U, consumer.result().size());
EXPECT_EQ(credit_card, *consumer.result()[0]);
Expand All @@ -435,7 +436,7 @@ TEST_F(WebDataServiceAutofillTest, CreditCardRemove) {
// Check that it was removed.
AutofillWebDataServiceConsumer<std::vector<CreditCard*> > consumer2;
WebDataServiceBase::Handle handle2 = wds_->GetCreditCards(&consumer2);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle2, consumer2.handle());
ASSERT_EQ(0U, consumer2.result().size());
}
Expand All @@ -455,7 +456,7 @@ TEST_F(WebDataServiceAutofillTest, CreditUpdate) {
// Check that they got added.
AutofillWebDataServiceConsumer<std::vector<CreditCard*> > consumer;
WebDataServiceBase::Handle handle = wds_->GetCreditCards(&consumer);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle, consumer.handle());
ASSERT_EQ(2U, consumer.result().size());
EXPECT_EQ(card2, *consumer.result()[0]);
Expand All @@ -471,7 +472,7 @@ TEST_F(WebDataServiceAutofillTest, CreditUpdate) {
// Check that the updates were made.
AutofillWebDataServiceConsumer<std::vector<CreditCard*> > consumer2;
WebDataServiceBase::Handle handle2 = wds_->GetCreditCards(&consumer2);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle2, consumer2.handle());
ASSERT_EQ(2U, consumer2.result().size());
EXPECT_NE(card2, *consumer2.result()[0]);
Expand All @@ -493,7 +494,7 @@ TEST_F(WebDataServiceAutofillTest, AutofillRemoveModifiedBetween) {
profile_consumer;
WebDataServiceBase::Handle handle =
wds_->GetAutofillProfiles(&profile_consumer);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle, profile_consumer.handle());
ASSERT_EQ(1U, profile_consumer.result().size());
EXPECT_EQ(profile, *profile_consumer.result()[0]);
Expand All @@ -507,7 +508,7 @@ TEST_F(WebDataServiceAutofillTest, AutofillRemoveModifiedBetween) {
// Check that it was added.
AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer;
handle = wds_->GetCreditCards(&card_consumer);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle, card_consumer.handle());
ASSERT_EQ(1U, card_consumer.result().size());
EXPECT_EQ(credit_card, *card_consumer.result()[0]);
Expand All @@ -529,14 +530,14 @@ TEST_F(WebDataServiceAutofillTest, AutofillRemoveModifiedBetween) {
profile_consumer2;
WebDataServiceBase::Handle handle2 =
wds_->GetAutofillProfiles(&profile_consumer2);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle2, profile_consumer2.handle());
ASSERT_EQ(0U, profile_consumer2.result().size());

// Check that the credit card was removed.
AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer2;
handle2 = wds_->GetCreditCards(&card_consumer2);
base::MessageLoop::current()->Run();
base::RunLoop().Run();
EXPECT_EQ(handle2, card_consumer2.handle());
ASSERT_EQ(0U, card_consumer2.result().size());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/bookmarks/browser/bookmark_model.h"
Expand Down Expand Up @@ -54,7 +55,7 @@ void BookmarkExpandedStateTrackerTest::SetUp() {

void BookmarkExpandedStateTrackerTest::TearDown() {
model_.reset();
message_loop_.RunUntilIdle();
base::RunLoop().RunUntilIdle();
}

// Various assertions for SetExpandedNodes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/bookmarks/browser/bookmark_model.h"
Expand Down Expand Up @@ -45,7 +46,7 @@ class ManagedBookmarksTrackerTest : public testing::Test {
void TearDown() override {
if (model_)
model_->RemoveObserver(&observer_);
loop_.RunUntilIdle();
base::RunLoop().RunUntilIdle();
}

void CreateModel(bool is_supervised) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread.h"
Expand Down Expand Up @@ -305,7 +306,7 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest {
FROM_HERE, task,
base::Bind(&base::MessageLoop::QuitNow,
base::Unretained(base::MessageLoop::current())));
base::MessageLoop::current()->Run();
base::RunLoop().Run();
}

void SendNotificationURLVisited(ui::PageTransition transition,
Expand Down
4 changes: 2 additions & 2 deletions components/devtools_http_handler/devtools_http_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ void TerminateOnUI(base::Thread* thread,
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (server_wrapper) {
DCHECK(thread);
thread->message_loop()->DeleteSoon(FROM_HERE, server_wrapper);
thread->task_runner()->DeleteSoon(FROM_HERE, server_wrapper);
}
if (socket_factory) {
DCHECK(thread);
thread->message_loop()->DeleteSoon(FROM_HERE, socket_factory);
thread->task_runner()->DeleteSoon(FROM_HERE, socket_factory);
}
if (thread) {
BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, thread);
Expand Down
4 changes: 3 additions & 1 deletion components/history/core/browser/history_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
Expand Down Expand Up @@ -227,7 +228,8 @@ HistoryBackend::~HistoryBackend() {
if (!backend_destroy_task_.is_null()) {
// Notify an interested party (typically a unit test) that we're done.
DCHECK(backend_destroy_message_loop_);
backend_destroy_message_loop_->PostTask(FROM_HERE, backend_destroy_task_);
backend_destroy_message_loop_->task_runner()->PostTask(
FROM_HERE, backend_destroy_task_);
}

#if defined(OS_ANDROID)
Expand Down
5 changes: 3 additions & 2 deletions components/history/core/browser/history_querying_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/cancelable_task_tracker.h"
#include "components/history/core/browser/history_database_params.h"
Expand Down Expand Up @@ -85,7 +86,7 @@ class HistoryQueryTest : public testing::Test {
base::Unretained(this)),
&tracker_);
// Will go until ...Complete calls Quit.
base::MessageLoop::current()->Run();
base::RunLoop().Run();
results->Swap(&last_query_results_);
}

Expand Down Expand Up @@ -185,7 +186,7 @@ class HistoryQueryTest : public testing::Test {
base::MessageLoop::QuitWhenIdleClosure());
history_->Cleanup();
history_.reset();
base::MessageLoop::current()->Run(); // Wait for the other thread.
base::RunLoop().Run(); // Wait for the other thread.
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/history/core/browser/history_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ void HistoryService::Cleanup() {
closing_task.Reset();
HistoryBackend* raw_ptr = history_backend_.get();
history_backend_ = nullptr;
thread_->message_loop()->ReleaseSoon(FROM_HERE, raw_ptr);
thread_->task_runner()->ReleaseSoon(FROM_HERE, raw_ptr);
}

// Delete the thread, which joins with the background thread. We defensively
Expand Down
Loading

0 comments on commit c85099d

Please sign in to comment.