Commit b3a25098 authored by xhwang@chromium.org's avatar xhwang@chromium.org

chrome: Use base::MessageLoop. (Part 3)

This CL updates chrome/browser/* other than chrome/browser/ui which is in
another CL.

BUG=236029
TBR=brettw

Review URL: https://chromiumcodereview.appspot.com/14113053

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202664 0039d316-1c4b-4281-b951-d872f2087c98
parent 3d8ab9f8
......@@ -835,7 +835,7 @@ void RecordLastRunAppBundlePath() {
// nested message loop and commands dispatched during this operation cause
// havoc.
if (SessionRestore::IsRestoring(lastProfile) &&
MessageLoop::current()->IsNested())
base::MessageLoop::current()->IsNested())
return;
NSInteger tag = [sender tag];
......
......@@ -96,8 +96,8 @@ void TestProvider::Start(const AutocompleteInput& input,
if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) {
done_ = false;
MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&TestProvider::Run,
this));
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&TestProvider::Run, this));
}
}
......@@ -194,7 +194,7 @@ class AutocompleteProviderTest : public testing::Test,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
MessageLoopForUI message_loop_;
base::MessageLoopForUI message_loop_;
content::NotificationRegistrar registrar_;
TestingProfile profile_;
};
......@@ -393,7 +393,7 @@ void AutocompleteProviderTest::RunQuery(const string16 query) {
if (!controller_->done())
// The message loop will terminate when all autocomplete input has been
// collected.
MessageLoop::current()->Run();
base::MessageLoop::current()->Run();
}
void AutocompleteProviderTest::RunExactKeymatchTest(
......@@ -422,7 +422,7 @@ void AutocompleteProviderTest::Observe(
const content::NotificationDetails& details) {
if (controller_->done()) {
result_.CopyFrom(controller_->result());
MessageLoop::current()->Quit();
base::MessageLoop::current()->Quit();
}
}
......
......@@ -123,7 +123,7 @@ class ContactProviderTest : public testing::Test {
return result;
}
MessageLoopForUI message_loop_;
base::MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
scoped_ptr<TestingProfileManager> profile_manager_;
......
......@@ -33,7 +33,7 @@ class ExtensionAppProviderTest : public testing::Test {
int num_cases);
protected:
MessageLoopForUI message_loop_;
base::MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
scoped_refptr<ExtensionAppProvider> app_provider_;
scoped_ptr<TestingProfile> profile_;
......
......@@ -56,7 +56,7 @@ class HistoryContentsProviderTest : public testing::Test,
// When we're waiting for asynchronous messages, we have to spin the message
// loop. This will be exited in the OnProviderUpdate function when complete.
if (input.matches_requested() == AutocompleteInput::ALL_MATCHES)
MessageLoop::current()->Run();
base::MessageLoop::current()->Run();
}
const ACMatches& matches() const { return provider_->matches(); }
......@@ -116,10 +116,11 @@ class HistoryContentsProviderTest : public testing::Test,
// We must quit the message loop (if running) to return control to the test.
// Note, calling Quit() directly will checkfail if the loop isn't running,
// so we post a task, which is safe for either case.
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
base::MessageLoop::current()->PostTask(FROM_HERE,
base::MessageLoop::QuitClosure());
}
MessageLoopForUI message_loop_;
base::MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
......
......@@ -135,7 +135,7 @@ class HistoryQuickProviderTest : public testing::Test,
// Pass-through functions to simplify our friendship with URLIndexPrivateData.
bool UpdateURL(const history::URLRow& row);
MessageLoopForUI message_loop_;
base::MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
......@@ -228,7 +228,7 @@ void HistoryQuickProviderTest::RunTest(const string16 text,
bool can_inline_top_result,
string16 expected_fill_into_edit) {
SCOPED_TRACE(text); // Minimal hint to query being run.
MessageLoop::current()->RunUntilIdle();
base::MessageLoop::current()->RunUntilIdle();
AutocompleteInput input(text, string16::npos, string16(), GURL(),false, false,
true, AutocompleteInput::ALL_MATCHES);
provider_->Start(input, false);
......
......@@ -295,7 +295,7 @@ HistoryURLProviderParams::HistoryURLProviderParams(
const std::string& languages,
TemplateURL* default_search_provider,
const SearchTermsData& search_terms_data)
: message_loop(MessageLoop::current()),
: message_loop(base::MessageLoop::current()),
input(input),
prevent_inline_autocomplete(input.prevent_inline_autocomplete()),
trim_http(trim_http),
......
......@@ -187,7 +187,7 @@ class HistoryURLProviderTest : public testing::Test,
void RunAdjustOffsetTest(const string16 text, size_t expected_offset);
MessageLoopForUI message_loop_;
base::MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
ACMatches matches_;
......@@ -207,7 +207,7 @@ class HistoryURLProviderTestNoDB : public HistoryURLProviderTest {
void HistoryURLProviderTest::OnProviderUpdate(bool updated_matches) {
if (autocomplete_->done())
MessageLoop::current()->Quit();
base::MessageLoop::current()->Quit();
}
void HistoryURLProviderTest::SetUpImpl(bool no_db) {
......@@ -266,7 +266,7 @@ void HistoryURLProviderTest::RunTest(
*identified_input_type = input.type();
autocomplete_->Start(input, false);
if (!autocomplete_->done())
MessageLoop::current()->Run();
base::MessageLoop::current()->Run();
matches_ = autocomplete_->matches();
if (sort_matches_) {
......@@ -292,7 +292,7 @@ void HistoryURLProviderTest::RunAdjustOffsetTest(const string16 text,
false, true, AutocompleteInput::ALL_MATCHES);
autocomplete_->Start(input, false);
if (!autocomplete_->done())
MessageLoop::current()->Run();
base::MessageLoop::current()->Run();
matches_ = autocomplete_->matches();
ASSERT_GE(matches_.size(), 1U) << "Input text: " << text;
......@@ -547,7 +547,7 @@ TEST_F(HistoryURLProviderTest, EmptyVisits) {
int pandora_relevance = matches_[0].relevance;
// Run the message loop. When |autocomplete_| finishes the loop is quit.
MessageLoop::current()->Run();
base::MessageLoop::current()->Run();
EXPECT_TRUE(autocomplete_->done());
matches_ = autocomplete_->matches();
ASSERT_GT(matches_.size(), 0u);
......@@ -575,7 +575,7 @@ TEST_F(HistoryURLProviderTest, DontAutocompleteOnTrailingWhitespace) {
AutocompleteInput::ALL_MATCHES);
autocomplete_->Start(input, false);
if (!autocomplete_->done())
MessageLoop::current()->Run();
base::MessageLoop::current()->Run();
// None of the matches should attempt to autocomplete.
matches_ = autocomplete_->matches();
......@@ -743,7 +743,7 @@ TEST_F(HistoryURLProviderTest, CrashDueToFixup) {
AutocompleteInput::ALL_MATCHES);
autocomplete_->Start(input, false);
if (!autocomplete_->done())
MessageLoop::current()->Run();
base::MessageLoop::current()->Run();
}
}
......
......@@ -145,7 +145,7 @@ class SearchProviderTest : public testing::Test,
const string16 keyword_term_;
GURL keyword_url_;
MessageLoopForUI message_loop_;
base::MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread io_thread_;
......
......@@ -155,7 +155,7 @@ class ShortcutsProviderTest : public testing::Test,
std::vector<std::string> expected_urls,
std::string expected_top_result);
MessageLoopForUI message_loop_;
base::MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
......@@ -225,7 +225,7 @@ void ShortcutsProviderTest::RunTest(const string16 text,
std::string expected_top_result) {
std::sort(expected_urls.begin(), expected_urls.end());
MessageLoop::current()->RunUntilIdle();
base::MessageLoop::current()->RunUntilIdle();
AutocompleteInput input(text, string16::npos, string16(), GURL(), false,
false, true, AutocompleteInput::ALL_MATCHES);
provider_->Start(input, false);
......
......@@ -153,7 +153,7 @@ class WindowedPersonalDataManagerObserver
// PersonalDataManagerObserver:
virtual void OnPersonalDataChanged() OVERRIDE {
if (has_run_message_loop_) {
MessageLoopForUI::current()->Quit();
base::MessageLoopForUI::current()->Quit();
has_run_message_loop_ = false;
}
alerted_ = true;
......
......@@ -130,7 +130,7 @@ class WindowedPersonalDataManagerObserver
// PersonalDataManagerObserver:
virtual void OnPersonalDataChanged() OVERRIDE {
if (has_run_message_loop_) {
MessageLoopForUI::current()->Quit();
base::MessageLoopForUI::current()->Quit();
has_run_message_loop_ = false;
}
alerted_ = true;
......
......@@ -40,7 +40,7 @@ class AutofillRiskFingerprintTest : public InProcessBrowserTest {
kScreenBounds(0, 0, 101, 71),
kAvailableScreenBounds(0, 11, 101, 60),
kUnavailableScreenBounds(0, 0, 101, 11),
message_loop_(MessageLoop::TYPE_UI) {}
message_loop_(base::MessageLoop::TYPE_UI) {}
void GetFingerprintTestCallback(scoped_ptr<Fingerprint> fingerprint) {
// Verify that all fields Chrome can fill have been filled.
......@@ -138,7 +138,7 @@ class AutofillRiskFingerprintTest : public InProcessBrowserTest {
const gfx::Rect kScreenBounds;
const gfx::Rect kAvailableScreenBounds;
const gfx::Rect kUnavailableScreenBounds;
MessageLoop message_loop_;
base::MessageLoop message_loop_;
};
// This test is flaky on Windows. See http://crbug.com/178356.
......
......@@ -25,7 +25,7 @@ class MockChromeFrameAutomationProvider
typedef testing::Test AutomationProviderTest;
TEST_F(AutomationProviderTest, TestInvalidChromeFrameMessage) {
MessageLoop message_loop;
base::MessageLoop message_loop;
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
IPC::Message bad_msg(1, -1, IPC::Message::PRIORITY_NORMAL);
......
......@@ -295,7 +295,7 @@ void TestingAutomationProvider::OnBrowserRemoved(Browser* browser) {
switches::kKeepAliveForTest)) {
// If you change this, update Observer for chrome::SESSION_END
// below.
MessageLoop::current()->PostTask(
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&TestingAutomationProvider::OnRemoveProvider, this));
}
......
......@@ -173,7 +173,7 @@ void URLRequestAutomationJob::Start() {
if (!is_pending()) {
// Start reading asynchronously so that all error reporting and data
// callbacks happen as they would for network requests.
MessageLoop::current()->PostTask(
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&URLRequestAutomationJob::StartAsync,
weak_factory_.GetWeakPtr()));
......@@ -212,7 +212,7 @@ bool URLRequestAutomationJob::ReadRawData(
message_filter_->Send(new AutomationMsg_RequestRead(tab_, id_, buf_size));
SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
} else {
MessageLoop::current()->PostTask(
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&URLRequestAutomationJob::NotifyJobCompletionTask,
weak_factory_.GetWeakPtr()));
......
......@@ -60,9 +60,9 @@ void CloseBalloon(const std::string id) {
}
void ScheduleCloseBalloon(const std::string& extension_id) {
if (!MessageLoop::current()) // For unit_tests
if (!base::MessageLoop::current()) // For unit_tests
return;
MessageLoop::current()->PostTask(
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&CloseBalloon, kNotificationPrefix + extension_id));
}
......@@ -374,7 +374,7 @@ void BackgroundContentsService::Observe(
// notifications for this extension to be cancelled by
// DesktopNotificationService. For this reason, instead of showing the
// balloon right now, we schedule it to show a little later.
MessageLoop::current()->PostTask(
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ShowBalloon, extension, profile));
break;
}
......
......@@ -530,8 +530,8 @@ void BackgroundModeManager::EndKeepAliveForStartup() {
// We call this via the message queue to make sure we don't try to end
// keep-alive (which can shutdown Chrome) before the message loop has
// started.
MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(&chrome::EndKeepAlive));
base::MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(&chrome::EndKeepAlive));
}
}
......
......@@ -26,7 +26,7 @@ class BookmarkExpandedStateTrackerTest : public testing::Test {
private:
scoped_ptr<TestingProfile> profile_;
MessageLoopForUI message_loop_;
base::MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
......
......@@ -417,7 +417,7 @@ void BookmarkFaviconFetcher::Observe(
const content::NotificationSource& source,
const content::NotificationDetails& details) {
if (chrome::NOTIFICATION_PROFILE_DESTROYED == type && fetcher != NULL) {
MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher);
base::MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher);
fetcher = NULL;
}
}
......@@ -445,7 +445,7 @@ void BookmarkFaviconFetcher::ExecuteWriter() {
profile_)),
path_, favicons_map_.release(), observer_)));
if (fetcher != NULL) {
MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher);
base::MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher);
fetcher = NULL;
}
}
......
......@@ -128,7 +128,7 @@ class BookmarkHTMLWriterTest : public testing::Test {
// Class that will notify message loop when file is written.
class BookmarksObserver : public BookmarksExportObserver {
public:
explicit BookmarksObserver(MessageLoop* loop) : loop_(loop) {
explicit BookmarksObserver(base::MessageLoop* loop) : loop_(loop) {
DCHECK(loop);
}
......@@ -137,14 +137,14 @@ class BookmarksObserver : public BookmarksExportObserver {
}
private:
MessageLoop* loop_;
base::MessageLoop* loop_;
DISALLOW_COPY_AND_ASSIGN(BookmarksObserver);
};
// Tests bookmark_html_writer by populating a BookmarkModel, writing it out by
// way of bookmark_html_writer, then using the importer to read it back in.
TEST_F(BookmarkHTMLWriterTest, Test) {