Skip to content

Commit

Permalink
content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs
Browse files Browse the repository at this point in the history
This patch was mostly autogenerated with
https://codereview.chromium.org/1010073002/.

BUG=465354
TBR=nick@chromium.org

Review URL: https://codereview.chromium.org/1159623009

Cr-Commit-Position: refs/heads/master@{#333043}
  • Loading branch information
skyostil authored and Commit bot committed Jun 5, 2015
1 parent ca894ec commit 5d18b24
Show file tree
Hide file tree
Showing 194 changed files with 1,245 additions and 1,212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ void SafeIAppsLibraryParser::StartProcessOnIOThread() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK_EQ(INITIAL_STATE, parser_state_);

scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
utility_process_host_ =
UtilityProcessHost::Create(this, message_loop_proxy.get())->AsWeakPtr();
UtilityProcessHost::Create(this, task_runner.get())->AsWeakPtr();
utility_process_host_->SetName(l10n_util::GetStringUTF16(
IDS_UTILITY_PROCESS_MEDIA_LIBRARY_FILE_CHECKER_NAME));
// Wait for the startup notification before sending the main IPC to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class CloudPrintProxyPolicyStartupTest : public base::MultiProcessTest,
void SetUp() override;
void TearDown() override;

scoped_refptr<base::MessageLoopProxy> IOMessageLoopProxy() {
scoped_refptr<base::SingleThreadTaskRunner> IOTaskRunner() {
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
}
base::Process Launch(const std::string& name);
Expand Down Expand Up @@ -442,7 +442,7 @@ base::Process CloudPrintProxyPolicyStartupTest::Launch(
startup_channel_ = IPC::ChannelProxy::Create(startup_channel_id_,
IPC::Channel::MODE_SERVER,
this,
IOMessageLoopProxy());
IOTaskRunner());

#if defined(OS_POSIX)
base::FileHandleMappingVector ipc_file_list;
Expand All @@ -467,7 +467,7 @@ void CloudPrintProxyPolicyStartupTest::WaitForConnect() {
IPC::ChannelProxy::Create(GetServiceProcessChannel(),
IPC::Channel::MODE_NAMED_CLIENT,
ServiceProcessControl::GetInstance(),
IOMessageLoopProxy()));
IOTaskRunner()));
}

bool CloudPrintProxyPolicyStartupTest::Send(IPC::Message* message) {
Expand Down
28 changes: 12 additions & 16 deletions chrome/browser/profiles/profile_io_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
&force_youtube_safety_mode_,
pref_service);

scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy =
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner =
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);

chrome_http_user_agent_settings_.reset(
Expand All @@ -467,25 +467,25 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
if (!IsOffTheRecord()) {
google_services_user_account_id_.Init(
prefs::kGoogleServicesUserAccountId, pref_service);
google_services_user_account_id_.MoveToThread(io_message_loop_proxy);
google_services_user_account_id_.MoveToThread(io_task_runner);

sync_disabled_.Init(sync_driver::prefs::kSyncManaged, pref_service);
sync_disabled_.MoveToThread(io_message_loop_proxy);
sync_disabled_.MoveToThread(io_task_runner);

signin_allowed_.Init(prefs::kSigninAllowed, pref_service);
signin_allowed_.MoveToThread(io_message_loop_proxy);
signin_allowed_.MoveToThread(io_task_runner);
}

quick_check_enabled_.Init(prefs::kQuickCheckEnabled,
local_state_pref_service);
quick_check_enabled_.MoveToThread(io_message_loop_proxy);
quick_check_enabled_.MoveToThread(io_task_runner);

media_device_id_salt_ = new MediaDeviceIDSalt(pref_service, IsOffTheRecord());

network_prediction_options_.Init(prefs::kNetworkPredictionOptions,
pref_service);

network_prediction_options_.MoveToThread(io_message_loop_proxy);
network_prediction_options_.MoveToThread(io_task_runner);

#if defined(OS_CHROMEOS)
scoped_ptr<policy::PolicyCertVerifier> verifier =
Expand All @@ -505,28 +505,24 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
scoped_refptr<base::SequencedTaskRunner> background_task_runner =
pool->GetSequencedTaskRunner(pool->GetSequenceToken());
url_blacklist_manager_.reset(
new policy::URLBlacklistManager(
pref_service,
background_task_runner,
io_message_loop_proxy,
callback,
base::Bind(policy::OverrideBlacklistForURL)));
url_blacklist_manager_.reset(new policy::URLBlacklistManager(
pref_service, background_task_runner, io_task_runner, callback,
base::Bind(policy::OverrideBlacklistForURL)));

if (!IsOffTheRecord()) {
// Add policy headers for non-incognito requests.
policy::PolicyHeaderService* policy_header_service =
policy::PolicyHeaderServiceFactory::GetForBrowserContext(profile);
if (policy_header_service) {
policy_header_helper_ = policy_header_service->CreatePolicyHeaderIOHelper(
io_message_loop_proxy);
policy_header_helper_ =
policy_header_service->CreatePolicyHeaderIOHelper(io_task_runner);
}
}
#endif

incognito_availibility_pref_.Init(
prefs::kIncognitoModeAvailability, pref_service);
incognito_availibility_pref_.MoveToThread(io_message_loop_proxy);
incognito_availibility_pref_.MoveToThread(io_task_runner);

initialized_on_UI_thread_ = true;

Expand Down
9 changes: 5 additions & 4 deletions content/browser/appcache/appcache_group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
#include <algorithm>

#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "content/browser/appcache/appcache.h"
#include "content/browser/appcache/appcache_host.h"
#include "content/browser/appcache/appcache_service_impl.h"
Expand Down Expand Up @@ -230,9 +232,8 @@ void AppCacheGroup::ScheduleUpdateRestart(int delay_ms) {
DCHECK(restart_update_task_.IsCancelled());
restart_update_task_.Reset(
base::Bind(&AppCacheGroup::RunQueuedUpdates, this));
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
restart_update_task_.callback(),
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, restart_update_task_.callback(),
base::TimeDelta::FromMilliseconds(delay_ms));
}

Expand Down
1 change: 0 additions & 1 deletion content/browser/appcache/appcache_quota_client_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <set>

#include "base/bind.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/run_loop.h"
#include "content/browser/appcache/appcache_quota_client.h"
#include "content/browser/appcache/mock_appcache_service.h"
Expand Down
15 changes: 8 additions & 7 deletions content/browser/appcache/appcache_request_handler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/message_loop/message_loop.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
#include "content/browser/appcache/appcache.h"
#include "content/browser/appcache/appcache_backend_impl.h"
Expand Down Expand Up @@ -180,7 +182,7 @@ class AppCacheRequestHandlerTest : public testing::Test {
template <class Method>
void RunTestOnIOThread(Method method) {
test_finished_event_ .reset(new base::WaitableEvent(false, false));
io_thread_->message_loop()->PostTask(
io_thread_->task_runner()->PostTask(
FROM_HERE,
base::Bind(&AppCacheRequestHandlerTest::MethodWrapper<Method>,
base::Unretained(this), method));
Expand Down Expand Up @@ -221,10 +223,9 @@ class AppCacheRequestHandlerTest : public testing::Test {
// We unwind the stack prior to finishing up to let stack
// based objects get deleted.
DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&AppCacheRequestHandlerTest::TestFinishedUnwound,
base::Unretained(this)));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&AppCacheRequestHandlerTest::TestFinishedUnwound,
base::Unretained(this)));
}

void TestFinishedUnwound() {
Expand All @@ -242,7 +243,7 @@ class AppCacheRequestHandlerTest : public testing::Test {
TestFinished();
return;
}
base::MessageLoop::current()->PostTask(FROM_HERE, task_stack_.top());
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task_stack_.top());
task_stack_.pop();
}

Expand Down
6 changes: 4 additions & 2 deletions content/browser/appcache/appcache_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/numerics/safe_math.h"
#include "base/pickle.h"
#include "base/profiler/scoped_tracker.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/thread_task_runner_handle.h"
#include "content/browser/appcache/appcache_storage.h"
#include "net/base/completion_callback.h"
#include "net/base/io_buffer.h"
Expand Down Expand Up @@ -90,7 +92,7 @@ AppCacheResponseIO::~AppCacheResponseIO() {
}

void AppCacheResponseIO::ScheduleIOCompletionCallback(int result) {
base::MessageLoop::current()->PostTask(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&AppCacheResponseIO::OnIOComplete,
weak_factory_.GetWeakPtr(), result));
}
Expand Down
11 changes: 7 additions & 4 deletions content/browser/appcache/appcache_response_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/location.h"
#include "base/pickle.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
#include "content/browser/appcache/appcache_response.h"
#include "content/browser/appcache/mock_appcache_service.h"
Expand Down Expand Up @@ -75,7 +78,7 @@ class AppCacheResponseTest : public testing::Test {
template <class Method>
void RunTestOnIOThread(Method method) {
test_finished_event_ .reset(new base::WaitableEvent(false, false));
io_thread_->message_loop()->PostTask(
io_thread_->task_runner()->PostTask(
FROM_HERE, base::Bind(&AppCacheResponseTest::MethodWrapper<Method>,
base::Unretained(this), method));
test_finished_event_->Wait();
Expand Down Expand Up @@ -116,7 +119,7 @@ class AppCacheResponseTest : public testing::Test {
// We unwind the stack prior to finishing up to let stack
// based objects get deleted.
DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
base::MessageLoop::current()->PostTask(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&AppCacheResponseTest::TestFinishedUnwound,
base::Unretained(this)));
}
Expand Down Expand Up @@ -146,7 +149,7 @@ class AppCacheResponseTest : public testing::Test {
if (immediate)
task.Run();
else
base::MessageLoop::current()->PostTask(FROM_HERE, task);
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task);
}

// Wrappers to call AppCacheResponseReader/Writer Read and Write methods
Expand Down Expand Up @@ -736,7 +739,7 @@ class AppCacheResponseTest : public testing::Test {
reader_.reset();

// Wait a moment to verify no callbacks.
base::MessageLoop::current()->PostDelayedTask(
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&AppCacheResponseTest::VerifyNoCallbacks,
base::Unretained(this)),
base::TimeDelta::FromMilliseconds(10));
Expand Down
5 changes: 3 additions & 2 deletions content/browser/appcache/appcache_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/thread_task_runner_handle.h"
#include "content/browser/appcache/appcache.h"
#include "content/browser/appcache/appcache_backend_impl.h"
#include "content/browser/appcache/appcache_entry.h"
Expand Down Expand Up @@ -63,7 +64,7 @@ class AppCacheServiceImpl::AsyncHelper
void CallCallback(int rv) {
if (!callback_.is_null()) {
// Defer to guarantee async completion.
base::MessageLoop::current()->PostTask(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&DeferredCallback, callback_, rv));
}
callback_.Reset();
Expand Down
9 changes: 6 additions & 3 deletions content/browser/appcache/appcache_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/location.h"
#include "base/pickle.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "content/browser/appcache/appcache_response.h"
#include "content/browser/appcache/appcache_service_impl.h"
#include "content/browser/appcache/mock_appcache_storage.h"
Expand Down Expand Up @@ -67,9 +70,9 @@ class MockResponseReader : public AppCacheResponseReader {

private:
void ScheduleUserCallback(int result) {
base::MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(&MockResponseReader::InvokeUserCompletionCallback,
weak_factory_.GetWeakPtr(), result));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&MockResponseReader::InvokeUserCompletionCallback,
weak_factory_.GetWeakPtr(), result));
}

scoped_ptr<net::HttpResponseInfo> info_;
Expand Down
26 changes: 13 additions & 13 deletions content/browser/appcache/appcache_storage_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/profiler/scoped_tracker.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/thread_task_runner_handle.h"
#include "content/browser/appcache/appcache.h"
#include "content/browser/appcache/appcache_database.h"
#include "content/browser/appcache/appcache_entry.h"
Expand Down Expand Up @@ -136,8 +137,9 @@ class AppCacheStorageImpl::DatabaseTask
: public base::RefCountedThreadSafe<DatabaseTask> {
public:
explicit DatabaseTask(AppCacheStorageImpl* storage)
: storage_(storage), database_(storage->database_),
io_thread_(base::MessageLoopProxy::current()) {
: storage_(storage),
database_(storage->database_),
io_thread_(base::ThreadTaskRunnerHandle::Get()) {
DCHECK(io_thread_.get());
}

Expand Down Expand Up @@ -178,7 +180,7 @@ class AppCacheStorageImpl::DatabaseTask
void CallRunCompleted(base::TimeTicks schedule_time);
void OnFatalError();

scoped_refptr<base::MessageLoopProxy> io_thread_;
scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
};

void AppCacheStorageImpl::DatabaseTask::Schedule() {
Expand Down Expand Up @@ -314,7 +316,7 @@ void AppCacheStorageImpl::InitTask::RunCompleted() {
if (!storage_->is_disabled()) {
storage_->usage_map_.swap(usage_map_);
const base::TimeDelta kDelay = base::TimeDelta::FromMinutes(5);
base::MessageLoop::current()->PostDelayedTask(
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::Bind(&AppCacheStorageImpl::DelayedStartDeletingUnusedResponses,
storage_->weak_factory_.GetWeakPtr()),
Expand Down Expand Up @@ -1738,10 +1740,9 @@ void AppCacheStorageImpl::StartDeletingResponses(
void AppCacheStorageImpl::ScheduleDeleteOneResponse() {
DCHECK(!is_response_deletion_scheduled_);
const base::TimeDelta kBriefDelay = base::TimeDelta::FromMilliseconds(10);
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&AppCacheStorageImpl::DeleteOneResponse,
weak_factory_.GetWeakPtr()),
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&AppCacheStorageImpl::DeleteOneResponse,
weak_factory_.GetWeakPtr()),
kBriefDelay);
is_response_deletion_scheduled_ = true;
}
Expand Down Expand Up @@ -1824,10 +1825,9 @@ void AppCacheStorageImpl::GetPendingForeignMarkingsForCache(

void AppCacheStorageImpl::ScheduleSimpleTask(const base::Closure& task) {
pending_simple_tasks_.push_back(task);
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&AppCacheStorageImpl::RunOnePendingSimpleTask,
weak_factory_.GetWeakPtr()));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&AppCacheStorageImpl::RunOnePendingSimpleTask,
weak_factory_.GetWeakPtr()));
}

void AppCacheStorageImpl::RunOnePendingSimpleTask() {
Expand Down
Loading

0 comments on commit 5d18b24

Please sign in to comment.