Skip to content

Commit

Permalink
Remove MessageLoop::current()->RunUntilIdle() in chrome.
Browse files Browse the repository at this point in the history
This CL replaces MessageLoop::current()->RunUntilIdle() with
RunLoop().RunUntilIdle() in chrome.

In files where this replacement is made, it adds this include:
  #include "base/run_loop.h"
And removes this include if it is no longer required:
  #include "base/message_loop/message_loop.h"

Why?
- The fact that there's a MessageLoop on the thread is an
  unnecessary implementation detail. When browser threads
  are migrated to base/task_scheduler, tasks will no longer
  have access to a MessageLoop but they will be able to use
  RunLoop.
- MessageLoop::RunUntilIdle() is deprecated.

Steps to generate this patch:
1. Run message_loop_cleanup_3.py (see code on the bug).
2. Run tools/sort-headers.py on modified files.
3. Run git cl format.

BUG=616447
R=thakis@chromium.org

Review-Url: https://codereview.chromium.org/2053103002
Cr-Commit-Position: refs/heads/master@{#399221}
  • Loading branch information
fdoray authored and Commit bot committed Jun 10, 2016
1 parent fe97611 commit fd4c7ba
Show file tree
Hide file tree
Showing 66 changed files with 284 additions and 255 deletions.
3 changes: 2 additions & 1 deletion chrome/browser/apps/guest_view/web_view_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "base/macros.h"
#include "base/path_service.h"
#include "base/process/process.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
Expand Down Expand Up @@ -3235,7 +3236,7 @@ class ScrollWaiter {

void WaitForScrollChange(gfx::Vector2dF target_offset) {
while (target_offset != host_view_->GetLastScrollOffset())
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
}

private:
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/background/background_mode_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "base/bind.h"
#include "base/command_line.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/test/test_simple_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
Expand Down Expand Up @@ -259,7 +259,7 @@ class BackgroundModeManagerWithExtensionsTest : public testing::Test {
Mock::VerifyAndClearExpectations(manager_.get());

// We're getting ready to shutdown the message loop. Clear everything out!
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();

test_keep_alive_.reset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "chrome/browser/browsing_data/browsing_data_quota_helper_impl.h"
#include "content/public/test/mock_storage_client.h"
#include "content/public/test/test_browser_thread.h"
Expand Down Expand Up @@ -46,7 +46,7 @@ class BrowsingDataQuotaHelperTest : public testing::Test {
helper_ = nullptr;
quota_manager_ = nullptr;
quota_info_.clear();
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
}

protected:
Expand Down Expand Up @@ -124,7 +124,7 @@ class BrowsingDataQuotaHelperTest : public testing::Test {

TEST_F(BrowsingDataQuotaHelperTest, Empty) {
StartFetching();
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(fetching_completed());
EXPECT_TRUE(quota_info().empty());
}
Expand All @@ -140,7 +140,7 @@ TEST_F(BrowsingDataQuotaHelperTest, FetchData) {

RegisterClient(kOrigins, arraysize(kOrigins));
StartFetching();
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(fetching_completed());

std::set<QuotaInfo> expected, actual;
Expand Down Expand Up @@ -169,7 +169,7 @@ TEST_F(BrowsingDataQuotaHelperTest, IgnoreExtensionsAndDevTools) {

RegisterClient(kOrigins, arraysize(kOrigins));
StartFetching();
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(fetching_completed());

std::set<QuotaInfo> expected, actual;
Expand All @@ -185,16 +185,16 @@ TEST_F(BrowsingDataQuotaHelperTest, RevokeHostQuota) {

SetPersistentHostQuota(kHost1, 1);
SetPersistentHostQuota(kHost2, 10);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();

RevokeHostQuota(kHost1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();

GetPersistentHostQuota(kHost1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(0, quota());

GetPersistentHostQuota(kHost2);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(10, quota());
}
6 changes: 3 additions & 3 deletions chrome/browser/browsing_data/cookies_tree_model_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string>

#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 "chrome/browser/browsing_data/mock_browsing_data_appcache_helper.h"
#include "chrome/browser/browsing_data/mock_browsing_data_cache_storage_helper.h"
Expand Down Expand Up @@ -52,7 +52,7 @@ class CookiesTreeModelTest : public testing::Test {
special_storage_policy_ = nullptr;
#endif
profile_.reset();
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
}

void SetUp() override {
Expand Down Expand Up @@ -106,7 +106,7 @@ class CookiesTreeModelTest : public testing::Test {
mock_browsing_data_local_storage_helper_ = nullptr;
mock_browsing_data_database_helper_ = nullptr;
mock_browsing_data_flash_lso_helper_ = nullptr;
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
}

std::unique_ptr<CookiesTreeModel> CreateCookiesTreeModelWithInitialSample() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "base/callback.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "chrome/browser/captive_portal/captive_portal_service.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "content/public/browser/interstitial_page.h"
Expand Down Expand Up @@ -117,7 +117,7 @@ TEST_F(CaptivePortalTabReloaderTest, InternetConnected) {
EXPECT_TRUE(tab_reloader().TimerRunning());

EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(tab_reloader().TimerRunning());
EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL,
tab_reloader().state());
Expand Down Expand Up @@ -167,7 +167,7 @@ TEST_F(CaptivePortalTabReloaderTest, NoResponse) {
EXPECT_TRUE(tab_reloader().TimerRunning());

EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(tab_reloader().TimerRunning());
EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL,
tab_reloader().state());
Expand Down Expand Up @@ -211,7 +211,7 @@ TEST_F(CaptivePortalTabReloaderTest, Login) {
tab_reloader().OnLoadStart(true);

EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(tab_reloader().TimerRunning());
EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL,
tab_reloader().state());
Expand Down Expand Up @@ -239,7 +239,7 @@ TEST_F(CaptivePortalTabReloaderTest, Login) {
tab_reloader().state());

EXPECT_CALL(tab_reloader(), ReloadTab()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, tab_reloader().state());
}

Expand All @@ -249,7 +249,7 @@ TEST_F(CaptivePortalTabReloaderTest, LoginLate) {
tab_reloader().OnLoadStart(true);

EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(tab_reloader().TimerRunning());
EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL,
tab_reloader().state());
Expand Down Expand Up @@ -373,7 +373,7 @@ TEST_F(CaptivePortalTabReloaderTest, SSLProtocolErrorAlreadyLoggedIn) {
// The error page commits, which should trigger a reload.
EXPECT_CALL(tab_reloader(), ReloadTab()).Times(1);
tab_reloader().OnLoadCommitted(net::ERR_SSL_PROTOCOL_ERROR);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, tab_reloader().state());
}

Expand All @@ -384,7 +384,7 @@ TEST_F(CaptivePortalTabReloaderTest, AlreadyLoggedIn) {
tab_reloader().OnLoadStart(true);

EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(tab_reloader().TimerRunning());
EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL,
tab_reloader().state());
Expand All @@ -403,7 +403,7 @@ TEST_F(CaptivePortalTabReloaderTest, AlreadyLoggedIn) {
tab_reloader().state());

EXPECT_CALL(tab_reloader(), ReloadTab()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, tab_reloader().state());
}

Expand All @@ -428,7 +428,7 @@ TEST_F(CaptivePortalTabReloaderTest, AlreadyLoggedInBeforeTimerTriggers) {
tab_reloader().state());

EXPECT_CALL(tab_reloader(), ReloadTab()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, tab_reloader().state());
}

Expand All @@ -453,7 +453,7 @@ TEST_F(CaptivePortalTabReloaderTest, LoginWhileTimerRunning) {
tab_reloader().state());

EXPECT_CALL(tab_reloader(), ReloadTab()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, tab_reloader().state());
}

Expand All @@ -476,7 +476,7 @@ TEST_F(CaptivePortalTabReloaderTest, BehindPortalResultWhileTimerRunning) {

// The rest proceeds as normal.
EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL,
tab_reloader().state());

Expand All @@ -503,7 +503,7 @@ TEST_F(CaptivePortalTabReloaderTest, BehindPortalResultWhileTimerRunning) {
tab_reloader().state());

EXPECT_CALL(tab_reloader(), ReloadTab()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, tab_reloader().state());
}

Expand Down Expand Up @@ -565,7 +565,7 @@ TEST_F(CaptivePortalTabReloaderTest, SSLCertErrorLogin) {
TEST_F(CaptivePortalTabReloaderTest, HttpToHttpsRedirectInternetConnected) {
tab_reloader().OnLoadStart(false);
// There should be no captive portal check pending.
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();

// HTTP to HTTPS redirect.
tab_reloader().OnRedirect(true);
Expand All @@ -574,7 +574,7 @@ TEST_F(CaptivePortalTabReloaderTest, HttpToHttpsRedirectInternetConnected) {
EXPECT_TRUE(tab_reloader().TimerRunning());

EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(tab_reloader().TimerRunning());
EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL,
tab_reloader().state());
Expand All @@ -595,15 +595,15 @@ TEST_F(CaptivePortalTabReloaderTest, HttpToHttpsRedirectInternetConnected) {
TEST_F(CaptivePortalTabReloaderTest, HttpToHttpsRedirectLogin) {
tab_reloader().OnLoadStart(false);
// There should be no captive portal check pending.
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();

// HTTP to HTTPS redirect.
tab_reloader().OnRedirect(true);
EXPECT_EQ(CaptivePortalTabReloader::STATE_TIMER_RUNNING,
tab_reloader().state());

EXPECT_CALL(tab_reloader(), CheckForCaptivePortal()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(tab_reloader().TimerRunning());
EXPECT_EQ(CaptivePortalTabReloader::STATE_MAYBE_BROKEN_BY_PORTAL,
tab_reloader().state());
Expand Down Expand Up @@ -631,7 +631,7 @@ TEST_F(CaptivePortalTabReloaderTest, HttpToHttpsRedirectLogin) {
tab_reloader().state());

EXPECT_CALL(tab_reloader(), ReloadTab()).Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, tab_reloader().state());
}

Expand All @@ -647,7 +647,7 @@ TEST_F(CaptivePortalTabReloaderTest, HttpsToHttpRedirect) {
EXPECT_FALSE(tab_reloader().TimerRunning());

// There should be no captive portal check pending after the redirect.
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();

// Logging in shouldn't do anything.
tab_reloader().OnCaptivePortalResults(
Expand All @@ -666,7 +666,7 @@ TEST_F(CaptivePortalTabReloaderTest, HttpsToHttpsRedirect) {
EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, tab_reloader().state());
EXPECT_FALSE(tab_reloader().TimerRunning());
// Nothing should happen.
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
}

// Check that an HTTPS to HTTP to HTTPS redirect results in no timer running.
Expand All @@ -683,7 +683,7 @@ TEST_F(CaptivePortalTabReloaderTest, HttpsToHttpToHttpsRedirect) {
EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, tab_reloader().state());
EXPECT_FALSE(tab_reloader().TimerRunning());
// Nothing should happen.
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
}

// Check that an HTTP to HTTP redirect results in the timer not running.
Expand All @@ -696,7 +696,7 @@ TEST_F(CaptivePortalTabReloaderTest, HttpToHttpRedirect) {
EXPECT_FALSE(tab_reloader().TimerRunning());

// There should be no captive portal check pending after the redirect.
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();

// Logging in shouldn't do anything.
tab_reloader().OnCaptivePortalResults(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ TEST_F(DeviceLocalAccountExternalPolicyLoaderTest, ForceInstallListSet) {
net::TestURLFetcherFactory factory;
EXPECT_CALL(visitor_, OnExternalProviderReady(provider_.get()))
.Times(1);
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();

// Verify that a downloader has started and is attempting to download an
// update manifest.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class CryptohomeAuthenticatorTest : public testing::Test {

void RunResolve(CryptohomeAuthenticator* auth) {
auth->Resolve();
base::MessageLoop::current()->RunUntilIdle();
base::RunLoop().RunUntilIdle();
}

void SetAttemptState(CryptohomeAuthenticator* auth, TestAttemptState* state) {
Expand Down
Loading

0 comments on commit fd4c7ba

Please sign in to comment.