Skip to content

Commit

Permalink
Revert "content: Remove use of MessageLoopProxy and deprecated Messag…
Browse files Browse the repository at this point in the history
…eLoop APIs"

This reverts commit 5d18b24.

Reason: Broke iOS build: http://build.chromium.org/p/chromium.mac/builders/iOS_Simulator_%28dbg%29/builds/27843

NOTRY=true
NOTREECHECKS=true
BUG=465354
TBR=sievers@chromium.org,nick@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#333047}
  • Loading branch information
skyostil authored and Commit bot committed Jun 5, 2015
1 parent a95af72 commit 74f13dc
Show file tree
Hide file tree
Showing 194 changed files with 1,212 additions and 1,245 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::SingleThreadTaskRunner> task_runner =
scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
utility_process_host_ =
UtilityProcessHost::Create(this, task_runner.get())->AsWeakPtr();
UtilityProcessHost::Create(this, message_loop_proxy.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::SingleThreadTaskRunner> IOTaskRunner() {
scoped_refptr<base::MessageLoopProxy> IOMessageLoopProxy() {
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,
IOTaskRunner());
IOMessageLoopProxy());

#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(),
IOTaskRunner()));
IOMessageLoopProxy()));
}

bool CloudPrintProxyPolicyStartupTest::Send(IPC::Message* message) {
Expand Down
28 changes: 16 additions & 12 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::SingleThreadTaskRunner> io_task_runner =
scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy =
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_task_runner);
google_services_user_account_id_.MoveToThread(io_message_loop_proxy);

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

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

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

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

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

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

#if defined(OS_CHROMEOS)
scoped_ptr<policy::PolicyCertVerifier> verifier =
Expand All @@ -505,24 +505,28 @@ 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_task_runner, callback,
base::Bind(policy::OverrideBlacklistForURL)));
url_blacklist_manager_.reset(
new policy::URLBlacklistManager(
pref_service,
background_task_runner,
io_message_loop_proxy,
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_task_runner);
policy_header_helper_ = policy_header_service->CreatePolicyHeaderIOHelper(
io_message_loop_proxy);
}
}
#endif

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

initialized_on_UI_thread_ = true;

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

#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "base/message_loop/message_loop.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 @@ -232,8 +230,9 @@ void AppCacheGroup::ScheduleUpdateRestart(int delay_ms) {
DCHECK(restart_update_task_.IsCancelled());
restart_update_task_.Reset(
base::Bind(&AppCacheGroup::RunQueuedUpdates, this));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, restart_update_task_.callback(),
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
restart_update_task_.callback(),
base::TimeDelta::FromMilliseconds(delay_ms));
}

Expand Down
1 change: 1 addition & 0 deletions content/browser/appcache/appcache_quota_client_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#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: 7 additions & 8 deletions content/browser/appcache/appcache_request_handler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/message_loop/message_loop.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 @@ -182,7 +180,7 @@ class AppCacheRequestHandlerTest : public testing::Test {
template <class Method>
void RunTestOnIOThread(Method method) {
test_finished_event_ .reset(new base::WaitableEvent(false, false));
io_thread_->task_runner()->PostTask(
io_thread_->message_loop()->PostTask(
FROM_HERE,
base::Bind(&AppCacheRequestHandlerTest::MethodWrapper<Method>,
base::Unretained(this), method));
Expand Down Expand Up @@ -223,9 +221,10 @@ 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::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&AppCacheRequestHandlerTest::TestFinishedUnwound,
base::Unretained(this)));
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&AppCacheRequestHandlerTest::TestFinishedUnwound,
base::Unretained(this)));
}

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

Expand Down
6 changes: 2 additions & 4 deletions content/browser/appcache/appcache_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
#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 @@ -92,7 +90,7 @@ AppCacheResponseIO::~AppCacheResponseIO() {
}

void AppCacheResponseIO::ScheduleIOCompletionCallback(int result) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&AppCacheResponseIO::OnIOComplete,
weak_factory_.GetWeakPtr(), result));
}
Expand Down
11 changes: 4 additions & 7 deletions content/browser/appcache/appcache_response_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
#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 @@ -78,7 +75,7 @@ class AppCacheResponseTest : public testing::Test {
template <class Method>
void RunTestOnIOThread(Method method) {
test_finished_event_ .reset(new base::WaitableEvent(false, false));
io_thread_->task_runner()->PostTask(
io_thread_->message_loop()->PostTask(
FROM_HERE, base::Bind(&AppCacheResponseTest::MethodWrapper<Method>,
base::Unretained(this), method));
test_finished_event_->Wait();
Expand Down Expand Up @@ -119,7 +116,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::ThreadTaskRunnerHandle::Get()->PostTask(
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&AppCacheResponseTest::TestFinishedUnwound,
base::Unretained(this)));
}
Expand Down Expand Up @@ -149,7 +146,7 @@ class AppCacheResponseTest : public testing::Test {
if (immediate)
task.Run();
else
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task);
base::MessageLoop::current()->PostTask(FROM_HERE, task);
}

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

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

#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 @@ -64,7 +63,7 @@ class AppCacheServiceImpl::AsyncHelper
void CallCallback(int rv) {
if (!callback_.is_null()) {
// Defer to guarantee async completion.
base::ThreadTaskRunnerHandle::Get()->PostTask(
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&DeferredCallback, callback_, rv));
}
callback_.Reset();
Expand Down
9 changes: 3 additions & 6 deletions content/browser/appcache/appcache_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@

#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 @@ -70,9 +67,9 @@ class MockResponseReader : public AppCacheResponseReader {

private:
void ScheduleUserCallback(int result) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&MockResponseReader::InvokeUserCompletionCallback,
weak_factory_.GetWeakPtr(), result));
base::MessageLoop::current()->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,13 +12,12 @@
#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 @@ -137,9 +136,8 @@ class AppCacheStorageImpl::DatabaseTask
: public base::RefCountedThreadSafe<DatabaseTask> {
public:
explicit DatabaseTask(AppCacheStorageImpl* storage)
: storage_(storage),
database_(storage->database_),
io_thread_(base::ThreadTaskRunnerHandle::Get()) {
: storage_(storage), database_(storage->database_),
io_thread_(base::MessageLoopProxy::current()) {
DCHECK(io_thread_.get());
}

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

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

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

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

void AppCacheStorageImpl::RunOnePendingSimpleTask() {
Expand Down
Loading

0 comments on commit 74f13dc

Please sign in to comment.