Commit 6117f22f authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

Migrate MessageLoop::current() to MessageLoopCurrent in /chrome/browser/chromeos/policy

These changes were scripted as part of the effort to restrict exposure of the
raw MessageLoop*.

Note that many static methods exposed on MessageLoopCurrent are also deprecated
so it is very well possible that this is migrating to an already deprecated
method.

The goal of this pass is to reduce usage of MessageLoop::current() (and
ultimately make it impossible to obtain the MessageLoop* statically).

As such I will not edit this CL unless the script did something logically wrong.
I defer to owners to fix highlighted usage of already deprecated APIs.

Possible script screw ups / things to look out for in this review:
 - Storing MessageLoopCurrent in a MessageLoop* variable or comparing it against
   one (I will go over that in a separate pass).

Includes should have been stripped if that was the last usage of message_loop.h
in that file.

Please CQ if LGTY

This CL was uploaded by git cl split.

R=pastarmovj@chromium.org

Bug: 825327
Change-Id: I4c8a61d564fa2c7c87ad95a334267a1715bb7563
Reviewed-on: https://chromium-review.googlesource.com/1024661
Commit-Queue: Julian Pastarmov <pastarmovj@chromium.org>
Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553027}
parent bbb7d2fb
......@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_task_runner_handle.h"
......@@ -527,15 +527,15 @@ TEST_F(AutoEnrollmentClientTest, CancelAndDeleteSoonWithPendingRequest) {
EXPECT_EQ(AUTO_ENROLLMENT_STATE_PENDING, state_);
// Cancel while a request is in flight.
EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
client_.release()->CancelAndDeleteSoon();
EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
// The client cleans itself up once a reply is received.
job->SendResponse(DM_STATUS_TEMPORARY_UNAVAILABLE,
em::DeviceManagementResponse());
// The DeleteSoon task has been posted:
EXPECT_FALSE(base::MessageLoop::current()->IsIdleForTesting());
EXPECT_FALSE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
EXPECT_EQ(AUTO_ENROLLMENT_STATE_PENDING, state_);
}
......@@ -548,10 +548,10 @@ TEST_F(AutoEnrollmentClientTest, NetworkChangedAfterCancelAndDeleteSoon) {
EXPECT_EQ(AUTO_ENROLLMENT_STATE_PENDING, state_);
// Cancel while a request is in flight.
EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
AutoEnrollmentClient* client = client_.release();
client->CancelAndDeleteSoon();
EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
// Network change events are ignored while a request is pending.
client->OnNetworkChanged(net::NetworkChangeNotifier::CONNECTION_ETHERNET);
......@@ -561,7 +561,7 @@ TEST_F(AutoEnrollmentClientTest, NetworkChangedAfterCancelAndDeleteSoon) {
job->SendResponse(DM_STATUS_TEMPORARY_UNAVAILABLE,
em::DeviceManagementResponse());
// The DeleteSoon task has been posted:
EXPECT_FALSE(base::MessageLoop::current()->IsIdleForTesting());
EXPECT_FALSE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
EXPECT_EQ(AUTO_ENROLLMENT_STATE_PENDING, state_);
// Network changes that have been posted before are also ignored:
......@@ -583,9 +583,9 @@ TEST_F(AutoEnrollmentClientTest, CancelAndDeleteSoonAfterCompletion) {
// The client will delete itself immediately if there are no pending
// requests.
EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
client_.release()->CancelAndDeleteSoon();
EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
}
TEST_F(AutoEnrollmentClientTest, CancelAndDeleteSoonAfterNetworkFailure) {
......@@ -595,9 +595,9 @@ TEST_F(AutoEnrollmentClientTest, CancelAndDeleteSoonAfterNetworkFailure) {
// The client will delete itself immediately if there are no pending
// requests.
EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
client_.release()->CancelAndDeleteSoon();
EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
}
TEST_F(AutoEnrollmentClientTest, NetworkFailureThenRequireUpdatedModulus) {
......
......@@ -9,7 +9,7 @@
#include "ash/public/cpp/ash_pref_names.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_simple_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
......@@ -105,7 +105,7 @@ RecommendationRestorerTest::RecommendationRestorerTest()
void RecommendationRestorerTest::SetUp() {
testing::Test::SetUp();
base::MessageLoop::current()->SetTaskRunner(runner_);
base::MessageLoopCurrent::Get()->SetTaskRunner(runner_);
ASSERT_TRUE(profile_manager_.SetUp());
}
......
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