diff options
author | skyostil <skyostil@chromium.org> | 2015-06-05 12:53:07 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-05 19:53:37 +0000 |
commit | 95082a6a47108c4e20a77cc224172a293065ab05 (patch) | |
tree | c34e72f82cf4742097c92a500fabd9af0f251cef /content/browser | |
parent | 4e95f763c7f52664c94373b7d9fcc0ed96c7f019 (diff) | |
download | chromium_src-95082a6a47108c4e20a77cc224172a293065ab05.zip chromium_src-95082a6a47108c4e20a77cc224172a293065ab05.tar.gz chromium_src-95082a6a47108c4e20a77cc224172a293065ab05.tar.bz2 |
content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs
This patch was mostly autogenerated with
https://codereview.chromium.org/1010073002/.
BUG=465354
TBR=nick@chromium.org
Committed: https://crrev.com/422456f9d53f0bf936a64f21a1463fd0abd3df84
Cr-Commit-Position: refs/heads/master@{#333081}
Review URL: https://codereview.chromium.org/1159623009
Cr-Commit-Position: refs/heads/master@{#333112}
Diffstat (limited to 'content/browser')
164 files changed, 1085 insertions, 1070 deletions
diff --git a/content/browser/appcache/appcache_group.cc b/content/browser/appcache/appcache_group.cc index 4e16e7f..dbd089c 100644 --- a/content/browser/appcache/appcache_group.cc +++ b/content/browser/appcache/appcache_group.cc @@ -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" @@ -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)); } diff --git a/content/browser/appcache/appcache_quota_client_unittest.cc b/content/browser/appcache/appcache_quota_client_unittest.cc index a453ee1..de17324 100644 --- a/content/browser/appcache/appcache_quota_client_unittest.cc +++ b/content/browser/appcache/appcache_quota_client_unittest.cc @@ -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" diff --git a/content/browser/appcache/appcache_request_handler_unittest.cc b/content/browser/appcache/appcache_request_handler_unittest.cc index f05fed2..3dbaf85 100644 --- a/content/browser/appcache/appcache_request_handler_unittest.cc +++ b/content/browser/appcache/appcache_request_handler_unittest.cc @@ -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" @@ -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)); @@ -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() { @@ -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(); } diff --git a/content/browser/appcache/appcache_response.cc b/content/browser/appcache/appcache_response.cc index 66ec22e..f113adf 100644 --- a/content/browser/appcache/appcache_response.cc +++ b/content/browser/appcache/appcache_response.cc @@ -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" @@ -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)); } diff --git a/content/browser/appcache/appcache_response_unittest.cc b/content/browser/appcache/appcache_response_unittest.cc index f5eb417..743a624 100644 --- a/content/browser/appcache/appcache_response_unittest.cc +++ b/content/browser/appcache/appcache_response_unittest.cc @@ -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" @@ -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(); @@ -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))); } @@ -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 @@ -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)); diff --git a/content/browser/appcache/appcache_service_impl.cc b/content/browser/appcache/appcache_service_impl.cc index 0c784df..47e81a4 100644 --- a/content/browser/appcache/appcache_service_impl.cc +++ b/content/browser/appcache/appcache_service_impl.cc @@ -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" @@ -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(); diff --git a/content/browser/appcache/appcache_service_unittest.cc b/content/browser/appcache/appcache_service_unittest.cc index 4159245..62e6a4d 100644 --- a/content/browser/appcache/appcache_service_unittest.cc +++ b/content/browser/appcache/appcache_service_unittest.cc @@ -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" @@ -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_; diff --git a/content/browser/appcache/appcache_storage_impl.cc b/content/browser/appcache/appcache_storage_impl.cc index 3653488..7494f5a 100644 --- a/content/browser/appcache/appcache_storage_impl.cc +++ b/content/browser/appcache/appcache_storage_impl.cc @@ -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" @@ -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()); } @@ -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() { @@ -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()), @@ -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; } @@ -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() { diff --git a/content/browser/appcache/appcache_storage_impl_unittest.cc b/content/browser/appcache/appcache_storage_impl_unittest.cc index 37c295d..9c980da 100644 --- a/content/browser/appcache/appcache_storage_impl_unittest.cc +++ b/content/browser/appcache/appcache_storage_impl_unittest.cc @@ -9,9 +9,11 @@ #include "base/callback.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" +#include "base/location.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.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" @@ -269,8 +271,8 @@ class AppCacheStorageImplTest : public testing::Test { MockQuotaManager() : QuotaManager(true /* is_incognito */, base::FilePath(), - io_thread->message_loop_proxy().get(), - db_thread->message_loop_proxy().get(), + io_thread->task_runner().get(), + db_thread->task_runner().get(), NULL), async_(false) {} @@ -279,11 +281,9 @@ class AppCacheStorageImplTest : public testing::Test { const GetUsageAndQuotaCallback& callback) override { EXPECT_EQ(storage::kStorageTypeTemporary, type); if (async_) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&MockQuotaManager::CallCallback, - base::Unretained(this), - callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&MockQuotaManager::CallCallback, + base::Unretained(this), callback)); return; } CallCallback(callback); @@ -370,11 +370,9 @@ class AppCacheStorageImplTest : public testing::Test { // We also have to wait for InitTask completion call to be performed // on the IO thread prior to running the test. Its guaranteed to be // queued by this time. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&AppCacheStorageImplTest::RunMethod<Method>, - base::Unretained(this), - method)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&AppCacheStorageImplTest::RunMethod<Method>, + base::Unretained(this), method)); } static void SetUpTestCase() { @@ -400,7 +398,7 @@ class AppCacheStorageImplTest : 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(&AppCacheStorageImplTest::MethodWrapper<Method>, base::Unretained(this), method)); test_finished_event_->Wait(); @@ -431,10 +429,9 @@ class AppCacheStorageImplTest : 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(&AppCacheStorageImplTest::TestFinishedUnwound, - base::Unretained(this))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&AppCacheStorageImplTest::TestFinishedUnwound, + base::Unretained(this))); } void TestFinishedUnwound() { @@ -451,7 +448,7 @@ class AppCacheStorageImplTest : public testing::Test { if (task_stack_.empty()) { return; } - base::MessageLoop::current()->PostTask(FROM_HERE, task_stack_.top()); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task_stack_.top()); task_stack_.pop(); } @@ -463,7 +460,7 @@ class AppCacheStorageImplTest : public testing::Test { // We pump a task thru the db thread to ensure any tasks previously // scheduled on that thread have been performed prior to return. base::WaitableEvent event(false, false); - db_thread->message_loop()->PostTask( + db_thread->task_runner()->PostTask( FROM_HERE, base::Bind(&AppCacheStorageImplTest::SignalEvent, &event)); event.Wait(); } @@ -1732,11 +1729,9 @@ class AppCacheStorageImplTest : public testing::Test { // We continue after the init task is complete including the callback // on the current thread. FlushDbThreadTasks(); - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&AppCacheStorageImplTest::Continue_Reinitialize, - base::Unretained(this), - test_case)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&AppCacheStorageImplTest::Continue_Reinitialize, + base::Unretained(this), test_case)); } void Continue_Reinitialize(ReinitTestCase test_case) { diff --git a/content/browser/appcache/appcache_update_job_unittest.cc b/content/browser/appcache/appcache_update_job_unittest.cc index b69af52..c5ddf4f 100644 --- a/content/browser/appcache/appcache_update_job_unittest.cc +++ b/content/browser/appcache/appcache_update_job_unittest.cc @@ -4,8 +4,11 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/synchronization/waitable_event.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "content/browser/appcache/appcache_group.h" #include "content/browser/appcache/appcache_host.h" @@ -603,7 +606,7 @@ class AppCacheUpdateJobTest : public testing::Test, template <class Method> void RunTestOnIOThread(Method method) { event_.reset(new base::WaitableEvent(false, false)); - io_thread_->message_loop()->PostTask( + io_thread_->task_runner()->PostTask( FROM_HERE, base::Bind(method, base::Unretained(this))); // Wait until task is done before exiting the test. @@ -2983,10 +2986,9 @@ class AppCacheUpdateJobTest : public testing::Test, void UpdateFinished() { // We unwind the stack prior to finishing up to let stack-based objects // get deleted. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&AppCacheUpdateJobTest::UpdateFinishedUnwound, - base::Unretained(this))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&AppCacheUpdateJobTest::UpdateFinishedUnwound, + base::Unretained(this))); } void UpdateFinishedUnwound() { diff --git a/content/browser/appcache/appcache_url_request_job.cc b/content/browser/appcache/appcache_url_request_job.cc index 9bf70e7..d66c795c 100644 --- a/content/browser/appcache/appcache_url_request_job.cc +++ b/content/browser/appcache/appcache_url_request_job.cc @@ -10,9 +10,11 @@ #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/compiler_specific.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/appcache/appcache.h" #include "content/browser/appcache/appcache_group.h" #include "content/browser/appcache/appcache_histograms.h" @@ -79,10 +81,9 @@ void AppCacheURLRequestJob::MaybeBeginDelivery() { if (has_been_started() && has_delivery_orders()) { // Start asynchronously so that all error reporting and data // callbacks happen as they would for network requests. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&AppCacheURLRequestJob::BeginDelivery, - weak_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&AppCacheURLRequestJob::BeginDelivery, + weak_factory_.GetWeakPtr())); } } diff --git a/content/browser/appcache/appcache_url_request_job_unittest.cc b/content/browser/appcache/appcache_url_request_job_unittest.cc index fdd1c9b..0e27295 100644 --- a/content/browser/appcache/appcache_url_request_job_unittest.cc +++ b/content/browser/appcache/appcache_url_request_job_unittest.cc @@ -9,10 +9,13 @@ #include "base/bind_helpers.h" #include "base/callback.h" #include "base/compiler_specific.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.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/appcache_url_request_job.h" @@ -217,7 +220,7 @@ class AppCacheURLRequestJobTest : 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(&AppCacheURLRequestJobTest::MethodWrapper<Method>, base::Unretained(this), method)); test_finished_event_->Wait(); @@ -267,10 +270,9 @@ class AppCacheURLRequestJobTest : 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(&AppCacheURLRequestJobTest::TestFinishedUnwound, - base::Unretained(this))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&AppCacheURLRequestJobTest::TestFinishedUnwound, + base::Unretained(this))); } void TestFinishedUnwound() { @@ -298,7 +300,7 @@ class AppCacheURLRequestJobTest : 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 diff --git a/content/browser/appcache/chrome_appcache_service_unittest.cc b/content/browser/appcache/chrome_appcache_service_unittest.cc index 450bfe2..0eca5fe 100644 --- a/content/browser/appcache/chrome_appcache_service_unittest.cc +++ b/content/browser/appcache/chrome_appcache_service_unittest.cc @@ -5,8 +5,9 @@ #include "base/bind.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" +#include "base/location.h" #include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "content/browser/appcache/appcache_database.h" #include "content/browser/appcache/appcache_storage_impl.h" #include "content/browser/appcache/chrome_appcache_service.h" @@ -33,17 +34,15 @@ const char kSessionOnlyManifest[] = "http://www.sessiononly.com/cache.manifest"; class MockURLRequestContextGetter : public net::URLRequestContextGetter { public: - MockURLRequestContextGetter( - net::URLRequestContext* context, - base::MessageLoopProxy* message_loop_proxy) - : context_(context), message_loop_proxy_(message_loop_proxy) { - } + MockURLRequestContextGetter(net::URLRequestContext* context, + base::SingleThreadTaskRunner* task_runner) + : context_(context), task_runner_(task_runner) {} net::URLRequestContext* GetURLRequestContext() override { return context_; } scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const override { - return message_loop_proxy_; + return task_runner_; } protected: @@ -51,7 +50,7 @@ class MockURLRequestContextGetter : public net::URLRequestContextGetter { private: net::URLRequestContext* context_; - scoped_refptr<base::SingleThreadTaskRunner> message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; }; } // namespace @@ -101,7 +100,7 @@ ChromeAppCacheServiceTest::CreateAppCacheServiceImpl( scoped_refptr<MockURLRequestContextGetter> mock_request_context_getter = new MockURLRequestContextGetter( browser_context_.GetResourceContext()->GetRequestContext(), - message_loop_.message_loop_proxy().get()); + message_loop_.task_runner().get()); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, diff --git a/content/browser/appcache/mock_appcache_service.cc b/content/browser/appcache/mock_appcache_service.cc index 549d20b..4f3e223 100644 --- a/content/browser/appcache/mock_appcache_service.cc +++ b/content/browser/appcache/mock_appcache_service.cc @@ -5,7 +5,9 @@ #include "content/browser/appcache/mock_appcache_service.h" #include "base/bind.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" namespace content { @@ -17,11 +19,9 @@ static void DeferredCallCallback( void MockAppCacheService::DeleteAppCachesForOrigin( const GURL& origin, const net::CompletionCallback& callback) { ++delete_called_count_; - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&DeferredCallCallback, - callback, - mock_delete_appcaches_for_origin_result_)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&DeferredCallCallback, callback, + mock_delete_appcaches_for_origin_result_)); } } // namespace content diff --git a/content/browser/appcache/mock_appcache_storage.cc b/content/browser/appcache/mock_appcache_storage.cc index 2a337a0..efac9ba 100644 --- a/content/browser/appcache/mock_appcache_storage.cc +++ b/content/browser/appcache/mock_appcache_storage.cc @@ -5,10 +5,12 @@ #include "content/browser/appcache/mock_appcache_storage.h" #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/ref_counted.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_entry.h" #include "content/browser/appcache/appcache_group.h" @@ -458,10 +460,9 @@ void MockAppCacheStorage::ProcessMakeGroupObsolete( void MockAppCacheStorage::ScheduleTask(const base::Closure& task) { pending_tasks_.push_back(task); - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&MockAppCacheStorage::RunOnePendingTask, - weak_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&MockAppCacheStorage::RunOnePendingTask, + weak_factory_.GetWeakPtr())); } void MockAppCacheStorage::RunOnePendingTask() { diff --git a/content/browser/background_sync/background_sync_manager.cc b/content/browser/background_sync/background_sync_manager.cc index c7c78cb..b82103d 100644 --- a/content/browser/background_sync/background_sync_manager.cc +++ b/content/browser/background_sync/background_sync_manager.cc @@ -6,6 +6,9 @@ #include "base/barrier_closure.h" #include "base/bind.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/background_sync/background_sync_network_observer.h" #include "content/browser/background_sync/background_sync_power_observer.h" #include "content/browser/service_worker/service_worker_context_wrapper.h" @@ -75,7 +78,7 @@ void BackgroundSyncManager::Register( sync_registration.id); if (disabled_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); return; @@ -96,7 +99,7 @@ void BackgroundSyncManager::Unregister( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); return; } @@ -117,7 +120,7 @@ void BackgroundSyncManager::GetRegistration( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); return; @@ -138,7 +141,7 @@ void BackgroundSyncManager::GetRegistrations( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, std::vector<BackgroundSyncRegistration>())); return; @@ -203,7 +206,8 @@ void BackgroundSyncManager::InitImpl(const base::Closure& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); return; } @@ -276,7 +280,8 @@ void BackgroundSyncManager::InitDidGetDataFromBackend( FireReadyEvents(); - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); } void BackgroundSyncManager::RegisterImpl( @@ -286,7 +291,7 @@ void BackgroundSyncManager::RegisterImpl( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); return; @@ -296,7 +301,7 @@ void BackgroundSyncManager::RegisterImpl( sw_registration_id, RegistrationKey(sync_registration)); if (existing_registration && existing_registration->Equals(sync_registration)) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, *existing_registration)); return; } @@ -309,7 +314,7 @@ void BackgroundSyncManager::RegisterImpl( ServiceWorkerRegistration* sw_registration = service_worker_context_->GetLiveRegistration(sw_registration_id); if (!sw_registration || !sw_registration->active_version()) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_NO_SERVICE_WORKER, BackgroundSyncRegistration())); return; @@ -331,7 +336,8 @@ void BackgroundSyncManager::DisableAndClearManager( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); return; } @@ -354,7 +360,8 @@ void BackgroundSyncManager::DisableAndClearDidGetRegistrations( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (status != SERVICE_WORKER_OK || user_data.empty()) { - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); return; } @@ -375,8 +382,8 @@ void BackgroundSyncManager::DisableAndClearManagerClearedOne( DCHECK_CURRENTLY_ON(BrowserThread::IO); // The status doesn't matter at this point, there is nothing else to be done. - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(barrier_closure)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(barrier_closure)); } BackgroundSyncManager::BackgroundSyncRegistration* @@ -445,7 +452,7 @@ void BackgroundSyncManager::RegisterDidStore( if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { // The registration is gone. sw_to_registrations_map_.erase(sw_registration_id); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); return; @@ -460,7 +467,7 @@ void BackgroundSyncManager::RegisterDidStore( } FireReadyEvents(); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, new_registration)); } @@ -530,7 +537,7 @@ void BackgroundSyncManager::UnregisterImpl( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); return; } @@ -539,7 +546,7 @@ void BackgroundSyncManager::UnregisterImpl( LookupRegistration(sw_registration_id, registration_key); if (!existing_registration || existing_registration->id != sync_registration_id) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND)); return; } @@ -561,7 +568,7 @@ void BackgroundSyncManager::UnregisterDidStore( if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { // ServiceWorker was unregistered. sw_to_registrations_map_.erase(sw_registration_id); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); return; } @@ -572,8 +579,8 @@ void BackgroundSyncManager::UnregisterDidStore( return; } - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, ERROR_TYPE_OK)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(callback, ERROR_TYPE_OK)); } void BackgroundSyncManager::GetRegistrationImpl( @@ -583,7 +590,7 @@ void BackgroundSyncManager::GetRegistrationImpl( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); return; @@ -592,13 +599,13 @@ void BackgroundSyncManager::GetRegistrationImpl( const BackgroundSyncRegistration* out_registration = LookupRegistration(sw_registration_id, registration_key); if (!out_registration) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND, BackgroundSyncRegistration())); return; } - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, *out_registration)); } @@ -611,7 +618,7 @@ void BackgroundSyncManager::GetRegistrationsImpl( std::vector<BackgroundSyncRegistration> out_registrations; if (disabled_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, out_registrations)); return; } @@ -629,7 +636,7 @@ void BackgroundSyncManager::GetRegistrationsImpl( } } - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, out_registrations)); } @@ -696,7 +703,8 @@ void BackgroundSyncManager::FireReadyEventsImpl(const base::Closure& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); return; } @@ -749,7 +757,8 @@ void BackgroundSyncManager::FireReadyEventsDidFindRegistration( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (service_worker_status != SERVICE_WORKER_OK) { - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); return; } @@ -760,7 +769,8 @@ void BackgroundSyncManager::FireReadyEventsDidFindRegistration( service_worker_registration->id(), registration_key, registration_id)); - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); } // |service_worker_registration| is just to keep the registration alive @@ -791,14 +801,16 @@ void BackgroundSyncManager::EventCompleteImpl( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); return; } BackgroundSyncRegistration* registration = LookupRegistration(service_worker_id, key); if (!registration || registration->id != sync_registration_id) { - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); return; } @@ -831,7 +843,8 @@ void BackgroundSyncManager::EventCompleteDidStore( if (status_code == SERVICE_WORKER_ERROR_NOT_FOUND) { // The registration is gone. sw_to_registrations_map_.erase(service_worker_id); - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); return; } @@ -842,7 +855,8 @@ void BackgroundSyncManager::EventCompleteDidStore( return; } - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); } void BackgroundSyncManager::OnRegistrationDeletedImpl( @@ -853,7 +867,8 @@ void BackgroundSyncManager::OnRegistrationDeletedImpl( // The backend (ServiceWorkerStorage) will delete the data, so just delete the // memory representation here. sw_to_registrations_map_.erase(registration_id); - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback)); } void BackgroundSyncManager::OnStorageWipedImpl(const base::Closure& callback) { diff --git a/content/browser/background_sync/background_sync_manager_unittest.cc b/content/browser/background_sync/background_sync_manager_unittest.cc index cb60eee..f49db2d 100644 --- a/content/browser/background_sync/background_sync_manager_unittest.cc +++ b/content/browser/background_sync/background_sync_manager_unittest.cc @@ -5,10 +5,12 @@ #include "content/browser/background_sync/background_sync_manager.h" #include "base/files/scoped_temp_dir.h" +#include "base/location.h" #include "base/logging.h" #include "base/power_monitor/power_monitor.h" #include "base/power_monitor/power_monitor_source.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/service_worker/embedded_worker_test_helper.h" @@ -145,7 +147,7 @@ class TestBackgroundSyncManager : public BackgroundSyncManager { const ServiceWorkerStorage::StatusCallback& callback) override { EXPECT_TRUE(continuation_.is_null()); if (corrupt_backend_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); return; } @@ -165,7 +167,7 @@ class TestBackgroundSyncManager : public BackgroundSyncManager { callback) override { EXPECT_TRUE(continuation_.is_null()); if (corrupt_backend_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, std::vector<std::pair<int64, std::string>>(), SERVICE_WORKER_ERROR_FAILED)); diff --git a/content/browser/background_sync/background_sync_network_observer.cc b/content/browser/background_sync/background_sync_network_observer.cc index fafb1e6..1c6f2bd 100644 --- a/content/browser/background_sync/background_sync_network_observer.cc +++ b/content/browser/background_sync/background_sync_network_observer.cc @@ -4,6 +4,9 @@ #include "content/browser/background_sync/background_sync_network_observer.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/public/browser/browser_thread.h" namespace content { @@ -47,7 +50,8 @@ bool BackgroundSyncNetworkObserver::NetworkSufficient( void BackgroundSyncNetworkObserver::NotifyNetworkChanged() { DCHECK_CURRENTLY_ON(BrowserThread::IO); - base::MessageLoop::current()->PostTask(FROM_HERE, network_changed_callback_); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + network_changed_callback_); } void BackgroundSyncNetworkObserver::OnNetworkChanged( diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index eeeb4d1..9ed607a 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc @@ -6,9 +6,9 @@ #include "base/bind.h" #include "base/command_line.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/memory_pressure_monitor.h" -#include "base/message_loop/message_loop.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/pending_task.h" @@ -17,6 +17,7 @@ #include "base/process/process_metrics.h" #include "base/profiler/scoped_profile.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/system_monitor/system_monitor.h" @@ -629,7 +630,7 @@ void BrowserMainLoop::PostMainMessageLoopStart() { #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) trace_memory_controller_.reset(new base::trace_event::TraceMemoryController( - base::MessageLoop::current()->message_loop_proxy(), + base::MessageLoop::current()->task_runner(), ::HeapProfilerWithPseudoStackStart, ::HeapProfilerStop, ::GetHeapProfile)); #endif @@ -714,13 +715,13 @@ void BrowserMainLoop::CreateStartupTasks() { // First time through, we really want to create all the tasks if (!startup_task_runner_.get()) { #if defined(OS_ANDROID) - startup_task_runner_ = make_scoped_ptr(new StartupTaskRunner( - base::Bind(&BrowserStartupComplete), - base::MessageLoop::current()->message_loop_proxy())); + startup_task_runner_ = make_scoped_ptr( + new StartupTaskRunner(base::Bind(&BrowserStartupComplete), + base::ThreadTaskRunnerHandle::Get())); #else - startup_task_runner_ = make_scoped_ptr(new StartupTaskRunner( - base::Callback<void(int)>(), - base::MessageLoop::current()->message_loop_proxy())); + startup_task_runner_ = make_scoped_ptr( + new StartupTaskRunner(base::Callback<void(int)>(), + base::ThreadTaskRunnerHandle::Get())); #endif StartupTask pre_create_threads = base::Bind(&BrowserMainLoop::PreCreateThreads, base::Unretained(this)); @@ -1207,7 +1208,7 @@ int BrowserMainLoop::BrowserThreadsStarted() { "startup", "BrowserMainLoop::BrowserThreadsStarted::InitUserInputMonitor"); user_input_monitor_ = media::UserInputMonitor::Create( - io_thread_->message_loop_proxy(), main_thread_->message_loop_proxy()); + io_thread_->task_runner(), main_thread_->task_runner()); } { @@ -1311,8 +1312,8 @@ void BrowserMainLoop::MainMessageLoopRun() { #else DCHECK(base::MessageLoopForUI::IsCurrent()); if (parameters_.ui_task) { - base::MessageLoopForUI::current()->PostTask(FROM_HERE, - *parameters_.ui_task); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + *parameters_.ui_task); } base::RunLoop run_loop; diff --git a/content/browser/browser_shutdown_profile_dumper.cc b/content/browser/browser_shutdown_profile_dumper.cc index 6c4d8c8..c23d8d1 100644 --- a/content/browser/browser_shutdown_profile_dumper.cc +++ b/content/browser/browser_shutdown_profile_dumper.cc @@ -8,7 +8,9 @@ #include "base/command_line.h" #include "base/files/file_path.h" #include "base/files/file_util.h" +#include "base/location.h" #include "base/logging.h" +#include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" @@ -59,11 +61,10 @@ void BrowserShutdownProfileDumper::WriteTracesToDisc() { base::WaitableEvent flush_complete_event(false, false); base::Thread flush_thread("browser_shutdown_trace_event_flush"); flush_thread.Start(); - flush_thread.message_loop()->PostTask( - FROM_HERE, - base::Bind(&BrowserShutdownProfileDumper::EndTraceAndFlush, - base::Unretained(this), - base::Unretained(&flush_complete_event))); + flush_thread.task_runner()->PostTask( + FROM_HERE, base::Bind(&BrowserShutdownProfileDumper::EndTraceAndFlush, + base::Unretained(this), + base::Unretained(&flush_complete_event))); bool original_wait_allowed = base::ThreadRestrictions::SetWaitAllowed(true); flush_complete_event.Wait(); diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc index 1aac305..b0a24ae 100644 --- a/content/browser/browser_thread_impl.cc +++ b/content/browser/browser_thread_impl.cc @@ -10,8 +10,7 @@ #include "base/bind.h" #include "base/compiler_specific.h" #include "base/lazy_instance.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "base/threading/sequenced_worker_pool.h" #include "base/threading/thread_restrictions.h" #include "content/public/browser/browser_thread_delegate.h" @@ -37,15 +36,14 @@ static const char* g_browser_thread_names[BrowserThread::ID_COUNT] = { "Chrome_IOThread", // IO }; -// An implementation of MessageLoopProxy to be used in conjunction +// An implementation of SingleThreadTaskRunner to be used in conjunction // with BrowserThread. -class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { +class BrowserThreadTaskRunner : public base::SingleThreadTaskRunner { public: - explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) - : id_(identifier) { - } + explicit BrowserThreadTaskRunner(BrowserThread::ID identifier) + : id_(identifier) {} - // MessageLoopProxy implementation. + // SingleThreadTaskRunner implementation. bool PostDelayedTask(const tracked_objects::Location& from_here, const base::Closure& task, base::TimeDelta delay) override { @@ -64,28 +62,28 @@ class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { } protected: - ~BrowserThreadMessageLoopProxy() override {} + ~BrowserThreadTaskRunner() override {} private: BrowserThread::ID id_; - DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); + DISALLOW_COPY_AND_ASSIGN(BrowserThreadTaskRunner); }; -// A separate helper is used just for the proxies, in order to avoid needing -// to initialize the globals to create a proxy. -struct BrowserThreadProxies { - BrowserThreadProxies() { +// A separate helper is used just for the task runners, in order to avoid +// needing to initialize the globals to create a task runner. +struct BrowserThreadTaskRunners { + BrowserThreadTaskRunners() { for (int i = 0; i < BrowserThread::ID_COUNT; ++i) { proxies[i] = - new BrowserThreadMessageLoopProxy(static_cast<BrowserThread::ID>(i)); + new BrowserThreadTaskRunner(static_cast<BrowserThread::ID>(i)); } } - scoped_refptr<base::MessageLoopProxy> proxies[BrowserThread::ID_COUNT]; + scoped_refptr<base::SingleThreadTaskRunner> proxies[BrowserThread::ID_COUNT]; }; -base::LazyInstance<BrowserThreadProxies>::Leaky - g_proxies = LAZY_INSTANCE_INITIALIZER; +base::LazyInstance<BrowserThreadTaskRunners>::Leaky g_task_runners = + LAZY_INSTANCE_INITIALIZER; struct BrowserThreadGlobals { BrowserThreadGlobals() @@ -331,9 +329,10 @@ bool BrowserThreadImpl::PostTaskHelper( : NULL; if (message_loop) { if (nestable) { - message_loop->PostDelayedTask(from_here, task, delay); + message_loop->task_runner()->PostDelayedTask(from_here, task, delay); } else { - message_loop->PostNonNestableDelayedTask(from_here, task, delay); + message_loop->task_runner()->PostNonNestableDelayedTask(from_here, task, + delay); } } @@ -517,9 +516,9 @@ bool BrowserThread::GetCurrentThreadIdentifier(ID* identifier) { } // static -scoped_refptr<base::MessageLoopProxy> +scoped_refptr<base::SingleThreadTaskRunner> BrowserThread::GetMessageLoopProxyForThread(ID identifier) { - return g_proxies.Get().proxies[identifier]; + return g_task_runners.Get().proxies[identifier]; } // static diff --git a/content/browser/browser_thread_unittest.cc b/content/browser/browser_thread_unittest.cc index 3f1f8cd..9b23057 100644 --- a/content/browser/browser_thread_unittest.cc +++ b/content/browser/browser_thread_unittest.cc @@ -4,10 +4,10 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/location.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/sequenced_task_runner_helpers.h" +#include "base/single_thread_task_runner.h" #include "content/browser/browser_thread_impl.h" #include "content/public/test/test_browser_thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -19,7 +19,7 @@ class BrowserThreadTest : public testing::Test { public: void Release() const { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); + loop_.task_runner()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); } protected: @@ -37,7 +37,8 @@ class BrowserThreadTest : public testing::Test { static void BasicFunction(base::MessageLoop* message_loop) { CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); + message_loop->task_runner()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); } class DeletedOnFile @@ -53,7 +54,8 @@ class BrowserThreadTest : public testing::Test { ~DeletedOnFile() { CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - message_loop_->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); + message_loop_->task_runner()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); } base::MessageLoop* message_loop_; @@ -88,24 +90,24 @@ TEST_F(BrowserThreadTest, ReleasedOnCorrectThread) { base::MessageLoop::current()->Run(); } -TEST_F(BrowserThreadTest, PostTaskViaMessageLoopProxy) { - scoped_refptr<base::MessageLoopProxy> message_loop_proxy = +TEST_F(BrowserThreadTest, PostTaskViaTaskRunner) { + scoped_refptr<base::SingleThreadTaskRunner> task_runner = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); - message_loop_proxy->PostTask( + task_runner->PostTask( FROM_HERE, base::Bind(&BasicFunction, base::MessageLoop::current())); base::MessageLoop::current()->Run(); } -TEST_F(BrowserThreadTest, ReleaseViaMessageLoopProxy) { - scoped_refptr<base::MessageLoopProxy> message_loop_proxy = +TEST_F(BrowserThreadTest, ReleaseViaTaskRunner) { + scoped_refptr<base::SingleThreadTaskRunner> task_runner = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); - message_loop_proxy->ReleaseSoon(FROM_HERE, this); + task_runner->ReleaseSoon(FROM_HERE, this); base::MessageLoop::current()->Run(); } TEST_F(BrowserThreadTest, PostTaskAndReply) { // Most of the heavy testing for PostTaskAndReply() is done inside the - // MessageLoopProxy test. This just makes sure we get piped through at all. + // task runner test. This just makes sure we get piped through at all. ASSERT_TRUE(BrowserThread::PostTaskAndReply( BrowserThread::FILE, FROM_HERE, diff --git a/content/browser/byte_stream_unittest.cc b/content/browser/byte_stream_unittest.cc index f814e2f5..f750cf2 100644 --- a/content/browser/byte_stream_unittest.cc +++ b/content/browser/byte_stream_unittest.cc @@ -10,7 +10,6 @@ #include "base/bind.h" #include "base/callback.h" #include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop.h" #include "base/test/test_simple_task_runner.h" #include "net/base/io_buffer.h" #include "testing/gtest/include/gtest/gtest.h" @@ -104,9 +103,8 @@ ByteStreamTest::ByteStreamTest() TEST_F(ByteStreamTest, ByteStream_PushBack) { scoped_ptr<ByteStreamWriter> byte_stream_input; scoped_ptr<ByteStreamReader> byte_stream_output; - CreateByteStream( - message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), + 3 * 1024, &byte_stream_input, &byte_stream_output); // Push a series of IO buffers on; test pushback happening and // that it's advisory. @@ -159,9 +157,8 @@ TEST_F(ByteStreamTest, ByteStream_PushBack) { TEST_F(ByteStreamTest, ByteStream_Flush) { scoped_ptr<ByteStreamWriter> byte_stream_input; scoped_ptr<ByteStreamReader> byte_stream_output; - CreateByteStream( - message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), - 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), + 1024, &byte_stream_input, &byte_stream_output); EXPECT_TRUE(Write(byte_stream_input.get(), 1)); message_loop_.RunUntilIdle(); @@ -199,9 +196,8 @@ TEST_F(ByteStreamTest, ByteStream_Flush) { TEST_F(ByteStreamTest, ByteStream_PushBackSplit) { scoped_ptr<ByteStreamWriter> byte_stream_input; scoped_ptr<ByteStreamReader> byte_stream_output; - CreateByteStream( - message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), - 9 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), + 9 * 1024, &byte_stream_input, &byte_stream_output); // Push a series of IO buffers on; test pushback happening and // that it's advisory. @@ -254,9 +250,8 @@ TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) { size_t output_length; // Empty stream, non-error case. - CreateByteStream( - message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), + 3 * 1024, &byte_stream_input, &byte_stream_output); EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, byte_stream_output->Read(&output_io_buffer, &output_length)); byte_stream_input->Close(0); @@ -266,9 +261,8 @@ TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) { EXPECT_EQ(0, byte_stream_output->GetStatus()); // Non-empty stream, non-error case. - CreateByteStream( - message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), + 3 * 1024, &byte_stream_input, &byte_stream_output); EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, byte_stream_output->Read(&output_io_buffer, &output_length)); EXPECT_TRUE(Write(byte_stream_input.get(), 1024)); @@ -284,9 +278,8 @@ TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) { const int kFakeErrorCode = 22; // Empty stream, error case. - CreateByteStream( - message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), + 3 * 1024, &byte_stream_input, &byte_stream_output); EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, byte_stream_output->Read(&output_io_buffer, &output_length)); byte_stream_input->Close(kFakeErrorCode); @@ -296,9 +289,8 @@ TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) { EXPECT_EQ(kFakeErrorCode, byte_stream_output->GetStatus()); // Non-empty stream, error case. - CreateByteStream( - message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), + 3 * 1024, &byte_stream_input, &byte_stream_output); EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, byte_stream_output->Read(&output_io_buffer, &output_length)); EXPECT_TRUE(Write(byte_stream_input.get(), 1024)); @@ -319,9 +311,8 @@ TEST_F(ByteStreamTest, ByteStream_SinkCallback) { scoped_ptr<ByteStreamWriter> byte_stream_input; scoped_ptr<ByteStreamReader> byte_stream_output; - CreateByteStream( - message_loop_.message_loop_proxy(), task_runner, - 10000, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), task_runner, 10000, + &byte_stream_input, &byte_stream_output); scoped_refptr<net::IOBuffer> output_io_buffer; size_t output_length; @@ -371,9 +362,8 @@ TEST_F(ByteStreamTest, ByteStream_SourceCallback) { scoped_ptr<ByteStreamWriter> byte_stream_input; scoped_ptr<ByteStreamReader> byte_stream_output; - CreateByteStream( - task_runner, message_loop_.message_loop_proxy(), - 10000, &byte_stream_input, &byte_stream_output); + CreateByteStream(task_runner, message_loop_.task_runner(), 10000, + &byte_stream_input, &byte_stream_output); scoped_refptr<net::IOBuffer> output_io_buffer; size_t output_length; @@ -433,9 +423,8 @@ TEST_F(ByteStreamTest, ByteStream_SinkInterrupt) { scoped_ptr<ByteStreamWriter> byte_stream_input; scoped_ptr<ByteStreamReader> byte_stream_output; - CreateByteStream( - message_loop_.message_loop_proxy(), task_runner, - 10000, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), task_runner, 10000, + &byte_stream_input, &byte_stream_output); scoped_refptr<net::IOBuffer> output_io_buffer; size_t output_length; @@ -480,9 +469,8 @@ TEST_F(ByteStreamTest, ByteStream_SourceInterrupt) { scoped_ptr<ByteStreamWriter> byte_stream_input; scoped_ptr<ByteStreamReader> byte_stream_output; - CreateByteStream( - task_runner, message_loop_.message_loop_proxy(), - 10000, &byte_stream_input, &byte_stream_output); + CreateByteStream(task_runner, message_loop_.task_runner(), 10000, + &byte_stream_input, &byte_stream_output); scoped_refptr<net::IOBuffer> output_io_buffer; size_t output_length; @@ -532,9 +520,8 @@ TEST_F(ByteStreamTest, ByteStream_ZeroCallback) { scoped_ptr<ByteStreamWriter> byte_stream_input; scoped_ptr<ByteStreamReader> byte_stream_output; - CreateByteStream( - message_loop_.message_loop_proxy(), task_runner, - 10000, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), task_runner, 10000, + &byte_stream_input, &byte_stream_output); base::Closure intermediate_callback; @@ -552,9 +539,8 @@ TEST_F(ByteStreamTest, ByteStream_ZeroCallback) { TEST_F(ByteStreamTest, ByteStream_CloseWithoutAnyWrite) { scoped_ptr<ByteStreamWriter> byte_stream_input; scoped_ptr<ByteStreamReader> byte_stream_output; - CreateByteStream( - message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), + 3 * 1024, &byte_stream_input, &byte_stream_output); byte_stream_input->Close(0); message_loop_.RunUntilIdle(); @@ -568,9 +554,8 @@ TEST_F(ByteStreamTest, ByteStream_CloseWithoutAnyWrite) { TEST_F(ByteStreamTest, ByteStream_FlushWithoutAnyWrite) { scoped_ptr<ByteStreamWriter> byte_stream_input; scoped_ptr<ByteStreamReader> byte_stream_output; - CreateByteStream( - message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), + 3 * 1024, &byte_stream_input, &byte_stream_output); byte_stream_input->Flush(); message_loop_.RunUntilIdle(); @@ -590,10 +575,9 @@ TEST_F(ByteStreamTest, ByteStream_FlushWithoutAnyWrite) { TEST_F(ByteStreamTest, ByteStream_WriteOverflow) { scoped_ptr<ByteStreamWriter> byte_stream_input; scoped_ptr<ByteStreamReader> byte_stream_output; - CreateByteStream( - message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), - std::numeric_limits<size_t>::max(), - &byte_stream_input, &byte_stream_output); + CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), + std::numeric_limits<size_t>::max(), &byte_stream_input, + &byte_stream_output); EXPECT_TRUE(Write(byte_stream_input.get(), 1)); // 1 + size_t max -> Overflow. diff --git a/content/browser/cache_storage/cache_storage.cc b/content/browser/cache_storage/cache_storage.cc index a6a32b9..24cc38b 100644 --- a/content/browser/cache_storage/cache_storage.cc +++ b/content/browser/cache_storage/cache_storage.cc @@ -9,12 +9,15 @@ #include "base/barrier_closure.h" #include "base/files/file_util.h" #include "base/files/memory_mapped_file.h" +#include "base/location.h" #include "base/memory/ref_counted.h" #include "base/metrics/histogram_macros.h" #include "base/sha1.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/cache_storage/cache_storage.pb.h" #include "content/browser/cache_storage/cache_storage_cache.h" #include "content/browser/cache_storage/cache_storage_scheduler.h" @@ -225,15 +228,15 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader { cache_task_runner_->PostTask( FROM_HERE, base::Bind(&SimpleCacheLoader::CleanUpDeleteCacheDirInPool, cache_path, - callback, base::MessageLoopProxy::current())); + callback, base::ThreadTaskRunnerHandle::Get())); } static void CleanUpDeleteCacheDirInPool( const base::FilePath& cache_path, const BoolCallback& callback, - const scoped_refptr<base::MessageLoopProxy>& original_loop) { + const scoped_refptr<base::SingleThreadTaskRunner>& original_task_runner) { bool rv = base::DeleteFile(cache_path, true); - original_loop->PostTask(FROM_HERE, base::Bind(callback, rv)); + original_task_runner->PostTask(FROM_HERE, base::Bind(callback, rv)); } void WriteIndex(const StringVector& cache_names, @@ -262,7 +265,7 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader { cache_task_runner_->PostTask( FROM_HERE, base::Bind(&SimpleCacheLoader::WriteIndexWriteToFileInPool, tmp_path, index_path, serialized, callback, - base::MessageLoopProxy::current())); + base::ThreadTaskRunnerHandle::Get())); } static void WriteIndexWriteToFileInPool( @@ -270,16 +273,16 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader { const base::FilePath& index_path, const std::string& data, const BoolCallback& callback, - const scoped_refptr<base::MessageLoopProxy>& original_loop) { + const scoped_refptr<base::SingleThreadTaskRunner>& original_task_runner) { int bytes_written = base::WriteFile(tmp_path, data.c_str(), data.size()); if (bytes_written != implicit_cast<int>(data.size())) { base::DeleteFile(tmp_path, /* recursive */ false); - original_loop->PostTask(FROM_HERE, base::Bind(callback, false)); + original_task_runner->PostTask(FROM_HERE, base::Bind(callback, false)); } // Atomically rename the temporary index file to become the real one. bool rv = base::ReplaceFile(tmp_path, index_path, NULL); - original_loop->PostTask(FROM_HERE, base::Bind(callback, rv)); + original_task_runner->PostTask(FROM_HERE, base::Bind(callback, rv)); } void LoadIndex(scoped_ptr<std::vector<std::string>> names, @@ -295,18 +298,18 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader { cache_task_runner_->PostTask( FROM_HERE, base::Bind(&SimpleCacheLoader::LoadIndexReadFileInPool, index_path, base::Passed(names.Pass()), callback, - base::MessageLoopProxy::current())); + base::ThreadTaskRunnerHandle::Get())); } static void LoadIndexReadFileInPool( const base::FilePath& index_path, scoped_ptr<std::vector<std::string>> names, const StringVectorCallback& callback, - const scoped_refptr<base::MessageLoopProxy>& original_loop) { + const scoped_refptr<base::SingleThreadTaskRunner>& original_task_runner) { std::string body; base::ReadFileToString(index_path, &body); - original_loop->PostTask( + original_task_runner->PostTask( FROM_HERE, base::Bind(&SimpleCacheLoader::LoadIndexDidReadFile, base::Passed(names.Pass()), callback, body)); } diff --git a/content/browser/cache_storage/cache_storage_cache.cc b/content/browser/cache_storage/cache_storage_cache.cc index 279dfc3..ab57e30 100644 --- a/content/browser/cache_storage/cache_storage_cache.cc +++ b/content/browser/cache_storage/cache_storage_cache.cc @@ -9,7 +9,6 @@ #include "base/barrier_closure.h" #include "base/files/file_path.h" #include "base/guid.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/histogram_macros.h" #include "base/strings/string_util.h" #include "content/browser/cache_storage/cache_storage.pb.h" @@ -1180,7 +1179,7 @@ void CacheStorageCache::CreateBackend(const ErrorCallback& callback) { weak_ptr_factory_.GetWeakPtr(), callback, base::Passed(backend_ptr.Pass())); - // TODO(jkarlin): Use the cache MessageLoopProxy that ServiceWorkerCacheCore + // TODO(jkarlin): Use the cache task runner that ServiceWorkerCacheCore // has for disk caches. int rv = disk_cache::CreateCacheBackend( cache_type, net::CACHE_BACKEND_SIMPLE, path_, kMaxCacheBytes, diff --git a/content/browser/cache_storage/cache_storage_cache_unittest.cc b/content/browser/cache_storage/cache_storage_cache_unittest.cc index 57350d2..2f11ab7 100644 --- a/content/browser/cache_storage/cache_storage_cache_unittest.cc +++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc @@ -6,9 +6,9 @@ #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" #include "base/strings/string_split.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/fileapi/chrome_blob_storage_context.h" #include "content/browser/fileapi/mock_url_request_delegate.h" #include "content/browser/quota/mock_quota_manager_proxy.h" @@ -38,10 +38,10 @@ const char kTestData[] = "Hello World"; // the memory. storage::BlobProtocolHandler* CreateMockBlobProtocolHandler( storage::BlobStorageContext* blob_storage_context) { - // The FileSystemContext and MessageLoopProxy are not actually used but a - // MessageLoopProxy is needed to avoid a DCHECK in BlobURLRequestJob ctor. + // The FileSystemContext and thread task runner are not actually used but a + // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. return new storage::BlobProtocolHandler( - blob_storage_context, NULL, base::MessageLoopProxy::current().get()); + blob_storage_context, NULL, base::ThreadTaskRunnerHandle::Get().get()); } // A disk_cache::Backend wrapper that can delay operations. @@ -186,7 +186,7 @@ class CacheStorageCacheTest : public testing::Test { blob_storage_context_ = blob_storage_context->context(); quota_manager_proxy_ = new MockQuotaManagerProxy( - nullptr, base::MessageLoopProxy::current().get()); + nullptr, base::ThreadTaskRunnerHandle::Get().get()); url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); url_request_job_factory_->SetProtocolHandler( @@ -261,8 +261,7 @@ class CacheStorageCacheTest : public testing::Test { base::Bind(&CacheStorageCacheTest::ErrorTypeCallback, base::Unretained(this), base::Unretained(loop.get()))); // TODO(jkarlin): These functions should use base::RunLoop().RunUntilIdle() - // once the cache uses a passed in MessageLoopProxy instead of the CACHE - // thread. + // once the cache uses a passed in task runner instead of the CACHE thread. loop->Run(); return callback_error_; diff --git a/content/browser/cache_storage/cache_storage_manager_unittest.cc b/content/browser/cache_storage/cache_storage_manager_unittest.cc index 4fb7e7f..61963b1 100644 --- a/content/browser/cache_storage/cache_storage_manager_unittest.cc +++ b/content/browser/cache_storage/cache_storage_manager_unittest.cc @@ -7,9 +7,9 @@ #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" #include "base/stl_util.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/cache_storage/cache_storage_quota_client.h" #include "content/browser/fileapi/chrome_blob_storage_context.h" #include "content/browser/quota/mock_quota_manager_proxy.h" @@ -39,18 +39,18 @@ class CacheStorageManagerTest : public testing::Test { base::RunLoop().RunUntilIdle(); quota_manager_proxy_ = new MockQuotaManagerProxy( - nullptr, base::MessageLoopProxy::current().get()); + nullptr, base::ThreadTaskRunnerHandle::Get().get()); net::URLRequestContext* url_request_context = browser_context_.GetRequestContext()->GetURLRequestContext(); if (MemoryOnly()) { cache_manager_ = CacheStorageManager::Create( - base::FilePath(), base::MessageLoopProxy::current(), + base::FilePath(), base::ThreadTaskRunnerHandle::Get(), quota_manager_proxy_); } else { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); cache_manager_ = CacheStorageManager::Create( - temp_dir_.path(), base::MessageLoopProxy::current(), + temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(), quota_manager_proxy_); } diff --git a/content/browser/cache_storage/cache_storage_scheduler.cc b/content/browser/cache_storage/cache_storage_scheduler.cc index 33447b9..86db5f2 100644 --- a/content/browser/cache_storage/cache_storage_scheduler.cc +++ b/content/browser/cache_storage/cache_storage_scheduler.cc @@ -9,7 +9,8 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" namespace content { @@ -40,7 +41,8 @@ void CacheStorageScheduler::RunOperationIfIdle() { // TODO(jkarlin): Run multiple operations in parallel where allowed. base::Closure closure = pending_operations_.front(); pending_operations_.pop_front(); - base::MessageLoopProxy::current()->PostTask(FROM_HERE, base::Bind(closure)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(closure)); } } diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc index 68ee72c..e1b4cfa 100644 --- a/content/browser/compositor/gpu_process_transport_factory.cc +++ b/content/browser/compositor/gpu_process_transport_factory.cc @@ -9,9 +9,10 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/location.h" -#include "base/message_loop/message_loop.h" #include "base/metrics/histogram.h" #include "base/profiler/scoped_tracker.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/simple_thread.h" #include "base/threading/thread.h" #include "cc/output/compositor_frame.h" @@ -594,7 +595,7 @@ GpuProcessTransportFactory::CreateContextCommon( } void GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback() { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&GpuProcessTransportFactory::OnLostMainThreadSharedContext, callback_factory_.GetWeakPtr())); diff --git a/content/browser/compositor/reflector_impl.h b/content/browser/compositor/reflector_impl.h index 957dfc3..ca1a89f 100644 --- a/content/browser/compositor/reflector_impl.h +++ b/content/browser/compositor/reflector_impl.h @@ -18,8 +18,6 @@ #include "ui/compositor/reflector.h" #include "ui/gfx/geometry/size.h" -namespace base { class MessageLoopProxy; } - namespace gfx { class Rect; } namespace ui { diff --git a/content/browser/compositor/reflector_impl_unittest.cc b/content/browser/compositor/reflector_impl_unittest.cc index a80b4fb..ce9fbb9 100644 --- a/content/browser/compositor/reflector_impl_unittest.cc +++ b/content/browser/compositor/reflector_impl_unittest.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "cc/test/fake_output_surface_client.h" @@ -119,7 +118,7 @@ class ReflectorImplTest : public testing::Test { scoped_ptr<ImageTransportFactory>( new NoTransportImageTransportFactory)); message_loop_.reset(new base::MessageLoop()); - proxy_ = message_loop_->message_loop_proxy(); + task_runner_ = message_loop_->task_runner(); compositor_task_runner_ = new FakeTaskRunner(); compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget, context_factory, @@ -166,7 +165,7 @@ class ReflectorImplTest : public testing::Test { scoped_refptr<cc::ContextProvider> context_provider_; cc::FakeOutputSurfaceClient output_surface_client_; scoped_ptr<base::MessageLoop> message_loop_; - scoped_refptr<base::MessageLoopProxy> proxy_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_ptr<ui::Compositor> compositor_; scoped_ptr<ui::Layer> root_layer_; scoped_ptr<ui::Layer> mirroring_layer_; diff --git a/content/browser/compositor/software_browser_compositor_output_surface.cc b/content/browser/compositor/software_browser_compositor_output_surface.cc index c2b70d4..866853c 100644 --- a/content/browser/compositor/software_browser_compositor_output_surface.cc +++ b/content/browser/compositor/software_browser_compositor_output_surface.cc @@ -4,8 +4,10 @@ #include "content/browser/compositor/software_browser_compositor_output_surface.h" +#include "base/location.h" #include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "cc/output/compositor_frame.h" #include "cc/output/output_surface_client.h" @@ -38,11 +40,9 @@ void SoftwareBrowserCompositorOutputSurface::SwapBuffers( ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, swap_time, 1); } - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind( - &RenderWidgetHostImpl::CompositorFrameDrawn, - frame->metadata.latency_info)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&RenderWidgetHostImpl::CompositorFrameDrawn, + frame->metadata.latency_info)); gfx::VSyncProvider* vsync_provider = software_device()->GetVSyncProvider(); if (vsync_provider) { diff --git a/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc b/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc index 68534f0..ae4962e 100644 --- a/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc +++ b/content/browser/compositor/software_browser_compositor_output_surface_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/message_loop/message_loop.h" +#include "base/thread_task_runner_handle.h" #include "cc/output/compositor_frame.h" #include "cc/test/fake_output_surface_client.h" #include "content/browser/compositor/software_browser_compositor_output_surface.h" @@ -91,7 +91,7 @@ void SoftwareBrowserCompositorOutputSurfaceTest::SetUp() { compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget, context_factory, - base::MessageLoopProxy::current())); + base::ThreadTaskRunnerHandle::Get())); } void SoftwareBrowserCompositorOutputSurfaceTest::TearDown() { diff --git a/content/browser/compositor/software_output_device_ozone_unittest.cc b/content/browser/compositor/software_output_device_ozone_unittest.cc index a19465b..99c55bd 100644 --- a/content/browser/compositor/software_output_device_ozone_unittest.cc +++ b/content/browser/compositor/software_output_device_ozone_unittest.cc @@ -4,6 +4,7 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" +#include "base/thread_task_runner_handle.h" #include "cc/output/software_frame_data.h" #include "content/browser/compositor/software_output_device_ozone.h" #include "testing/gtest/include/gtest/gtest.h" @@ -88,7 +89,7 @@ void SoftwareOutputDeviceOzoneTest::SetUp() { &window_delegate_, gfx::Rect(size)); compositor_.reset(new ui::Compositor(window_delegate_.GetAcceleratedWidget(), context_factory, - base::MessageLoopProxy::current())); + base::ThreadTaskRunnerHandle::Get())); compositor_->SetScaleAndSize(1.0f, size); output_device_.reset(new content::SoftwareOutputDeviceOzone( diff --git a/content/browser/database_quota_client_unittest.cc b/content/browser/database_quota_client_unittest.cc index a439b51..3c2c6f3 100644 --- a/content/browser/database_quota_client_unittest.cc +++ b/content/browser/database_quota_client_unittest.cc @@ -6,9 +6,11 @@ #include "base/bind.h" #include "base/files/file_path.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "net/base/completion_callback.h" #include "net/base/net_errors.h" #include "storage/browser/database/database_quota_client.h" @@ -72,10 +74,9 @@ class MockDatabaseTracker : public DatabaseTracker { const net::CompletionCallback& callback) override { ++delete_called_count_; if (async_delete()) { - base::MessageLoopProxy::current()->PostTask( - FROM_HERE, - base::Bind(&MockDatabaseTracker::AsyncDeleteDataForOrigin, this, - callback)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&MockDatabaseTracker::AsyncDeleteDataForOrigin, + this, callback)); return net::ERR_IO_PENDING; } return net::OK; @@ -207,7 +208,7 @@ class DatabaseQuotaClientTest : public testing::Test { TEST_F(DatabaseQuotaClientTest, GetOriginUsage) { - DatabaseQuotaClient client(base::MessageLoopProxy::current().get(), + DatabaseQuotaClient client(base::ThreadTaskRunnerHandle::Get().get(), mock_tracker()); EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); @@ -222,7 +223,7 @@ TEST_F(DatabaseQuotaClientTest, GetOriginUsage) { } TEST_F(DatabaseQuotaClientTest, GetOriginsForHost) { - DatabaseQuotaClient client(base::MessageLoopProxy::current().get(), + DatabaseQuotaClient client(base::ThreadTaskRunnerHandle::Get().get(), mock_tracker()); EXPECT_EQ(kOriginA.host(), kOriginB.host()); @@ -247,7 +248,7 @@ TEST_F(DatabaseQuotaClientTest, GetOriginsForHost) { } TEST_F(DatabaseQuotaClientTest, GetOriginsForType) { - DatabaseQuotaClient client(base::MessageLoopProxy::current().get(), + DatabaseQuotaClient client(base::ThreadTaskRunnerHandle::Get().get(), mock_tracker()); EXPECT_TRUE(GetOriginsForType(&client, kTemp).empty()); @@ -262,7 +263,7 @@ TEST_F(DatabaseQuotaClientTest, GetOriginsForType) { } TEST_F(DatabaseQuotaClientTest, DeleteOriginData) { - DatabaseQuotaClient client(base::MessageLoopProxy::current().get(), + DatabaseQuotaClient client(base::ThreadTaskRunnerHandle::Get().get(), mock_tracker()); // Perm deletions are short circuited in the Client and diff --git a/content/browser/database_tracker_unittest.cc b/content/browser/database_tracker_unittest.cc index 14557de..a068b4d 100644 --- a/content/browser/database_tracker_unittest.cc +++ b/content/browser/database_tracker_unittest.cc @@ -8,8 +8,8 @@ #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/public/test/mock_special_storage_policy.h" #include "net/base/net_errors.h" @@ -564,12 +564,9 @@ class DatabaseTracker_TestHelper_Test { scoped_refptr<MockSpecialStoragePolicy> special_storage_policy = new MockSpecialStoragePolicy; special_storage_policy->AddSessionOnly(GURL(kOrigin2Url)); - scoped_refptr<DatabaseTracker> tracker( - new DatabaseTracker(temp_dir.path(), - false, - special_storage_policy.get(), - NULL, - base::MessageLoopProxy::current().get())); + scoped_refptr<DatabaseTracker> tracker(new DatabaseTracker( + temp_dir.path(), false, special_storage_policy.get(), NULL, + base::ThreadTaskRunnerHandle::Get().get())); // Open two new databases. tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0, @@ -644,12 +641,9 @@ class DatabaseTracker_TestHelper_Test { scoped_refptr<MockSpecialStoragePolicy> special_storage_policy = new MockSpecialStoragePolicy; special_storage_policy->AddSessionOnly(GURL(kOrigin2Url)); - scoped_refptr<DatabaseTracker> tracker( - new DatabaseTracker(temp_dir.path(), - false, - special_storage_policy.get(), - NULL, - base::MessageLoopProxy::current().get())); + scoped_refptr<DatabaseTracker> tracker(new DatabaseTracker( + temp_dir.path(), false, special_storage_policy.get(), NULL, + base::ThreadTaskRunnerHandle::Get().get())); tracker->SetForceKeepSessionState(); // Open two new databases. diff --git a/content/browser/device_sensors/data_fetcher_shared_memory_base.cc b/content/browser/device_sensors/data_fetcher_shared_memory_base.cc index f2b2d40..ac86c6f 100644 --- a/content/browser/device_sensors/data_fetcher_shared_memory_base.cc +++ b/content/browser/device_sensors/data_fetcher_shared_memory_base.cc @@ -5,7 +5,9 @@ #include "content/browser/device_sensors/data_fetcher_shared_memory_base.h" #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/threading/thread.h" #include "base/timer/timer.h" @@ -129,11 +131,10 @@ bool DataFetcherSharedMemoryBase::StartFetchingDeviceData( if (GetType() != FETCHER_TYPE_DEFAULT) { if (!InitAndStartPollingThreadIfNecessary()) return false; - polling_thread_->message_loop()->PostTask( - FROM_HERE, - base::Bind(&PollingThread::AddConsumer, - base::Unretained(polling_thread_.get()), - consumer_type, buffer)); + polling_thread_->task_runner()->PostTask( + FROM_HERE, base::Bind(&PollingThread::AddConsumer, + base::Unretained(polling_thread_.get()), + consumer_type, buffer)); } else { if (!Start(consumer_type, buffer)) return false; @@ -150,11 +151,10 @@ bool DataFetcherSharedMemoryBase::StopFetchingDeviceData( return true; if (GetType() != FETCHER_TYPE_DEFAULT) { - polling_thread_->message_loop()->PostTask( + polling_thread_->task_runner()->PostTask( FROM_HERE, base::Bind(&PollingThread::RemoveConsumer, - base::Unretained(polling_thread_.get()), - consumer_type)); + base::Unretained(polling_thread_.get()), consumer_type)); } else { if (!Stop(consumer_type)) return false; diff --git a/content/browser/devtools/devtools_manager_unittest.cc b/content/browser/devtools/devtools_manager_unittest.cc index cd632c1..9ace6fa 100644 --- a/content/browser/devtools/devtools_manager_unittest.cc +++ b/content/browser/devtools/devtools_manager_unittest.cc @@ -3,7 +3,10 @@ // found in the LICENSE file. #include "base/basictypes.h" +#include "base/location.h" #include "base/memory/scoped_ptr.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/browser/devtools/devtools_manager.h" #include "content/browser/devtools/shared_worker_devtools_manager.h" @@ -140,9 +143,8 @@ TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedContents) { // Start with a short timeout. inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); // Wait long enough for first timeout and see if it fired. - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::MessageLoop::QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); base::MessageLoop::current()->Run(); EXPECT_FALSE(delegate.renderer_unresponsive_received()); @@ -152,9 +154,8 @@ TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedContents) { // Start with a short timeout. inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); // Wait long enough for first timeout and see if it fired. - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::MessageLoop::QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); base::MessageLoop::current()->Run(); EXPECT_TRUE(delegate.renderer_unresponsive_received()); diff --git a/content/browser/devtools/protocol/page_handler.cc b/content/browser/devtools/protocol/page_handler.cc index cc69f7d2..63550c0 100644 --- a/content/browser/devtools/protocol/page_handler.cc +++ b/content/browser/devtools/protocol/page_handler.cc @@ -8,8 +8,11 @@ #include "base/base64.h" #include "base/bind.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/worker_pool.h" #include "content/browser/devtools/protocol/color_picker.h" #include "content/browser/renderer_host/render_widget_host_impl.h" @@ -426,10 +429,9 @@ void PageHandler::ScreencastFrameCaptured( processing_screencast_frame_ = false; if (capture_retry_count_) { --capture_retry_count_; - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&PageHandler::InnerSwapCompositorFrame, - weak_factory_.GetWeakPtr()), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&PageHandler::InnerSwapCompositorFrame, + weak_factory_.GetWeakPtr()), base::TimeDelta::FromMilliseconds(kFrameRetryDelayMs)); } return; diff --git a/content/browser/devtools/protocol/tethering_handler.h b/content/browser/devtools/protocol/tethering_handler.h index 246fdd3..21f1a9a 100644 --- a/content/browser/devtools/protocol/tethering_handler.h +++ b/content/browser/devtools/protocol/tethering_handler.h @@ -6,7 +6,6 @@ #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_ #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" namespace net { diff --git a/content/browser/dom_storage/dom_storage_area_unittest.cc b/content/browser/dom_storage/dom_storage_area_unittest.cc index aa5653d..ba91f26 100644 --- a/content/browser/dom_storage/dom_storage_area_unittest.cc +++ b/content/browser/dom_storage/dom_storage_area_unittest.cc @@ -5,7 +5,9 @@ #include "base/bind.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" +#include "base/location.h" #include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "base/thread_task_runner_handle.h" #include "base/threading/sequenced_worker_pool.h" @@ -45,11 +47,10 @@ class DOMStorageAreaTest : public testing::Test { // At this point the StartCommitTimer task has run and // the OnCommitTimer task is queued. We want to inject after // that. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&DOMStorageAreaTest::InjectedCommitSequencingTask2, - base::Unretained(this), - area)); + base::Unretained(this), area)); } void InjectedCommitSequencingTask2( @@ -173,10 +174,10 @@ TEST_F(DOMStorageAreaTest, BackingDatabaseOpened) { // This should set up a DOMStorageArea that is correctly backed to disk. { - scoped_refptr<DOMStorageArea> area(new DOMStorageArea( - kOrigin, - temp_dir.path(), - new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()))); + scoped_refptr<DOMStorageArea> area( + new DOMStorageArea(kOrigin, temp_dir.path(), + new MockDOMStorageTaskRunner( + base::ThreadTaskRunnerHandle::Get().get()))); EXPECT_TRUE(area->backing_.get()); DOMStorageDatabase* database = static_cast<LocalStorageDatabaseAdapter*>( @@ -221,9 +222,8 @@ TEST_F(DOMStorageAreaTest, CommitTasks) { ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); scoped_refptr<DOMStorageArea> area(new DOMStorageArea( - kOrigin, - temp_dir.path(), - new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()))); + kOrigin, temp_dir.path(), + new MockDOMStorageTaskRunner(base::ThreadTaskRunnerHandle::Get().get()))); // Inject an in-memory db to speed up the test. area->backing_.reset(new LocalStorageDatabaseAdapter()); @@ -300,9 +300,8 @@ TEST_F(DOMStorageAreaTest, CommitChangesAtShutdown) { base::ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); scoped_refptr<DOMStorageArea> area(new DOMStorageArea( - kOrigin, - temp_dir.path(), - new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()))); + kOrigin, temp_dir.path(), + new MockDOMStorageTaskRunner(base::ThreadTaskRunnerHandle::Get().get()))); // Inject an in-memory db to speed up the test and also to verify // the final changes are commited in it's dtor. @@ -327,9 +326,8 @@ TEST_F(DOMStorageAreaTest, DeleteOrigin) { base::ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); scoped_refptr<DOMStorageArea> area(new DOMStorageArea( - kOrigin, - temp_dir.path(), - new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()))); + kOrigin, temp_dir.path(), + new MockDOMStorageTaskRunner(base::ThreadTaskRunnerHandle::Get().get()))); // This test puts files on disk. base::FilePath db_file_path = static_cast<LocalStorageDatabaseAdapter*>( @@ -388,9 +386,8 @@ TEST_F(DOMStorageAreaTest, PurgeMemory) { base::ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); scoped_refptr<DOMStorageArea> area(new DOMStorageArea( - kOrigin, - temp_dir.path(), - new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()))); + kOrigin, temp_dir.path(), + new MockDOMStorageTaskRunner(base::ThreadTaskRunnerHandle::Get().get()))); // Inject an in-memory db to speed up the test. area->backing_.reset(new LocalStorageDatabaseAdapter()); diff --git a/content/browser/dom_storage/dom_storage_context_impl_unittest.cc b/content/browser/dom_storage/dom_storage_context_impl_unittest.cc index 9ea4602..fe99fbf 100644 --- a/content/browser/dom_storage/dom_storage_context_impl_unittest.cc +++ b/content/browser/dom_storage/dom_storage_context_impl_unittest.cc @@ -6,8 +6,8 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/sequenced_worker_pool.h" #include "base/time/time.h" #include "content/browser/dom_storage/dom_storage_area.h" @@ -43,7 +43,7 @@ class DOMStorageContextImplTest : public testing::Test { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); storage_policy_ = new MockSpecialStoragePolicy; task_runner_ = - new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()); + new MockDOMStorageTaskRunner(base::ThreadTaskRunnerHandle::Get().get()); context_ = new DOMStorageContextImpl(temp_dir_.path(), base::FilePath(), storage_policy_.get(), diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.cc b/content/browser/dom_storage/dom_storage_context_wrapper.cc index fef44e8..db486f3 100644 --- a/content/browser/dom_storage/dom_storage_context_wrapper.cc +++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc @@ -10,7 +10,9 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/files/file_path.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/dom_storage/dom_storage_area.h" #include "content/browser/dom_storage/dom_storage_context_impl.h" #include "content/browser/dom_storage/dom_storage_task_runner.h" @@ -32,16 +34,15 @@ void InvokeLocalStorageUsageCallbackHelper( } void GetLocalStorageUsageHelper( - base::MessageLoopProxy* reply_loop, + base::SingleThreadTaskRunner* reply_task_runner, DOMStorageContextImpl* context, const DOMStorageContext::GetLocalStorageUsageCallback& callback) { std::vector<LocalStorageUsageInfo>* infos = new std::vector<LocalStorageUsageInfo>; context->GetLocalStorageUsage(infos, true); - reply_loop->PostTask( - FROM_HERE, - base::Bind(&InvokeLocalStorageUsageCallbackHelper, - callback, base::Owned(infos))); + reply_task_runner->PostTask( + FROM_HERE, base::Bind(&InvokeLocalStorageUsageCallbackHelper, callback, + base::Owned(infos))); } void InvokeSessionStorageUsageCallbackHelper( @@ -51,16 +52,15 @@ void InvokeSessionStorageUsageCallbackHelper( } void GetSessionStorageUsageHelper( - base::MessageLoopProxy* reply_loop, + base::SingleThreadTaskRunner* reply_task_runner, DOMStorageContextImpl* context, const DOMStorageContext::GetSessionStorageUsageCallback& callback) { std::vector<SessionStorageUsageInfo>* infos = new std::vector<SessionStorageUsageInfo>; context->GetSessionStorageUsage(infos); - reply_loop->PostTask( - FROM_HERE, - base::Bind(&InvokeSessionStorageUsageCallbackHelper, - callback, base::Owned(infos))); + reply_task_runner->PostTask( + FROM_HERE, base::Bind(&InvokeSessionStorageUsageCallbackHelper, callback, + base::Owned(infos))); } } // namespace @@ -89,25 +89,19 @@ DOMStorageContextWrapper::~DOMStorageContextWrapper() { void DOMStorageContextWrapper::GetLocalStorageUsage( const GetLocalStorageUsageCallback& callback) { DCHECK(context_.get()); - context_->task_runner() - ->PostShutdownBlockingTask(FROM_HERE, - DOMStorageTaskRunner::PRIMARY_SEQUENCE, - base::Bind(&GetLocalStorageUsageHelper, - base::MessageLoopProxy::current(), - context_, - callback)); + context_->task_runner()->PostShutdownBlockingTask( + FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, + base::Bind(&GetLocalStorageUsageHelper, + base::ThreadTaskRunnerHandle::Get(), context_, callback)); } void DOMStorageContextWrapper::GetSessionStorageUsage( const GetSessionStorageUsageCallback& callback) { DCHECK(context_.get()); - context_->task_runner() - ->PostShutdownBlockingTask(FROM_HERE, - DOMStorageTaskRunner::PRIMARY_SEQUENCE, - base::Bind(&GetSessionStorageUsageHelper, - base::MessageLoopProxy::current(), - context_, - callback)); + context_->task_runner()->PostShutdownBlockingTask( + FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, + base::Bind(&GetSessionStorageUsageHelper, + base::ThreadTaskRunnerHandle::Get(), context_, callback)); } void DOMStorageContextWrapper::DeleteLocalStorage(const GURL& origin) { diff --git a/content/browser/dom_storage/dom_storage_task_runner.cc b/content/browser/dom_storage/dom_storage_task_runner.cc index aa75c3c..cf2204d 100644 --- a/content/browser/dom_storage/dom_storage_task_runner.cc +++ b/content/browser/dom_storage/dom_storage_task_runner.cc @@ -6,7 +6,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" #include "base/tracked_objects.h" namespace content { @@ -23,8 +23,8 @@ DOMStorageWorkerPoolTaskRunner::DOMStorageWorkerPoolTaskRunner( base::SequencedWorkerPool* sequenced_worker_pool, base::SequencedWorkerPool::SequenceToken primary_sequence_token, base::SequencedWorkerPool::SequenceToken commit_sequence_token, - base::MessageLoopProxy* delayed_task_loop) - : message_loop_(delayed_task_loop), + base::SingleThreadTaskRunner* delayed_task_task_runner) + : task_runner_(delayed_task_task_runner), sequenced_worker_pool_(sequenced_worker_pool), primary_sequence_token_(primary_sequence_token), commit_sequence_token_(commit_sequence_token) { @@ -46,7 +46,7 @@ bool DOMStorageWorkerPoolTaskRunner::PostDelayedTask( base::SequencedWorkerPool::BLOCK_SHUTDOWN); } // Post a task to call this->PostTask() after the delay. - return message_loop_->PostDelayedTask( + return task_runner_->PostDelayedTask( FROM_HERE, base::Bind(base::IgnoreResult(&DOMStorageWorkerPoolTaskRunner::PostTask), this, from_here, task), @@ -79,8 +79,8 @@ DOMStorageWorkerPoolTaskRunner::IDtoToken(SequenceID id) const { // MockDOMStorageTaskRunner MockDOMStorageTaskRunner::MockDOMStorageTaskRunner( - base::MessageLoopProxy* message_loop) - : message_loop_(message_loop) { + base::SingleThreadTaskRunner* task_runner) + : task_runner_(task_runner) { } MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() { @@ -90,18 +90,18 @@ bool MockDOMStorageTaskRunner::PostDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, base::TimeDelta delay) { - return message_loop_->PostTask(from_here, task); + return task_runner_->PostTask(from_here, task); } bool MockDOMStorageTaskRunner::PostShutdownBlockingTask( const tracked_objects::Location& from_here, SequenceID sequence_id, const base::Closure& task) { - return message_loop_->PostTask(from_here, task); + return task_runner_->PostTask(from_here, task); } bool MockDOMStorageTaskRunner::IsRunningOnSequence(SequenceID) const { - return message_loop_->RunsTasksOnCurrentThread(); + return task_runner_->RunsTasksOnCurrentThread(); } } // namespace content diff --git a/content/browser/dom_storage/dom_storage_task_runner.h b/content/browser/dom_storage/dom_storage_task_runner.h index 1d4485c..f71c9c8 100644 --- a/content/browser/dom_storage/dom_storage_task_runner.h +++ b/content/browser/dom_storage/dom_storage_task_runner.h @@ -7,12 +7,13 @@ #include "base/memory/ref_counted.h" #include "base/sequenced_task_runner.h" +#include "base/single_thread_task_runner.h" #include "base/threading/sequenced_worker_pool.h" #include "base/time/time.h" #include "content/common/content_export.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } namespace content { @@ -73,7 +74,7 @@ class CONTENT_EXPORT DOMStorageWorkerPoolTaskRunner : base::SequencedWorkerPool* sequenced_worker_pool, base::SequencedWorkerPool::SequenceToken primary_sequence_token, base::SequencedWorkerPool::SequenceToken commit_sequence_token, - base::MessageLoopProxy* delayed_task_loop); + base::SingleThreadTaskRunner* delayed_task_task_runner); bool PostDelayedTask(const tracked_objects::Location& from_here, const base::Closure& task, @@ -92,7 +93,7 @@ class CONTENT_EXPORT DOMStorageWorkerPoolTaskRunner : base::SequencedWorkerPool::SequenceToken IDtoToken(SequenceID id) const; - const scoped_refptr<base::MessageLoopProxy> message_loop_; + const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; const scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_; base::SequencedWorkerPool::SequenceToken primary_sequence_token_; base::SequencedWorkerPool::SequenceToken commit_sequence_token_; @@ -106,7 +107,7 @@ class CONTENT_EXPORT DOMStorageWorkerPoolTaskRunner : class CONTENT_EXPORT MockDOMStorageTaskRunner : public DOMStorageTaskRunner { public: - explicit MockDOMStorageTaskRunner(base::MessageLoopProxy* message_loop); + explicit MockDOMStorageTaskRunner(base::SingleThreadTaskRunner* task_runner); bool PostDelayedTask(const tracked_objects::Location& from_here, const base::Closure& task, @@ -122,7 +123,7 @@ class CONTENT_EXPORT MockDOMStorageTaskRunner : ~MockDOMStorageTaskRunner() override; private: - const scoped_refptr<base::MessageLoopProxy> message_loop_; + const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; }; } // namespace content diff --git a/content/browser/download/download_file_impl.cc b/content/browser/download/download_file_impl.cc index 5597703..3436722 100644 --- a/content/browser/download/download_file_impl.cc +++ b/content/browser/download/download_file_impl.cc @@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/files/file_util.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/strings/stringprintf.h" #include "base/time/time.h" #include "base/values.h" diff --git a/content/browser/download/download_file_unittest.cc b/content/browser/download/download_file_unittest.cc index 620efa3..59cc4a7 100644 --- a/content/browser/download/download_file_unittest.cc +++ b/content/browser/download/download_file_unittest.cc @@ -4,10 +4,12 @@ #include "base/files/file.h" #include "base/files/file_util.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/test/test_file_util.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/byte_stream.h" #include "content/browser/download/download_create_info.h" @@ -650,16 +652,16 @@ TEST_P(DownloadFileTestWithRename, RenameWithErrorRetry) { // Rename() will be in front of the QuitClosure(). Running the message loop // now causes the just the first retry task to be run. The rename still // fails, so another retry task would get queued behind the QuitClosure(). - base::MessageLoop::current()->PostTask(FROM_HERE, - first_failing_run.QuitClosure()); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, first_failing_run.QuitClosure()); first_failing_run.Run(); EXPECT_FALSE(did_run_callback); // Running another loop should have the same effect as the above as long as // kMaxRenameRetries is greater than 2. base::RunLoop second_failing_run; - base::MessageLoop::current()->PostTask(FROM_HERE, - second_failing_run.QuitClosure()); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, second_failing_run.QuitClosure()); second_failing_run.Run(); EXPECT_FALSE(did_run_callback); } @@ -775,9 +777,9 @@ TEST_F(DownloadFileTest, ConfirmUpdate) { AppendDataToFile(chunks1, 2); // Run the message loops for 750ms and check for results. - loop_.PostDelayedTask(FROM_HERE, - base::MessageLoop::QuitClosure(), - base::TimeDelta::FromMilliseconds(750)); + loop_.task_runner()->PostDelayedTask(FROM_HERE, + base::MessageLoop::QuitClosure(), + base::TimeDelta::FromMilliseconds(750)); loop_.Run(); EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc index ee610e4..99a57b1 100644 --- a/content/browser/download/download_resource_handler.cc +++ b/content/browser/download/download_resource_handler.cc @@ -7,11 +7,13 @@ #include <string> #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/histogram_macros.h" #include "base/metrics/sparse_histogram.h" +#include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/byte_stream.h" #include "content/browser/download/download_create_info.h" #include "content/browser/download/download_interrupt_reasons_impl.h" @@ -191,7 +193,7 @@ bool DownloadResourceHandler::OnResponseStarted( // Create the ByteStream for sending data to the download sink. scoped_ptr<ByteStreamReader> stream_reader; CreateByteStream( - base::MessageLoopProxy::current(), + base::ThreadTaskRunnerHandle::Get(), BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), kDownloadByteStreamSize, &stream_writer_, &stream_reader); stream_writer_->RegisterCallback( diff --git a/content/browser/download/drag_download_file.cc b/content/browser/download/drag_download_file.cc index 13950a1..2014270 100644 --- a/content/browser/download/drag_download_file.cc +++ b/content/browser/download/drag_download_file.cc @@ -6,7 +6,8 @@ #include "base/bind.h" #include "base/files/file.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "content/browser/download/download_stats.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/browser_context.h" @@ -94,7 +95,8 @@ class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer { DCHECK_CURRENTLY_ON(BrowserThread::UI); if (!item) { DCHECK_NE(DOWNLOAD_INTERRUPT_REASON_NONE, interrupt_reason); - on_completed_loop_->PostTask(FROM_HERE, base::Bind(on_completed_, false)); + on_completed_loop_->task_runner()->PostTask( + FROM_HERE, base::Bind(on_completed_, false)); return; } DCHECK_EQ(DOWNLOAD_INTERRUPT_REASON_NONE, interrupt_reason); @@ -111,8 +113,9 @@ class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer { state == DownloadItem::CANCELLED || state == DownloadItem::INTERRUPTED) { if (!on_completed_.is_null()) { - on_completed_loop_->PostTask(FROM_HERE, base::Bind( - on_completed_, state == DownloadItem::COMPLETE)); + on_completed_loop_->task_runner()->PostTask( + FROM_HERE, + base::Bind(on_completed_, state == DownloadItem::COMPLETE)); on_completed_.Reset(); } download_item_->RemoveObserver(this); @@ -127,8 +130,8 @@ class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer { if (!on_completed_.is_null()) { const bool is_complete = download_item_->GetState() == DownloadItem::COMPLETE; - on_completed_loop_->PostTask(FROM_HERE, base::Bind( - on_completed_, is_complete)); + on_completed_loop_->task_runner()->PostTask( + FROM_HERE, base::Bind(on_completed_, is_complete)); on_completed_.Reset(); } download_item_->RemoveObserver(this); diff --git a/content/browser/fileapi/blob_url_request_job_unittest.cc b/content/browser/fileapi/blob_url_request_job_unittest.cc index ed90f1d..e2fa5fe 100644 --- a/content/browser/fileapi/blob_url_request_job_unittest.cc +++ b/content/browser/fileapi/blob_url_request_job_unittest.cc @@ -11,6 +11,7 @@ #include "base/memory/scoped_ptr.h" #include "base/numerics/safe_conversions.h" #include "base/run_loop.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/browser/fileapi/mock_url_request_delegate.h" #include "content/public/test/async_file_test_helper.h" @@ -71,7 +72,7 @@ class BlobURLRequestJobTest : public testing::Test { return new BlobURLRequestJob(request, network_delegate, test_->GetSnapshotFromBuilder(), test_->file_system_context_.get(), - base::MessageLoopProxy::current().get()); + base::ThreadTaskRunnerHandle::Get().get()); } private: diff --git a/content/browser/fileapi/copy_or_move_file_validator_unittest.cc b/content/browser/fileapi/copy_or_move_file_validator_unittest.cc index f9b8d15..c07db9d 100644 --- a/content/browser/fileapi/copy_or_move_file_validator_unittest.cc +++ b/content/browser/fileapi/copy_or_move_file_validator_unittest.cc @@ -6,7 +6,10 @@ #include "base/bind.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/public/test/async_file_test_helper.h" #include "content/public/test/mock_special_storage_policy.h" #include "content/public/test/test_file_system_backend.h" @@ -221,7 +224,7 @@ class TestCopyOrMoveFileValidatorFactory void StartPreWriteValidation( const ResultCallback& result_callback) override { // Post the result since a real validator must do work asynchronously. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(result_callback, result_)); } @@ -229,7 +232,7 @@ class TestCopyOrMoveFileValidatorFactory const base::FilePath& dest_platform_path, const ResultCallback& result_callback) override { // Post the result since a real validator must do work asynchronously. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(result_callback, write_result_)); } diff --git a/content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc b/content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc index 451353d..bbcae16 100644 --- a/content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc +++ b/content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc @@ -9,9 +9,11 @@ #include "base/bind.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/quota/mock_quota_manager.h" #include "content/browser/quota/mock_quota_manager_proxy.h" #include "content/public/test/async_file_test_helper.h" @@ -79,7 +81,7 @@ class TestValidatorFactory : public storage::CopyOrMoveFileValidatorFactory { void StartPreWriteValidation( const ResultCallback& result_callback) override { // Post the result since a real validator must do work asynchronously. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(result_callback, result_)); } @@ -92,7 +94,7 @@ class TestValidatorFactory : public storage::CopyOrMoveFileValidatorFactory { result = base::File::FILE_ERROR_SECURITY; } // Post the result since a real validator must do work asynchronously. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(result_callback, result)); } @@ -147,7 +149,7 @@ class ScopedThreadStopper { if (thread_) { // Give another chance for deleted streams to perform Close. base::RunLoop run_loop; - thread_->message_loop_proxy()->PostTaskAndReply( + thread_->task_runner()->PostTaskAndReply( FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure()); run_loop.Run(); thread_->Stop(); @@ -191,13 +193,12 @@ class CopyOrMoveOperationTestHelper { ASSERT_TRUE(base_.CreateUniqueTempDir()); base::FilePath base_dir = base_.path(); quota_manager_ = - new MockQuotaManager(false /* is_incognito */, - base_dir, - base::MessageLoopProxy::current().get(), - base::MessageLoopProxy::current().get(), - NULL /* special storage policy */); + new MockQuotaManager(false /* is_incognito */, base_dir, + base::ThreadTaskRunnerHandle::Get().get(), + base::ThreadTaskRunnerHandle::Get().get(), + NULL /* special storage policy */); quota_manager_proxy_ = new MockQuotaManagerProxy( - quota_manager_.get(), base::MessageLoopProxy::current().get()); + quota_manager_.get(), base::ThreadTaskRunnerHandle::Get().get()); file_system_context_ = CreateFileSystemContextForTesting(quota_manager_proxy_.get(), base_dir); @@ -728,8 +729,8 @@ TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelper) { ScopedThreadStopper thread_stopper(&file_thread); ASSERT_TRUE(thread_stopper.is_valid()); - scoped_refptr<base::MessageLoopProxy> task_runner = - file_thread.message_loop_proxy(); + scoped_refptr<base::SingleThreadTaskRunner> task_runner = + file_thread.task_runner(); scoped_ptr<storage::FileStreamReader> reader( storage::FileStreamReader::CreateForLocalFile( @@ -784,8 +785,8 @@ TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelperWithFlush) { ScopedThreadStopper thread_stopper(&file_thread); ASSERT_TRUE(thread_stopper.is_valid()); - scoped_refptr<base::MessageLoopProxy> task_runner = - file_thread.message_loop_proxy(); + scoped_refptr<base::SingleThreadTaskRunner> task_runner = + file_thread.task_runner(); scoped_ptr<storage::FileStreamReader> reader( storage::FileStreamReader::CreateForLocalFile( @@ -835,8 +836,8 @@ TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelper_Cancel) { ScopedThreadStopper thread_stopper(&file_thread); ASSERT_TRUE(thread_stopper.is_valid()); - scoped_refptr<base::MessageLoopProxy> task_runner = - file_thread.message_loop_proxy(); + scoped_refptr<base::SingleThreadTaskRunner> task_runner = + file_thread.task_runner(); scoped_ptr<storage::FileStreamReader> reader( storage::FileStreamReader::CreateForLocalFile( @@ -854,7 +855,7 @@ TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelper_Cancel) { base::TimeDelta()); // For testing, we need all the progress. // Call Cancel() later. - base::MessageLoopProxy::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&CopyOrMoveOperationDelegate::StreamCopyHelper::Cancel, base::Unretained(&helper))); diff --git a/content/browser/fileapi/dragged_file_util_unittest.cc b/content/browser/fileapi/dragged_file_util_unittest.cc index 98b2cee..38d8337 100644 --- a/content/browser/fileapi/dragged_file_util_unittest.cc +++ b/content/browser/fileapi/dragged_file_util_unittest.cc @@ -13,7 +13,6 @@ #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/time/time.h" #include "content/public/test/async_file_test_helper.h" #include "content/public/test/test_file_system_context.h" diff --git a/content/browser/fileapi/file_system_browsertest.cc b/content/browser/fileapi/file_system_browsertest.cc index 79e9f3cb..5ff9600 100644 --- a/content/browser/fileapi/file_system_browsertest.cc +++ b/content/browser/fileapi/file_system_browsertest.cc @@ -5,7 +5,9 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/files/file_path.h" +#include "base/location.h" #include "base/memory/ref_counted.h" +#include "base/single_thread_task_runner.h" #include "base/test/thread_test_helper.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/browser_context.h" diff --git a/content/browser/fileapi/file_system_context_unittest.cc b/content/browser/fileapi/file_system_context_unittest.cc index c071c4b..b1ffb63 100644 --- a/content/browser/fileapi/file_system_context_unittest.cc +++ b/content/browser/fileapi/file_system_context_unittest.cc @@ -5,8 +5,8 @@ #include "storage/browser/fileapi/file_system_context.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop.h" #include "base/strings/stringprintf.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/quota/mock_quota_manager.h" #include "content/public/test/mock_special_storage_policy.h" #include "content/public/test/test_file_system_options.h" @@ -54,26 +54,21 @@ class FileSystemContextTest : public testing::Test { storage_policy_ = new MockSpecialStoragePolicy(); - mock_quota_manager_ = - new MockQuotaManager(false /* is_incognito */, - data_dir_.path(), - base::MessageLoopProxy::current().get(), - base::MessageLoopProxy::current().get(), - storage_policy_.get()); + mock_quota_manager_ = new MockQuotaManager( + false /* is_incognito */, data_dir_.path(), + base::ThreadTaskRunnerHandle::Get().get(), + base::ThreadTaskRunnerHandle::Get().get(), storage_policy_.get()); } protected: FileSystemContext* CreateFileSystemContextForTest( storage::ExternalMountPoints* external_mount_points) { return new FileSystemContext( - base::MessageLoopProxy::current().get(), - base::MessageLoopProxy::current().get(), - external_mount_points, - storage_policy_.get(), - mock_quota_manager_->proxy(), + base::ThreadTaskRunnerHandle::Get().get(), + base::ThreadTaskRunnerHandle::Get().get(), external_mount_points, + storage_policy_.get(), mock_quota_manager_->proxy(), ScopedVector<FileSystemBackend>(), - std::vector<storage::URLRequestAutoMountHandler>(), - data_dir_.path(), + std::vector<storage::URLRequestAutoMountHandler>(), data_dir_.path(), CreateAllowFileAccessOptions()); } diff --git a/content/browser/fileapi/file_system_dir_url_request_job_unittest.cc b/content/browser/fileapi/file_system_dir_url_request_job_unittest.cc index ff913ec..43dd8129 100644 --- a/content/browser/fileapi/file_system_dir_url_request_job_unittest.cc +++ b/content/browser/fileapi/file_system_dir_url_request_job_unittest.cc @@ -10,12 +10,13 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/format_macros.h" +#include "base/location.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/strings/string_piece.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/public/test/mock_special_storage_policy.h" #include "content/public/test/test_file_system_backend.h" #include "content/public/test/test_file_system_context.h" @@ -153,7 +154,7 @@ class FileSystemDirURLRequestJobTest : public testing::Test { ScopedVector<storage::FileSystemBackend> additional_providers; additional_providers.push_back(new TestFileSystemBackend( - base::MessageLoopProxy::current().get(), *mnt_point)); + base::ThreadTaskRunnerHandle::Get().get(), *mnt_point)); std::vector<storage::URLRequestAutoMountHandler> handlers; handlers.push_back(base::Bind(&TestAutoMountForURLRequest)); @@ -285,7 +286,7 @@ class FileSystemDirURLRequestJobTest : public testing::Test { } // Put the message loop at the top, so that it's the last thing deleted. - // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent + // Delete all task runner objects before the MessageLoop, to help prevent // leaks caused by tasks posted during shutdown. base::MessageLoopForIO message_loop_; diff --git a/content/browser/fileapi/file_system_operation_impl_unittest.cc b/content/browser/fileapi/file_system_operation_impl_unittest.cc index 6f84204..e4a1e6c 100644 --- a/content/browser/fileapi/file_system_operation_impl_unittest.cc +++ b/content/browser/fileapi/file_system_operation_impl_unittest.cc @@ -12,6 +12,7 @@ #include "base/memory/weak_ptr.h" #include "base/run_loop.h" #include "base/strings/stringprintf.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/fileapi/mock_file_change_observer.h" #include "content/browser/fileapi/mock_file_update_observer.h" #include "content/browser/quota/mock_quota_manager.h" @@ -57,13 +58,12 @@ class FileSystemOperationImplTest base::FilePath base_dir = base_.path().AppendASCII("filesystem"); quota_manager_ = - new MockQuotaManager(false /* is_incognito */, - base_dir, - base::MessageLoopProxy::current().get(), - base::MessageLoopProxy::current().get(), - NULL /* special storage policy */); + new MockQuotaManager(false /* is_incognito */, base_dir, + base::ThreadTaskRunnerHandle::Get().get(), + base::ThreadTaskRunnerHandle::Get().get(), + NULL /* special storage policy */); quota_manager_proxy_ = new MockQuotaManagerProxy( - quota_manager(), base::MessageLoopProxy::current().get()); + quota_manager(), base::ThreadTaskRunnerHandle::Get().get()); sandbox_file_system_.SetUp(base_dir, quota_manager_proxy_.get()); sandbox_file_system_.AddFileChangeObserver(&change_observer_); sandbox_file_system_.AddFileUpdateObserver(&update_observer_); diff --git a/content/browser/fileapi/file_system_operation_impl_write_unittest.cc b/content/browser/fileapi/file_system_operation_impl_write_unittest.cc index ca324ae..ae3277f 100644 --- a/content/browser/fileapi/file_system_operation_impl_write_unittest.cc +++ b/content/browser/fileapi/file_system_operation_impl_write_unittest.cc @@ -7,8 +7,8 @@ #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/fileapi/mock_file_change_observer.h" #include "content/browser/quota/mock_quota_manager.h" #include "content/public/test/mock_blob_url_request_context.h" @@ -66,11 +66,10 @@ class FileSystemOperationImplWriteTest ASSERT_TRUE(dir_.CreateUniqueTempDir()); quota_manager_ = - new MockQuotaManager(false /* is_incognito */, - dir_.path(), - base::MessageLoopProxy::current().get(), - base::MessageLoopProxy::current().get(), - NULL /* special storage policy */); + new MockQuotaManager(false /* is_incognito */, dir_.path(), + base::ThreadTaskRunnerHandle::Get().get(), + base::ThreadTaskRunnerHandle::Get().get(), + NULL /* special storage policy */); virtual_path_ = base::FilePath(FILE_PATH_LITERAL("temporary file")); file_system_context_ = CreateFileSystemContextForTesting( diff --git a/content/browser/fileapi/file_system_quota_client_unittest.cc b/content/browser/fileapi/file_system_quota_client_unittest.cc index 5ab33e1..b3333a0 100644 --- a/content/browser/fileapi/file_system_quota_client_unittest.cc +++ b/content/browser/fileapi/file_system_quota_client_unittest.cc @@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" #include "content/public/test/async_file_test_helper.h" #include "content/public/test/test_file_system_context.h" diff --git a/content/browser/fileapi/file_system_url_request_job_unittest.cc b/content/browser/fileapi/file_system_url_request_job_unittest.cc index 5e932f2..dca1c53 100644 --- a/content/browser/fileapi/file_system_url_request_job_unittest.cc +++ b/content/browser/fileapi/file_system_url_request_job_unittest.cc @@ -11,15 +11,15 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/format_macros.h" +#include "base/location.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/rand_util.h" #include "base/run_loop.h" #include "base/strings/string_piece.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/public/test/async_file_test_helper.h" #include "content/public/test/test_file_system_backend.h" #include "content/public/test/test_file_system_context.h" @@ -160,7 +160,7 @@ class FileSystemURLRequestJobTest : public testing::Test { ScopedVector<storage::FileSystemBackend> additional_providers; additional_providers.push_back(new TestFileSystemBackend( - base::MessageLoopProxy::current().get(), mnt_point)); + base::ThreadTaskRunnerHandle::Get().get(), mnt_point)); std::vector<storage::URLRequestAutoMountHandler> handlers; handlers.push_back(base::Bind(&TestAutoMountForURLRequest)); diff --git a/content/browser/fileapi/file_system_usage_cache_unittest.cc b/content/browser/fileapi/file_system_usage_cache_unittest.cc index 13f1d65..f67485c 100644 --- a/content/browser/fileapi/file_system_usage_cache_unittest.cc +++ b/content/browser/fileapi/file_system_usage_cache_unittest.cc @@ -8,6 +8,7 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/message_loop/message_loop.h" +#include "base/thread_task_runner_handle.h" #include "testing/gtest/include/gtest/gtest.h" using storage::FileSystemUsageCache; @@ -17,7 +18,7 @@ namespace content { class FileSystemUsageCacheTest : public testing::Test { public: FileSystemUsageCacheTest() - : usage_cache_(base::MessageLoopProxy::current().get()) {} + : usage_cache_(base::ThreadTaskRunnerHandle::Get().get()) {} void SetUp() override { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); } diff --git a/content/browser/fileapi/file_writer_delegate_unittest.cc b/content/browser/fileapi/file_writer_delegate_unittest.cc index 1aacacc..af60d3f 100644 --- a/content/browser/fileapi/file_writer_delegate_unittest.cc +++ b/content/browser/fileapi/file_writer_delegate_unittest.cc @@ -9,8 +9,10 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/public/test/async_file_test_helper.h" #include "content/public/test/test_file_system_context.h" #include "net/base/io_buffer.h" @@ -96,8 +98,8 @@ class FileWriterDelegateTest : public PlatformTest { int64 GetFileSizeOnDisk(const char* test_file_path) { // There might be in-flight flush/write. - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&base::DoNothing)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(&base::DoNothing)); base::RunLoop().RunUntilIdle(); FileSystemURL url = GetFileSystemURL(test_file_path); @@ -177,7 +179,7 @@ class FileWriterDelegateTestJob : public net::URLRequestJob { } void Start() override { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&FileWriterDelegateTestJob::NotifyHeadersComplete, this)); } diff --git a/content/browser/fileapi/local_file_stream_reader_unittest.cc b/content/browser/fileapi/local_file_stream_reader_unittest.cc index 5e17165..d8e30ce 100644 --- a/content/browser/fileapi/local_file_stream_reader_unittest.cc +++ b/content/browser/fileapi/local_file_stream_reader_unittest.cc @@ -10,8 +10,10 @@ #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" +#include "base/location.h" #include "base/memory/scoped_ptr.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/threading/thread.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" @@ -101,8 +103,8 @@ class LocalFileStreamReaderTest : public testing::Test { new_modified_time)); } - base::MessageLoopProxy* file_task_runner() const { - return file_thread_.message_loop_proxy().get(); + base::SingleThreadTaskRunner* file_task_runner() const { + return file_thread_.task_runner().get(); } base::FilePath test_dir() const { return dir_.path(); } diff --git a/content/browser/fileapi/local_file_stream_writer_unittest.cc b/content/browser/fileapi/local_file_stream_writer_unittest.cc index 48f5560..9e05310 100644 --- a/content/browser/fileapi/local_file_stream_writer_unittest.cc +++ b/content/browser/fileapi/local_file_stream_writer_unittest.cc @@ -11,8 +11,8 @@ #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/threading/thread.h" #include "net/base/io_buffer.h" #include "net/base/test_completion_callback.h" @@ -77,8 +77,8 @@ class LocalFileStreamWriterTest : public testing::Test { return path; } - base::MessageLoopProxy* file_task_runner() const { - return file_thread_.message_loop_proxy().get(); + base::SingleThreadTaskRunner* file_task_runner() const { + return file_thread_.task_runner().get(); } LocalFileStreamWriter* CreateWriter(const base::FilePath& path, diff --git a/content/browser/fileapi/local_file_util_unittest.cc b/content/browser/fileapi/local_file_util_unittest.cc index bf2f2f8..a0c9615 100644 --- a/content/browser/fileapi/local_file_util_unittest.cc +++ b/content/browser/fileapi/local_file_util_unittest.cc @@ -8,7 +8,6 @@ #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" #include "base/strings/sys_string_conversions.h" #include "base/strings/utf_string_conversions.h" diff --git a/content/browser/fileapi/mock_file_change_observer.cc b/content/browser/fileapi/mock_file_change_observer.cc index f6a86e9..6677607 100644 --- a/content/browser/fileapi/mock_file_change_observer.cc +++ b/content/browser/fileapi/mock_file_change_observer.cc @@ -4,6 +4,8 @@ #include "content/browser/fileapi/mock_file_change_observer.h" +#include "base/thread_task_runner_handle.h" + namespace storage { MockFileChangeObserver::MockFileChangeObserver() @@ -20,7 +22,7 @@ MockFileChangeObserver::~MockFileChangeObserver() {} ChangeObserverList MockFileChangeObserver::CreateList( MockFileChangeObserver* observer) { ChangeObserverList list; - return list.AddObserver(observer, base::MessageLoopProxy::current().get()); + return list.AddObserver(observer, base::ThreadTaskRunnerHandle::Get().get()); } void MockFileChangeObserver::OnCreateFile(const FileSystemURL& url) { diff --git a/content/browser/fileapi/obfuscated_file_util_unittest.cc b/content/browser/fileapi/obfuscated_file_util_unittest.cc index 7abaf7e..06638ff 100644 --- a/content/browser/fileapi/obfuscated_file_util_unittest.cc +++ b/content/browser/fileapi/obfuscated_file_util_unittest.cc @@ -13,6 +13,7 @@ #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" #include "base/run_loop.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/fileapi/mock_file_change_observer.h" #include "content/public/test/async_file_test_helper.h" #include "content/public/test/mock_special_storage_policy.h" @@ -156,12 +157,10 @@ class ObfuscatedFileUtilTest : public testing::Test { storage_policy_ = new MockSpecialStoragePolicy(); - quota_manager_ = - new storage::QuotaManager(false /* is_incognito */, - data_dir_.path(), - base::MessageLoopProxy::current().get(), - base::MessageLoopProxy::current().get(), - storage_policy_.get()); + quota_manager_ = new storage::QuotaManager( + false /* is_incognito */, data_dir_.path(), + base::ThreadTaskRunnerHandle::Get().get(), + base::ThreadTaskRunnerHandle::Get().get(), storage_policy_.get()); // Every time we create a new sandbox_file_system helper, // it creates another context, which creates another path manager, @@ -231,10 +230,9 @@ class ObfuscatedFileUtilTest : public testing::Test { scoped_ptr<ObfuscatedFileUtil> CreateObfuscatedFileUtil( storage::SpecialStoragePolicy* storage_policy) { - return scoped_ptr<ObfuscatedFileUtil>( - ObfuscatedFileUtil::CreateForTesting( - storage_policy, data_dir_path(), NULL, - base::MessageLoopProxy::current().get())); + return scoped_ptr<ObfuscatedFileUtil>(ObfuscatedFileUtil::CreateForTesting( + storage_policy, data_dir_path(), NULL, + base::ThreadTaskRunnerHandle::Get().get())); } ObfuscatedFileUtil* ofu() { diff --git a/content/browser/fileapi/plugin_private_file_system_backend_unittest.cc b/content/browser/fileapi/plugin_private_file_system_backend_unittest.cc index ef88fed..8c5e45d 100644 --- a/content/browser/fileapi/plugin_private_file_system_backend_unittest.cc +++ b/content/browser/fileapi/plugin_private_file_system_backend_unittest.cc @@ -7,7 +7,6 @@ #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" #include "content/public/test/async_file_test_helper.h" #include "content/public/test/test_file_system_context.h" diff --git a/content/browser/fileapi/recursive_operation_delegate_unittest.cc b/content/browser/fileapi/recursive_operation_delegate_unittest.cc index 3885384..54b9626 100644 --- a/content/browser/fileapi/recursive_operation_delegate_unittest.cc +++ b/content/browser/fileapi/recursive_operation_delegate_unittest.cc @@ -10,9 +10,10 @@ #include "base/bind.h" #include "base/callback.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/public/test/sandbox_file_system_test_helper.h" #include "storage/browser/fileapi/file_system_file_util.h" #include "storage/browser/fileapi/file_system_operation.h" @@ -115,7 +116,7 @@ void ReportStatus(base::File::Error* out_error, void CallCancelLater(storage::RecursiveOperationDelegate* operation, int counter) { if (counter > 0) { - base::MessageLoopProxy::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&CallCancelLater, base::Unretained(operation), counter - 1)); return; diff --git a/content/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc b/content/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc index 1b5b19b..fd25aa7f 100644 --- a/content/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc +++ b/content/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc @@ -8,8 +8,7 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/thread_task_runner_handle.h" #include "content/public/test/test_file_system_options.h" #include "storage/browser/fileapi/file_system_url.h" #include "testing/gtest/include/gtest/gtest.h" @@ -37,10 +36,8 @@ class SandboxFileSystemBackendDelegateTest : public testing::Test { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); delegate_.reset(new storage::SandboxFileSystemBackendDelegate( NULL /* quota_manager_proxy */, - base::MessageLoopProxy::current().get(), - data_dir_.path(), - NULL /* special_storage_policy */, - CreateAllowFileAccessOptions())); + base::ThreadTaskRunnerHandle::Get().get(), data_dir_.path(), + NULL /* special_storage_policy */, CreateAllowFileAccessOptions())); } bool IsAccessValid(const FileSystemURL& url) const { diff --git a/content/browser/fileapi/sandbox_file_system_backend_unittest.cc b/content/browser/fileapi/sandbox_file_system_backend_unittest.cc index efa7259..38630b8 100644 --- a/content/browser/fileapi/sandbox_file_system_backend_unittest.cc +++ b/content/browser/fileapi/sandbox_file_system_backend_unittest.cc @@ -10,8 +10,8 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" +#include "base/thread_task_runner_handle.h" #include "content/public/test/test_file_system_options.h" #include "storage/browser/fileapi/file_system_backend.h" #include "storage/browser/fileapi/file_system_url.h" @@ -79,10 +79,8 @@ class SandboxFileSystemBackendTest : public testing::Test { void SetUpNewDelegate(const storage::FileSystemOptions& options) { delegate_.reset(new SandboxFileSystemBackendDelegate( NULL /* quota_manager_proxy */, - base::MessageLoopProxy::current().get(), - data_dir_.path(), - NULL /* special_storage_policy */, - options)); + base::ThreadTaskRunnerHandle::Get().get(), data_dir_.path(), + NULL /* special_storage_policy */, options)); } void SetUpNewBackend(const storage::FileSystemOptions& options) { diff --git a/content/browser/fileapi/timed_task_helper_unittest.cc b/content/browser/fileapi/timed_task_helper_unittest.cc index 5a6ac8d..1bdc25d 100644 --- a/content/browser/fileapi/timed_task_helper_unittest.cc +++ b/content/browser/fileapi/timed_task_helper_unittest.cc @@ -6,8 +6,8 @@ #include "base/bind.h" #include "base/location.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "storage/browser/fileapi/timed_task_helper.h" #include "testing/gtest/include/gtest/gtest.h" @@ -21,7 +21,8 @@ namespace { class Embedder { public: Embedder() - : timer_(base::MessageLoopProxy::current().get()), timer_fired_(false) {} + : timer_(base::ThreadTaskRunnerHandle::Get().get()), + timer_fired_(false) {} void OnTimerFired() { timer_fired_ = true; diff --git a/content/browser/frame_host/interstitial_page_impl.cc b/content/browser/frame_host/interstitial_page_impl.cc index 6e32401..88d720f 100644 --- a/content/browser/frame_host/interstitial_page_impl.cc +++ b/content/browser/frame_host/interstitial_page_impl.cc @@ -8,9 +8,11 @@ #include "base/bind.h" #include "base/compiler_specific.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "content/browser/dom_storage/dom_storage_context_wrapper.h" #include "content/browser/dom_storage/session_storage_namespace_impl.h" @@ -289,10 +291,9 @@ void InterstitialPageImpl::Hide() { // Delete this and call Shutdown on the RVH asynchronously, as we may have // been called from a RVH delegate method, and we can't delete the RVH out // from under itself. - base::MessageLoop::current()->PostNonNestableTask( - FROM_HERE, - base::Bind(&InterstitialPageImpl::Shutdown, - weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( + FROM_HERE, base::Bind(&InterstitialPageImpl::Shutdown, + weak_ptr_factory_.GetWeakPtr())); render_view_host_ = NULL; frame_tree_.root()->ResetForNewProcess(); controller_->delegate()->DetachInterstitialPage(); diff --git a/content/browser/frame_host/render_frame_host_manager_browsertest.cc b/content/browser/frame_host/render_frame_host_manager_browsertest.cc index 9567394..6072302 100644 --- a/content/browser/frame_host/render_frame_host_manager_browsertest.cc +++ b/content/browser/frame_host/render_frame_host_manager_browsertest.cc @@ -6,9 +6,12 @@ #include "base/command_line.h" #include "base/json/json_reader.h" +#include "base/location.h" #include "base/memory/ref_counted.h" #include "base/path_service.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" #include "content/browser/child_process_security_policy_impl.h" #include "content/browser/renderer_host/render_view_host_impl.h" @@ -1766,7 +1769,7 @@ class RenderFrameHostDestructionObserver : public WebContentsObserver { } if (deleted_ && message_loop_runner_->loop_running()) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, message_loop_runner_->QuitClosure()); } } diff --git a/content/browser/gamepad/gamepad_provider.cc b/content/browser/gamepad/gamepad_provider.cc index e16339c..eef9001 100644 --- a/content/browser/gamepad/gamepad_provider.cc +++ b/content/browser/gamepad/gamepad_provider.cc @@ -7,10 +7,11 @@ #include <vector> #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "base/third_party/dynamic_annotations/dynamic_annotations.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" #include "content/browser/gamepad/gamepad_data_fetcher.h" @@ -29,9 +30,8 @@ namespace content { GamepadProvider::ClosureAndThread::ClosureAndThread( const base::Closure& c, - const scoped_refptr<base::MessageLoopProxy>& m) - : closure(c), - message_loop(m) { + const scoped_refptr<base::SingleThreadTaskRunner>& m) + : closure(c), task_runner(m) { } GamepadProvider::ClosureAndThread::~ClosureAndThread() { @@ -83,7 +83,7 @@ void GamepadProvider::Pause() { is_paused_ = true; } base::MessageLoop* polling_loop = polling_thread_->message_loop(); - polling_loop->PostTask( + polling_loop->task_runner()->PostTask( FROM_HERE, base::Bind(&GamepadProvider::SendPauseHint, Unretained(this), true)); } @@ -97,18 +97,18 @@ void GamepadProvider::Resume() { } base::MessageLoop* polling_loop = polling_thread_->message_loop(); - polling_loop->PostTask( + polling_loop->task_runner()->PostTask( FROM_HERE, base::Bind(&GamepadProvider::SendPauseHint, Unretained(this), false)); - polling_loop->PostTask( + polling_loop->task_runner()->PostTask( FROM_HERE, base::Bind(&GamepadProvider::ScheduleDoPoll, Unretained(this))); } void GamepadProvider::RegisterForUserGesture(const base::Closure& closure) { base::AutoLock lock(user_gesture_lock_); - user_gesture_observers_.push_back(ClosureAndThread( - closure, base::MessageLoop::current()->message_loop_proxy())); + user_gesture_observers_.push_back( + ClosureAndThread(closure, base::MessageLoop::current()->task_runner())); } void GamepadProvider::OnDevicesChanged(base::SystemMonitor::DeviceType type) { @@ -144,11 +144,9 @@ void GamepadProvider::Initialize(scoped_ptr<GamepadDataFetcher> fetcher) { #endif polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0)); - polling_thread_->message_loop()->PostTask( - FROM_HERE, - base::Bind(&GamepadProvider::DoInitializePollingThread, - base::Unretained(this), - base::Passed(&fetcher))); + polling_thread_->task_runner()->PostTask( + FROM_HERE, base::Bind(&GamepadProvider::DoInitializePollingThread, + base::Unretained(this), base::Passed(&fetcher))); } void GamepadProvider::DoInitializePollingThread( @@ -264,9 +262,8 @@ void GamepadProvider::ScheduleDoPoll() { return; } - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&GamepadProvider::DoPoll, Unretained(this)), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&GamepadProvider::DoPoll, Unretained(this)), base::TimeDelta::FromMilliseconds(kDesiredSamplingIntervalMs)); have_scheduled_do_poll_ = true; } @@ -313,8 +310,8 @@ void GamepadProvider::CheckForUserGesture() { if (GamepadsHaveUserGesture(pads)) { ever_had_user_gesture_ = true; for (size_t i = 0; i < user_gesture_observers_.size(); i++) { - user_gesture_observers_[i].message_loop->PostTask(FROM_HERE, - user_gesture_observers_[i].closure); + user_gesture_observers_[i].task_runner->PostTask( + FROM_HERE, user_gesture_observers_[i].closure); } user_gesture_observers_.clear(); } diff --git a/content/browser/gamepad/gamepad_provider.h b/content/browser/gamepad/gamepad_provider.h index a81061a..ce9c11a 100644 --- a/content/browser/gamepad/gamepad_provider.h +++ b/content/browser/gamepad/gamepad_provider.h @@ -13,14 +13,13 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/synchronization/lock.h" #include "base/system_monitor/system_monitor.h" #include "content/common/content_export.h" #include "third_party/WebKit/public/platform/WebGamepads.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; class Thread; } @@ -105,11 +104,11 @@ class CONTENT_EXPORT GamepadProvider : base::Lock user_gesture_lock_; struct ClosureAndThread { ClosureAndThread(const base::Closure& c, - const scoped_refptr<base::MessageLoopProxy>& m); + const scoped_refptr<base::SingleThreadTaskRunner>& m); ~ClosureAndThread(); base::Closure closure; - scoped_refptr<base::MessageLoopProxy> message_loop; + scoped_refptr<base::SingleThreadTaskRunner> task_runner; }; typedef std::vector<ClosureAndThread> UserGestureObserverVector; UserGestureObserverVector user_gesture_observers_; diff --git a/content/browser/geofencing/geofencing_service.cc b/content/browser/geofencing/geofencing_service.cc index 11df952..c9ea83d 100644 --- a/content/browser/geofencing/geofencing_service.cc +++ b/content/browser/geofencing/geofencing_service.cc @@ -4,8 +4,10 @@ #include "content/browser/geofencing/geofencing_service.h" +#include "base/location.h" #include "base/memory/singleton.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/geofencing/geofencing_provider.h" #include "content/browser/geofencing/geofencing_registration_delegate.h" #include "content/public/browser/browser_thread.h" @@ -17,7 +19,7 @@ namespace { void RunSoon(const base::Closure& callback) { if (!callback.is_null()) - base::MessageLoop::current()->PostTask(FROM_HERE, callback); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); } } // namespace diff --git a/content/browser/geofencing/mock_geofencing_service.cc b/content/browser/geofencing/mock_geofencing_service.cc index e53b8c7..c3a1f27 100644 --- a/content/browser/geofencing/mock_geofencing_service.cc +++ b/content/browser/geofencing/mock_geofencing_service.cc @@ -10,7 +10,9 @@ #include <cmath> #include "base/bind.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/geofencing/geofencing_registration_delegate.h" #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h" @@ -21,7 +23,7 @@ namespace { void RegisterRegionResult(GeofencingRegistrationDelegate* delegate, int64 geofencing_registration_id, GeofencingStatus status) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&GeofencingRegistrationDelegate::RegistrationFinished, base::Unretained(delegate), geofencing_registration_id, @@ -109,7 +111,7 @@ int64 MockGeofencingService::RegisterRegion( PositionInRegion(last_latitude_, last_longitude_, region); RegisterRegionResult(delegate, id, GEOFENCING_STATUS_OK); if (registration.is_inside) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&GeofencingRegistrationDelegate::RegionEntered, base::Unretained(delegate), id)); } diff --git a/content/browser/geolocation/fake_access_token_store.cc b/content/browser/geolocation/fake_access_token_store.cc index 0e5fe40..9e8704a 100644 --- a/content/browser/geolocation/fake_access_token_store.cc +++ b/content/browser/geolocation/fake_access_token_store.cc @@ -7,16 +7,14 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/thread_task_runner_handle.h" -using base::MessageLoopProxy; using testing::_; using testing::Invoke; namespace content { -FakeAccessTokenStore::FakeAccessTokenStore() - : originating_message_loop_(NULL) { +FakeAccessTokenStore::FakeAccessTokenStore() : originating_task_runner_(NULL) { ON_CALL(*this, LoadAccessTokens(_)) .WillByDefault(Invoke(this, &FakeAccessTokenStore::DefaultLoadAccessTokens)); @@ -26,9 +24,9 @@ FakeAccessTokenStore::FakeAccessTokenStore() } void FakeAccessTokenStore::NotifyDelegateTokensLoaded() { - DCHECK(originating_message_loop_); - if (!originating_message_loop_->BelongsToCurrentThread()) { - originating_message_loop_->PostTask( + DCHECK(originating_task_runner_); + if (!originating_task_runner_->BelongsToCurrentThread()) { + originating_task_runner_->PostTask( FROM_HERE, base::Bind(&FakeAccessTokenStore::NotifyDelegateTokensLoaded, this)); return; @@ -40,7 +38,7 @@ void FakeAccessTokenStore::NotifyDelegateTokensLoaded() { void FakeAccessTokenStore::DefaultLoadAccessTokens( const LoadAccessTokensCallbackType& callback) { - originating_message_loop_ = MessageLoopProxy::current().get(); + originating_task_runner_ = base::ThreadTaskRunnerHandle::Get().get(); callback_ = callback; } diff --git a/content/browser/geolocation/fake_access_token_store.h b/content/browser/geolocation/fake_access_token_store.h index 30a0185..423b317 100644 --- a/content/browser/geolocation/fake_access_token_store.h +++ b/content/browser/geolocation/fake_access_token_store.h @@ -5,7 +5,7 @@ #ifndef CONTENT_BROWSER_GEOLOCATION_FAKE_ACCESS_TOKEN_STORE_H_ #define CONTENT_BROWSER_GEOLOCATION_FAKE_ACCESS_TOKEN_STORE_H_ -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "content/public/browser/access_token_store.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -42,7 +42,7 @@ class FakeAccessTokenStore : public AccessTokenStore { // In some tests, NotifyDelegateTokensLoaded() is called on a thread // other than the originating thread, in which case we must post // back to it. - base::MessageLoopProxy* originating_message_loop_; + base::SingleThreadTaskRunner* originating_task_runner_; DISALLOW_COPY_AND_ASSIGN(FakeAccessTokenStore); }; diff --git a/content/browser/geolocation/geolocation_provider_impl.cc b/content/browser/geolocation/geolocation_provider_impl.cc index 7375d57..4c32269 100644 --- a/content/browser/geolocation/geolocation_provider_impl.cc +++ b/content/browser/geolocation/geolocation_provider_impl.cc @@ -10,7 +10,7 @@ #include "base/location.h" #include "base/logging.h" #include "base/memory/singleton.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "content/browser/geolocation/location_arbitrator_impl.h" #include "content/public/browser/browser_thread.h" @@ -121,7 +121,7 @@ void GeolocationProviderImpl::OnClientsChanged() { use_high_accuracy); } - message_loop()->PostTask(FROM_HERE, task); + task_runner()->PostTask(FROM_HERE, task); } void GeolocationProviderImpl::StopProviders() { @@ -139,7 +139,7 @@ void GeolocationProviderImpl::StartProviders(bool use_high_accuracy) { void GeolocationProviderImpl::InformProvidersPermissionGranted() { DCHECK(IsRunning()); if (!OnGeolocationThread()) { - message_loop()->PostTask( + task_runner()->PostTask( FROM_HERE, base::Bind(&GeolocationProviderImpl::InformProvidersPermissionGranted, base::Unretained(this))); diff --git a/content/browser/geolocation/geolocation_provider_impl_unittest.cc b/content/browser/geolocation/geolocation_provider_impl_unittest.cc index 685818b..3ba4dae 100644 --- a/content/browser/geolocation/geolocation_provider_impl_unittest.cc +++ b/content/browser/geolocation/geolocation_provider_impl_unittest.cc @@ -4,9 +4,10 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/location.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string16.h" #include "base/time/time.h" #include "content/browser/geolocation/geolocation_provider_impl.h" @@ -140,11 +141,9 @@ bool GeolocationProviderTest::ProvidersStarted() { DCHECK(provider_->IsRunning()); DCHECK(base::MessageLoop::current() == &message_loop_); bool started; - provider_->message_loop_proxy()->PostTaskAndReply( - FROM_HERE, - base::Bind(&GeolocationProviderTest::GetProvidersStarted, - base::Unretained(this), - &started), + provider_->task_runner()->PostTaskAndReply( + FROM_HERE, base::Bind(&GeolocationProviderTest::GetProvidersStarted, + base::Unretained(this), &started), base::MessageLoop::QuitClosure()); message_loop_.Run(); return started; @@ -158,11 +157,9 @@ void GeolocationProviderTest::GetProvidersStarted(bool* started) { void GeolocationProviderTest::SendMockLocation(const Geoposition& position) { DCHECK(provider_->IsRunning()); DCHECK(base::MessageLoop::current() == &message_loop_); - provider_->message_loop() - ->PostTask(FROM_HERE, - base::Bind(&GeolocationProviderImpl::OnLocationUpdate, - base::Unretained(provider_.get()), - position)); + provider_->task_runner()->PostTask( + FROM_HERE, base::Bind(&GeolocationProviderImpl::OnLocationUpdate, + base::Unretained(provider_.get()), position)); } // Regression test for http://crbug.com/59377 diff --git a/content/browser/geolocation/location_api_adapter_android.cc b/content/browser/geolocation/location_api_adapter_android.cc index 84cfd10..a78cae2 100644 --- a/content/browser/geolocation/location_api_adapter_android.cc +++ b/content/browser/geolocation/location_api_adapter_android.cc @@ -8,6 +8,7 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "base/location.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/geolocation/location_provider_android.h" #include "jni/LocationProviderAdapter_jni.h" @@ -41,7 +42,7 @@ AndroidLocationApiAdapter::AndroidLocationApiAdapter() AndroidLocationApiAdapter::~AndroidLocationApiAdapter() { CHECK(!location_provider_); - CHECK(!message_loop_.get()); + CHECK(!task_runner_.get()); CHECK(java_location_provider_android_object_.is_null()); } @@ -54,14 +55,14 @@ bool AndroidLocationApiAdapter::Start( CreateJavaObject(env); { base::AutoLock lock(lock_); - CHECK(!message_loop_.get()); - message_loop_ = base::MessageLoopProxy::current(); + CHECK(!task_runner_.get()); + task_runner_ = base::ThreadTaskRunnerHandle::Get(); } } // At this point we should have all our pre-conditions ready, and they'd only // change in Stop() which must be called on the same thread as here. CHECK(location_provider_); - CHECK(message_loop_.get()); + CHECK(task_runner_.get()); CHECK(!java_location_provider_android_object_.is_null()); // We'll start receiving notifications from java in the main thread looper // until Stop() is called. @@ -71,14 +72,14 @@ bool AndroidLocationApiAdapter::Start( void AndroidLocationApiAdapter::Stop() { if (!location_provider_) { - CHECK(!message_loop_.get()); + CHECK(!task_runner_.get()); CHECK(java_location_provider_android_object_.is_null()); return; } { base::AutoLock lock(lock_); - message_loop_ = NULL; + task_runner_ = NULL; } location_provider_ = NULL; @@ -94,7 +95,7 @@ void AndroidLocationApiAdapter::NotifyProviderNewGeoposition( const Geoposition& geoposition) { // Called on the geolocation thread, safe to access location_provider_ here. if (GetInstance()->location_provider_) { - CHECK(GetInstance()->message_loop_->BelongsToCurrentThread()); + CHECK(GetInstance()->task_runner_->BelongsToCurrentThread()); GetInstance()->location_provider_->NotifyNewGeoposition(geoposition); } } @@ -152,13 +153,12 @@ void AndroidLocationApiAdapter::CreateJavaObject(JNIEnv* env) { void AndroidLocationApiAdapter::OnNewGeopositionInternal( const Geoposition& geoposition) { base::AutoLock lock(lock_); - if (!message_loop_.get()) + if (!task_runner_.get()) return; - message_loop_->PostTask( + task_runner_->PostTask( FROM_HERE, - base::Bind( - &AndroidLocationApiAdapter::NotifyProviderNewGeoposition, - geoposition)); + base::Bind(&AndroidLocationApiAdapter::NotifyProviderNewGeoposition, + geoposition)); } } // namespace content diff --git a/content/browser/geolocation/location_api_adapter_android.h b/content/browser/geolocation/location_api_adapter_android.h index d1d2fa5..8cba148 100644 --- a/content/browser/geolocation/location_api_adapter_android.h +++ b/content/browser/geolocation/location_api_adapter_android.h @@ -9,9 +9,12 @@ #include "base/android/scoped_java_ref.h" #include "base/memory/ref_counted.h" #include "base/memory/singleton.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/synchronization/lock.h" +namespace base { +class SingleThreadTaskRunner; +} + namespace content { class LocationProviderAndroid; struct Geoposition; @@ -73,7 +76,7 @@ class AndroidLocationApiAdapter { // Guards against the following member which is accessed on Geolocation // thread and the JNI main thread looper. base::Lock lock_; - scoped_refptr<base::MessageLoopProxy> message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; }; } // namespace content diff --git a/content/browser/geolocation/mock_location_provider.cc b/content/browser/geolocation/mock_location_provider.cc index 2953ba1..0bb760f 100644 --- a/content/browser/geolocation/mock_location_provider.cc +++ b/content/browser/geolocation/mock_location_provider.cc @@ -10,10 +10,10 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/compiler_specific.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/thread_task_runner_handle.h" namespace content { MockLocationProvider* MockLocationProvider::instance_ = NULL; @@ -22,7 +22,7 @@ MockLocationProvider::MockLocationProvider(MockLocationProvider** self_ref) : state_(STOPPED), is_permission_granted_(false), self_ref_(self_ref), - provider_loop_(base::MessageLoopProxy::current()) { + provider_task_runner_(base::ThreadTaskRunnerHandle::Get()) { CHECK(self_ref_); CHECK(*self_ref_ == NULL); *self_ref_ = this; @@ -34,16 +34,15 @@ MockLocationProvider::~MockLocationProvider() { } void MockLocationProvider::HandlePositionChanged(const Geoposition& position) { - if (provider_loop_->BelongsToCurrentThread()) { + if (provider_task_runner_->BelongsToCurrentThread()) { // The location arbitrator unit tests rely on this method running // synchronously. position_ = position; NotifyCallback(position_); } else { - provider_loop_->PostTask( - FROM_HERE, - base::Bind(&MockLocationProvider::HandlePositionChanged, - base::Unretained(this), position)); + provider_task_runner_->PostTask( + FROM_HERE, base::Bind(&MockLocationProvider::HandlePositionChanged, + base::Unretained(this), position)); } } @@ -104,11 +103,9 @@ class AutoMockLocationProvider : public MockLocationProvider { void UpdateListenersIfNeeded() { if (!listeners_updated_) { listeners_updated_ = true; - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&MockLocationProvider::HandlePositionChanged, - weak_factory_.GetWeakPtr(), - position_)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&MockLocationProvider::HandlePositionChanged, + weak_factory_.GetWeakPtr(), position_)); } } diff --git a/content/browser/geolocation/mock_location_provider.h b/content/browser/geolocation/mock_location_provider.h index 882a447..bedd2a4 100644 --- a/content/browser/geolocation/mock_location_provider.h +++ b/content/browser/geolocation/mock_location_provider.h @@ -8,6 +8,7 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" +#include "base/single_thread_task_runner.h" #include "base/threading/thread.h" #include "content/browser/geolocation/location_provider_base.h" #include "content/public/common/geoposition.h" @@ -36,7 +37,7 @@ class MockLocationProvider : public LocationProviderBase { bool is_permission_granted_; MockLocationProvider** self_ref_; - scoped_refptr<base::MessageLoopProxy> provider_loop_; + scoped_refptr<base::SingleThreadTaskRunner> provider_task_runner_; // Set when an instance of the mock is created via a factory function. static MockLocationProvider* instance_; diff --git a/content/browser/geolocation/network_location_provider.cc b/content/browser/geolocation/network_location_provider.cc index 13a6504..5db43fa 100644 --- a/content/browser/geolocation/network_location_provider.cc +++ b/content/browser/geolocation/network_location_provider.cc @@ -5,7 +5,10 @@ #include "content/browser/geolocation/network_location_provider.h" #include "base/bind.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/public/browser/access_token_store.h" @@ -199,10 +202,9 @@ bool NetworkLocationProvider::StartProvider(bool high_accuracy) { wifi_data_provider_manager_ = WifiDataProviderManager::Register(&wifi_data_update_callback_); - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&NetworkLocationProvider::RequestPosition, - weak_factory_.GetWeakPtr()), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&NetworkLocationProvider::RequestPosition, + weak_factory_.GetWeakPtr()), base::TimeDelta::FromSeconds(kDataCompleteWaitSeconds)); // Get the wifi data. is_wifi_data_complete_ = wifi_data_provider_manager_->GetData(&wifi_data_); diff --git a/content/browser/geolocation/wifi_data_provider.cc b/content/browser/geolocation/wifi_data_provider.cc index cd739e7..71b78c4 100644 --- a/content/browser/geolocation/wifi_data_provider.cc +++ b/content/browser/geolocation/wifi_data_provider.cc @@ -27,8 +27,8 @@ bool WifiDataProvider::has_callbacks() const { } void WifiDataProvider::RunCallbacks() { - client_loop_->PostTask(FROM_HERE, - base::Bind(&WifiDataProvider::DoRunCallbacks, this)); + client_loop_->task_runner()->PostTask( + FROM_HERE, base::Bind(&WifiDataProvider::DoRunCallbacks, this)); } bool WifiDataProvider::CalledOnClientThread() const { diff --git a/content/browser/geolocation/wifi_data_provider_common.cc b/content/browser/geolocation/wifi_data_provider_common.cc index 388a17e..7bac7ab 100644 --- a/content/browser/geolocation/wifi_data_provider_common.cc +++ b/content/browser/geolocation/wifi_data_provider_common.cc @@ -5,6 +5,8 @@ #include "content/browser/geolocation/wifi_data_provider_common.h" #include "base/bind.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -80,10 +82,9 @@ void WifiDataProviderCommon::DoWifiScanTask() { } void WifiDataProviderCommon::ScheduleNextScan(int interval) { - client_loop()->PostDelayedTask( - FROM_HERE, - base::Bind(&WifiDataProviderCommon::DoWifiScanTask, - weak_factory_.GetWeakPtr()), + client_loop()->task_runner()->PostDelayedTask( + FROM_HERE, base::Bind(&WifiDataProviderCommon::DoWifiScanTask, + weak_factory_.GetWeakPtr()), base::TimeDelta::FromMilliseconds(interval)); } diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.cc b/content/browser/gpu/browser_gpu_channel_host_factory.cc index 4019ccb..d14dd4c 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.cc +++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc @@ -7,8 +7,11 @@ #include <set> #include "base/bind.h" +#include "base/location.h" #include "base/profiler/scoped_tracker.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_restrictions.h" #include "base/trace_event/trace_event.h" #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" @@ -123,7 +126,7 @@ class BrowserGpuChannelHostFactory::EstablishRequest IPC::ChannelHandle channel_handle_; gpu::GPUInfo gpu_info_; bool finished_; - scoped_refptr<base::MessageLoopProxy> main_loop_; + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; }; scoped_refptr<BrowserGpuChannelHostFactory::EstablishRequest> @@ -132,10 +135,10 @@ BrowserGpuChannelHostFactory::EstablishRequest::Create(CauseForGpuLaunch cause, int gpu_host_id) { scoped_refptr<EstablishRequest> establish_request = new EstablishRequest(cause, gpu_client_id, gpu_host_id); - scoped_refptr<base::MessageLoopProxy> loop = + scoped_refptr<base::SingleThreadTaskRunner> task_runner = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); // PostTask outside the constructor to ensure at least one reference exists. - loop->PostTask( + task_runner->PostTask( FROM_HERE, base::Bind(&BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO, establish_request)); @@ -152,7 +155,7 @@ BrowserGpuChannelHostFactory::EstablishRequest::EstablishRequest( gpu_host_id_(gpu_host_id), reused_gpu_process_(false), finished_(false), - main_loop_(base::MessageLoopProxy::current()) { + main_task_runner_(base::ThreadTaskRunnerHandle::Get()) { } void BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO() { @@ -212,7 +215,7 @@ void BrowserGpuChannelHostFactory::EstablishRequest::OnEstablishedOnIO( void BrowserGpuChannelHostFactory::EstablishRequest::FinishOnIO() { event_.Signal(); - main_loop_->PostTask( + main_task_runner_->PostTask( FROM_HERE, base::Bind(&BrowserGpuChannelHostFactory::EstablishRequest::FinishOnMain, this)); @@ -228,7 +231,7 @@ void BrowserGpuChannelHostFactory::EstablishRequest::FinishOnMain() { } void BrowserGpuChannelHostFactory::EstablishRequest::Wait() { - DCHECK(main_loop_->BelongsToCurrentThread()); + DCHECK(main_task_runner_->BelongsToCurrentThread()); { // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. tracked_objects::ScopedTracker tracking_profile( @@ -248,7 +251,7 @@ void BrowserGpuChannelHostFactory::EstablishRequest::Wait() { } void BrowserGpuChannelHostFactory::EstablishRequest::Cancel() { - DCHECK(main_loop_->BelongsToCurrentThread()); + DCHECK(main_task_runner_->BelongsToCurrentThread()); finished_ = true; } diff --git a/content/browser/histogram_synchronizer.cc b/content/browser/histogram_synchronizer.cc index 9b15b73..5851790 100644 --- a/content/browser/histogram_synchronizer.cc +++ b/content/browser/histogram_synchronizer.cc @@ -6,10 +6,12 @@ #include "base/bind.h" #include "base/lazy_instance.h" +#include "base/location.h" #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/metrics/histogram_delta_serialization.h" #include "base/pickle.h" +#include "base/single_thread_task_runner.h" #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" #include "content/browser/histogram_controller.h" @@ -319,7 +321,7 @@ void HistogramSynchronizer::InternalPostTask(base::MessageLoop* thread, const base::Closure& callback) { if (callback.is_null() || !thread) return; - thread->PostTask(FROM_HERE, callback); + thread->task_runner()->PostTask(FROM_HERE, callback); } int HistogramSynchronizer::GetNextAvailableSequenceNumber( diff --git a/content/browser/indexed_db/indexed_db_browsertest.cc b/content/browser/indexed_db/indexed_db_browsertest.cc index 2ab58c2..cf5b049 100644 --- a/content/browser/indexed_db/indexed_db_browsertest.cc +++ b/content/browser/indexed_db/indexed_db_browsertest.cc @@ -9,8 +9,9 @@ #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/lazy_instance.h" +#include "base/location.h" #include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "base/test/thread_test_helper.h" #include "content/browser/browser_main_loop.h" @@ -142,8 +143,7 @@ class IndexedDBBrowserTest : public ContentBrowserTest { GURL("file:///")), base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, this)); scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( - BrowserMainLoop::GetInstance()->indexed_db_thread()-> - message_loop_proxy())); + BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); EXPECT_TRUE(helper->Run()); // Wait for DidGetDiskUsage to be called. base::MessageLoop::current()->RunUntilIdle(); @@ -156,10 +156,8 @@ class IndexedDBBrowserTest : public ContentBrowserTest { base::Bind(&IndexedDBContextImpl::GetOriginBlobFileCount, GetContext(), GURL("file:///")), base::Bind(&IndexedDBBrowserTest::DidGetBlobFileCount, this)); - scoped_refptr<base::ThreadTestHelper> helper( - new base::ThreadTestHelper(BrowserMainLoop::GetInstance() - ->indexed_db_thread() - ->message_loop_proxy())); + scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( + BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); EXPECT_TRUE(helper->Run()); // Wait for DidGetBlobFileCount to be called. base::MessageLoop::current()->RunUntilIdle(); @@ -323,8 +321,7 @@ class IndexedDBBrowserTestWithPreexistingLevelDB : public IndexedDBBrowserTest { base::Bind( &CopyLevelDBToProfile, shell(), context, EnclosingLevelDBDir())); scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( - BrowserMainLoop::GetInstance()->indexed_db_thread()-> - message_loop_proxy())); + BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); ASSERT_TRUE(helper->Run()); } @@ -477,10 +474,8 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DeleteForOriginDeletesBlobs) { GetContext()->TaskRunner()->PostTask( FROM_HERE, base::Bind(&IndexedDBContextImpl::DeleteForOrigin, GetContext(), GURL("file:///"))); - scoped_refptr<base::ThreadTestHelper> helper( - new base::ThreadTestHelper(BrowserMainLoop::GetInstance() - ->indexed_db_thread() - ->message_loop_proxy())); + scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( + BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); ASSERT_TRUE(helper->Run()); EXPECT_EQ(0, RequestDiskUsage()); } diff --git a/content/browser/indexed_db/indexed_db_quota_client.h b/content/browser/indexed_db/indexed_db_quota_client.h index b9e9bce..a99588c 100644 --- a/content/browser/indexed_db/indexed_db_quota_client.h +++ b/content/browser/indexed_db/indexed_db_quota_client.h @@ -10,7 +10,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "content/common/content_export.h" #include "storage/browser/quota/quota_client.h" #include "storage/browser/quota/quota_task.h" diff --git a/content/browser/indexed_db/indexed_db_quota_client_unittest.cc b/content/browser/indexed_db/indexed_db_quota_client_unittest.cc index f0befd2..3bec0b0 100644 --- a/content/browser/indexed_db/indexed_db_quota_client_unittest.cc +++ b/content/browser/indexed_db/indexed_db_quota_client_unittest.cc @@ -8,7 +8,6 @@ #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop.h" #include "base/test/test_simple_task_runner.h" #include "base/threading/thread.h" #include "content/browser/browser_thread_impl.h" @@ -44,10 +43,9 @@ class IndexedDBQuotaClientTest : public testing::Test { browser_context_.reset(new TestBrowserContext()); scoped_refptr<storage::QuotaManager> quota_manager = - new MockQuotaManager(false /*in_memory*/, - browser_context_->GetPath(), - base::MessageLoop::current()->message_loop_proxy(), - base::MessageLoop::current()->message_loop_proxy(), + new MockQuotaManager(false /*in_memory*/, browser_context_->GetPath(), + base::MessageLoop::current()->task_runner(), + base::MessageLoop::current()->task_runner(), browser_context_->GetSpecialStoragePolicy()); idb_context_ = diff --git a/content/browser/indexed_db/indexed_db_transaction.cc b/content/browser/indexed_db/indexed_db_transaction.cc index cb6fad6..9267999 100644 --- a/content/browser/indexed_db/indexed_db_transaction.cc +++ b/content/browser/indexed_db/indexed_db_transaction.cc @@ -5,9 +5,11 @@ #include "content/browser/indexed_db/indexed_db_transaction.h" #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/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/indexed_db/indexed_db_backing_store.h" #include "content/browser/indexed_db/indexed_db_cursor.h" #include "content/browser/indexed_db/indexed_db_database.h" @@ -122,7 +124,7 @@ void IndexedDBTransaction::RunTasksIfStarted() { return; should_process_queue_ = true; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&IndexedDBTransaction::ProcessTaskQueue, this)); } diff --git a/content/browser/loader/buffered_resource_handler.cc b/content/browser/loader/buffered_resource_handler.cc index 2d4e088..a160eed 100644 --- a/content/browser/loader/buffered_resource_handler.cc +++ b/content/browser/loader/buffered_resource_handler.cc @@ -7,9 +7,12 @@ #include <vector> #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" #include "base/metrics/histogram.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" +#include "base/thread_task_runner_handle.h" #include "components/mime_util/mime_util.h" #include "content/browser/download/download_resource_handler.h" #include "content/browser/download/download_stats.h" @@ -196,7 +199,7 @@ void BufferedResourceHandler::Resume() { NOTREACHED(); break; case STATE_REPLAYING: - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&BufferedResourceHandler::CallReplayReadCompleted, weak_ptr_factory_.GetWeakPtr())); diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc index c3b4eca..5df1109 100644 --- a/content/browser/loader/resource_dispatcher_host_unittest.cc +++ b/content/browser/loader/resource_dispatcher_host_unittest.cc @@ -8,13 +8,15 @@ #include "base/bind.h" #include "base/files/file_path.h" #include "base/files/file_util.h" +#include "base/location.h" #include "base/memory/scoped_vector.h" #include "base/memory/shared_memory.h" -#include "base/message_loop/message_loop.h" #include "base/pickle.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/child_process_security_policy_impl.h" #include "content/browser/loader/cross_site_resource_handler.h" @@ -442,7 +444,7 @@ class URLRequestBigJob : public net::URLRequestSimpleJob { } base::TaskRunner* GetTaskRunner() const override { - return base::MessageLoopProxy::current().get(); + return base::ThreadTaskRunnerHandle::Get().get(); } private: @@ -922,7 +924,7 @@ class ResourceDispatcherHostTest : public testing::Test, scoped_ptr<IPC::Message> ack( new ResourceHostMsg_DataReceived_ACK(request_id)); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&GenerateIPCMessage, filter_, base::Passed(&ack))); } diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc index f3be2a8..63b9f9c 100644 --- a/content/browser/loader/resource_loader.cc +++ b/content/browser/loader/resource_loader.cc @@ -5,9 +5,11 @@ #include "content/browser/loader/resource_loader.h" #include "base/command_line.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" #include "base/metrics/histogram.h" #include "base/profiler/scoped_tracker.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/browser/appcache/appcache_interceptor.h" #include "content/browser/child_process_security_policy_impl.h" @@ -465,23 +467,20 @@ void ResourceLoader::Resume() { request_->FollowDeferredRedirect(); break; case DEFERRED_READ: - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&ResourceLoader::ResumeReading, - weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ResourceLoader::ResumeReading, + weak_ptr_factory_.GetWeakPtr())); break; case DEFERRED_RESPONSE_COMPLETE: - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&ResourceLoader::ResponseCompleted, - weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ResourceLoader::ResponseCompleted, + weak_ptr_factory_.GetWeakPtr())); break; case DEFERRED_FINISH: // Delay self-destruction since we don't know how we were reached. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&ResourceLoader::CallDidFinishLoading, - weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ResourceLoader::CallDidFinishLoading, + weak_ptr_factory_.GetWeakPtr())); break; } } @@ -545,10 +544,9 @@ void ResourceLoader::CancelRequestInternal(int error, bool from_renderer) { // If the request isn't in flight, then we won't get an asynchronous // notification from the request, so we have to signal ourselves to finish // this request. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&ResourceLoader::ResponseCompleted, - weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ResourceLoader::ResponseCompleted, + weak_ptr_factory_.GetWeakPtr())); } } @@ -623,12 +621,10 @@ void ResourceLoader::StartReading(bool is_continuation) { } else { // Else, trigger OnReadCompleted asynchronously to avoid starving the IO // thread in case the URLRequest can provide data synchronously. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&ResourceLoader::OnReadCompleted, - weak_ptr_factory_.GetWeakPtr(), - request_.get(), - bytes_read)); + weak_ptr_factory_.GetWeakPtr(), request_.get(), bytes_read)); } } diff --git a/content/browser/loader/resource_loader_unittest.cc b/content/browser/loader/resource_loader_unittest.cc index 16cab3a..7b4000e 100644 --- a/content/browser/loader/resource_loader_unittest.cc +++ b/content/browser/loader/resource_loader_unittest.cc @@ -6,9 +6,11 @@ #include "base/files/file.h" #include "base/files/file_util.h" +#include "base/location.h" #include "base/macros.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/loader/redirect_to_file_resource_handler.h" #include "content/browser/loader/resource_loader_delegate.h" @@ -104,7 +106,7 @@ class LoaderDestroyingCertStore : public net::ClientCertStore { net::CertificateList* selected_certs, const base::Closure& callback) override { // Don't destroy |loader_| while it's on the stack. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&LoaderDestroyingCertStore::DoCallback, base::Unretained(loader_), callback)); } @@ -135,7 +137,7 @@ class MockClientCertURLRequestJob : public net::URLRequestTestJob { scoped_refptr<net::SSLCertRequestInfo> cert_request_info( new net::SSLCertRequestInfo); cert_request_info->cert_authorities = test_authorities(); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&MockClientCertURLRequestJob::NotifyCertificateRequested, this, cert_request_info)); @@ -407,7 +409,7 @@ class NonChunkedUploadDataStream : public net::UploadDataStream { void CreateTemporaryError( base::File::Error error, const CreateTemporaryFileStreamCallback& callback) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, error, base::Passed(scoped_ptr<net::FileStream>()), scoped_refptr<ShareableFileReference>())); @@ -779,7 +781,7 @@ class ResourceLoaderRedirectToFileTest : public ResourceLoaderTest { // Create mock file streams and a ShareableFileReference. scoped_ptr<net::testing::MockFileStream> file_stream( new net::testing::MockFileStream(file.Pass(), - base::MessageLoopProxy::current())); + base::ThreadTaskRunnerHandle::Get())); file_stream_ = file_stream.get(); deletable_file_ = ShareableFileReference::GetOrCreate( temp_path_, @@ -802,10 +804,9 @@ class ResourceLoaderRedirectToFileTest : public ResourceLoaderTest { void PostCallback( scoped_ptr<net::FileStream> file_stream, const CreateTemporaryFileStreamCallback& callback) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(callback, base::File::FILE_OK, - base::Passed(&file_stream), deletable_file_)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(callback, base::File::FILE_OK, + base::Passed(&file_stream), deletable_file_)); } base::FilePath temp_path_; diff --git a/content/browser/loader/upload_data_stream_builder_unittest.cc b/content/browser/loader/upload_data_stream_builder_unittest.cc index 57161ea..174a89b 100644 --- a/content/browser/loader/upload_data_stream_builder_unittest.cc +++ b/content/browser/loader/upload_data_stream_builder_unittest.cc @@ -9,9 +9,8 @@ #include "base/files/file_path.h" #include "base/files/file_util.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/common/resource_request_body.h" #include "net/base/io_buffer.h" @@ -78,7 +77,8 @@ TEST(UploadDataStreamBuilderTest, CreateUploadDataStreamWithoutBlob) { request_body->set_identifier(kIdentifier); scoped_ptr<net::UploadDataStream> upload(UploadDataStreamBuilder::Build( - request_body.get(), NULL, NULL, base::MessageLoopProxy::current().get())); + request_body.get(), NULL, NULL, + base::ThreadTaskRunnerHandle::Get().get())); EXPECT_EQ(kIdentifier, upload->identifier()); ASSERT_TRUE(upload->GetElementReaders()); @@ -146,12 +146,9 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { upload_element2.length(), upload_element2.expected_modification_time()); - scoped_ptr<net::UploadDataStream> upload( - UploadDataStreamBuilder::Build( - request_body.get(), - &blob_storage_context, - NULL, - base::MessageLoopProxy::current().get())); + scoped_ptr<net::UploadDataStream> upload(UploadDataStreamBuilder::Build( + request_body.get(), &blob_storage_context, NULL, + base::ThreadTaskRunnerHandle::Get().get())); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(2U, upload->GetElementReaders()->size()); @@ -165,10 +162,8 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { request_body->AppendBlob(blob_id0); upload = UploadDataStreamBuilder::Build( - request_body.get(), - &blob_storage_context, - NULL, - base::MessageLoopProxy::current().get()); + request_body.get(), &blob_storage_context, NULL, + base::ThreadTaskRunnerHandle::Get().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(0U, upload->GetElementReaders()->size()); @@ -177,10 +172,8 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { request_body->AppendBlob(blob_id1); upload = UploadDataStreamBuilder::Build( - request_body.get(), - &blob_storage_context, - NULL, - base::MessageLoopProxy::current().get()); + request_body.get(), &blob_storage_context, NULL, + base::ThreadTaskRunnerHandle::Get().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(2U, upload->GetElementReaders()->size()); EXPECT_TRUE(AreElementsEqual( @@ -201,10 +194,8 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { upload_element2.expected_modification_time()); upload = UploadDataStreamBuilder::Build( - request_body.get(), - &blob_storage_context, - NULL, - base::MessageLoopProxy::current().get()); + request_body.get(), &blob_storage_context, NULL, + base::ThreadTaskRunnerHandle::Get().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(4U, upload->GetElementReaders()->size()); EXPECT_TRUE(AreElementsEqual( @@ -228,11 +219,9 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { upload_element2.expected_modification_time()); request_body->AppendBlob(blob_id1); - upload = - UploadDataStreamBuilder::Build(request_body.get(), - &blob_storage_context, - NULL, - base::MessageLoopProxy::current().get()); + upload = UploadDataStreamBuilder::Build( + request_body.get(), &blob_storage_context, NULL, + base::ThreadTaskRunnerHandle::Get().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(4U, upload->GetElementReaders()->size()); EXPECT_TRUE(AreElementsEqual( @@ -257,10 +246,8 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { upload_element2.expected_modification_time()); upload = UploadDataStreamBuilder::Build( - request_body.get(), - &blob_storage_context, - NULL, - base::MessageLoopProxy::current().get()); + request_body.get(), &blob_storage_context, NULL, + base::ThreadTaskRunnerHandle::Get().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(4U, upload->GetElementReaders()->size()); EXPECT_TRUE(AreElementsEqual( @@ -287,10 +274,8 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { upload_element2.expected_modification_time()); upload = UploadDataStreamBuilder::Build( - request_body.get(), - &blob_storage_context, - NULL, - base::MessageLoopProxy::current().get()); + request_body.get(), &blob_storage_context, NULL, + base::ThreadTaskRunnerHandle::Get().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(8U, upload->GetElementReaders()->size()); EXPECT_TRUE(AreElementsEqual( @@ -341,7 +326,7 @@ TEST(UploadDataStreamBuilderTest, scoped_refptr<ResourceRequestBody> request_body(new ResourceRequestBody()); scoped_ptr<net::UploadDataStream> upload(UploadDataStreamBuilder::Build( request_body.get(), &blob_storage_context, NULL, - base::MessageLoopProxy::current().get())); + base::ThreadTaskRunnerHandle::Get().get())); request_body = new ResourceRequestBody(); request_body->AppendBlob(blob_id); @@ -350,7 +335,7 @@ TEST(UploadDataStreamBuilderTest, upload = UploadDataStreamBuilder::Build( request_body.get(), &blob_storage_context, NULL, - base::MessageLoopProxy::current().get()); + base::ThreadTaskRunnerHandle::Get().get()); ASSERT_TRUE(upload->GetElementReaders()); const auto& readers = *upload->GetElementReaders(); ASSERT_EQ(3U, readers.size()); diff --git a/content/browser/media/capture/content_video_capture_device_core.cc b/content/browser/media/capture/content_video_capture_device_core.cc index 051aec1..96cef23 100644 --- a/content/browser/media/capture/content_video_capture_device_core.cc +++ b/content/browser/media/capture/content_video_capture_device_core.cc @@ -11,7 +11,6 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/histogram.h" #include "base/sequenced_task_runner.h" #include "base/strings/string_number_conversions.h" diff --git a/content/browser/media/capture/web_contents_audio_input_stream_unittest.cc b/content/browser/media/capture/web_contents_audio_input_stream_unittest.cc index 0eebd7a..c7c9c84 100644 --- a/content/browser/media/capture/web_contents_audio_input_stream_unittest.cc +++ b/content/browser/media/capture/web_contents_audio_input_stream_unittest.cc @@ -8,7 +8,7 @@ #include "base/bind.h" #include "base/bind_helpers.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/threading/thread.h" @@ -201,8 +201,7 @@ class WebContentsAudioInputStreamTest : public testing::Test { } void Open() { - mock_vais_ = - new MockVirtualAudioInputStream(audio_thread_.message_loop_proxy()); + mock_vais_ = new MockVirtualAudioInputStream(audio_thread_.task_runner()); EXPECT_CALL(*mock_vais_, Open()); EXPECT_CALL(*mock_vais_, Close()); // At Close() time. @@ -341,7 +340,7 @@ class WebContentsAudioInputStreamTest : public testing::Test { } void RunOnAudioThread(const base::Closure& closure) { - audio_thread_.message_loop()->PostTask(FROM_HERE, closure); + audio_thread_.task_runner()->PostTask(FROM_HERE, closure); } // Block the calling thread until OnData() callbacks are being made. diff --git a/content/browser/media/capture/web_contents_video_capture_device.cc b/content/browser/media/capture/web_contents_video_capture_device.cc index def9f9a..dca65d3 100644 --- a/content/browser/media/capture/web_contents_video_capture_device.cc +++ b/content/browser/media/capture/web_contents_video_capture_device.cc @@ -53,12 +53,13 @@ #include "base/basictypes.h" #include "base/bind.h" #include "base/callback_helpers.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/histogram.h" #include "base/sequenced_task_runner.h" +#include "base/single_thread_task_runner.h" #include "base/threading/thread.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" @@ -633,9 +634,9 @@ void WebContentsCaptureMachine::DidCopyFromBackingStore( UMA_HISTOGRAM_TIMES("TabCapture.CopyTimeBitmap", now - start_time); TRACE_EVENT_ASYNC_STEP_INTO0("gpu.capture", "Capture", target.get(), "Render"); - render_thread_->message_loop_proxy()->PostTask(FROM_HERE, base::Bind( - &RenderVideoFrame, bitmap, target, - base::Bind(deliver_frame_cb, start_time))); + render_thread_->task_runner()->PostTask( + FROM_HERE, base::Bind(&RenderVideoFrame, bitmap, target, + base::Bind(deliver_frame_cb, start_time))); } else { // Capture can fail due to transient issues, so just skip this frame. DVLOG(1) << "CopyFromBackingStore failed; skipping frame."; diff --git a/content/browser/media/media_internals_proxy.cc b/content/browser/media/media_internals_proxy.cc index 05f4dd8..8a0fbd40 100644 --- a/content/browser/media/media_internals_proxy.cc +++ b/content/browser/media/media_internals_proxy.cc @@ -5,7 +5,9 @@ #include "content/browser/media/media_internals_proxy.h" #include "base/bind.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/media/media_internals_handler.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/notification_service.h" @@ -156,7 +158,7 @@ void MediaInternalsProxy::AddNetEventOnUIThread(base::Value* entry) { // if an update is not already pending. if (!pending_net_updates_) { pending_net_updates_.reset(new base::ListValue()); - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&MediaInternalsProxy::SendNetEventsOnUIThread, this), base::TimeDelta::FromMilliseconds( diff --git a/content/browser/net/view_http_cache_job_factory.cc b/content/browser/net/view_http_cache_job_factory.cc index e80cac7..6b46b61 100644 --- a/content/browser/net/view_http_cache_job_factory.cc +++ b/content/browser/net/view_http_cache_job_factory.cc @@ -8,9 +8,11 @@ #include "base/bind_helpers.h" #include "base/callback.h" #include "base/compiler_specific.h" +#include "base/location.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" +#include "base/thread_task_runner_handle.h" #include "content/public/common/url_constants.h" #include "net/base/completion_callback.h" #include "net/base/net_errors.h" @@ -96,7 +98,7 @@ class ViewHttpCacheJob : public net::URLRequestJob { }; void ViewHttpCacheJob::Start() { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&ViewHttpCacheJob::StartAsync, weak_factory_.GetWeakPtr())); } diff --git a/content/browser/notifications/platform_notification_context_unittest.cc b/content/browser/notifications/platform_notification_context_unittest.cc index 30ab46a..4560f7d 100644 --- a/content/browser/notifications/platform_notification_context_unittest.cc +++ b/content/browser/notifications/platform_notification_context_unittest.cc @@ -6,6 +6,7 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/run_loop.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/notifications/platform_notification_context_impl.h" #include "content/browser/service_worker/embedded_worker_test_helper.h" #include "content/browser/service_worker/service_worker_context_wrapper.h" @@ -99,7 +100,7 @@ class PlatformNotificationContextTest : public ::testing::Test { // Overrides the task runner in |context| with the current message loop // proxy, to reduce the number of threads involved in the tests. void OverrideTaskRunnerForTesting(PlatformNotificationContextImpl* context) { - context->SetTaskRunnerForTesting(base::MessageLoopProxy::current()); + context->SetTaskRunnerForTesting(base::ThreadTaskRunnerHandle::Get()); } // Returns the testing browsing context that can be used for this test. diff --git a/content/browser/plugin_loader_posix.cc b/content/browser/plugin_loader_posix.cc index b8750ed..bfc9032 100644 --- a/content/browser/plugin_loader_posix.cc +++ b/content/browser/plugin_loader_posix.cc @@ -5,9 +5,10 @@ #include "content/browser/plugin_loader_posix.h" #include "base/bind.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" #include "base/metrics/histogram.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/utility_process_host_impl.h" #include "content/common/child_process_host_impl.h" #include "content/common/plugin_list.h" @@ -29,8 +30,8 @@ void PluginLoaderPosix::GetPlugins( std::vector<WebPluginInfo> cached_plugins; if (PluginList::Singleton()->GetPluginsNoRefresh(&cached_plugins)) { // Can't assume the caller is reentrant. - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, cached_plugins)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(callback, cached_plugins)); return; } @@ -226,7 +227,7 @@ void PluginLoaderPosix::FinishedLoadingPlugins() { PluginList::Singleton()->SetPlugins(loaded_plugins_); for (auto& callback : callbacks_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, loaded_plugins_)); } callbacks_.clear(); diff --git a/content/browser/plugin_loader_posix.h b/content/browser/plugin_loader_posix.h index 3a50bcd..2db1634 100644 --- a/content/browser/plugin_loader_posix.h +++ b/content/browser/plugin_loader_posix.h @@ -16,10 +16,6 @@ #include "content/public/common/webplugininfo.h" #include "ipc/ipc_sender.h" -namespace base { -class MessageLoopProxy; -} - namespace content { class UtilityProcessHost; diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc index ed7f64c..678171c 100644 --- a/content/browser/plugin_service_impl.cc +++ b/content/browser/plugin_service_impl.cc @@ -8,9 +8,9 @@ #include "base/command_line.h" #include "base/compiler_specific.h" #include "base/files/file_path.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" #include "base/metrics/histogram.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/waitable_event.h" @@ -125,10 +125,10 @@ void NotifyPluginDirChanged(const base::FilePath& path, bool error) { } #endif -void ForwardCallback(base::MessageLoopProxy* target_loop, +void ForwardCallback(base::SingleThreadTaskRunner* target_task_runner, const PluginService::GetPluginsCallback& callback, const std::vector<WebPluginInfo>& plugins) { - target_loop->PostTask(FROM_HERE, base::Bind(callback, plugins)); + target_task_runner->PostTask(FROM_HERE, base::Bind(callback, plugins)); } } // namespace @@ -589,45 +589,43 @@ base::string16 PluginServiceImpl::GetPluginDisplayNameByPath( } void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) { - scoped_refptr<base::MessageLoopProxy> target_loop( - base::MessageLoop::current()->message_loop_proxy()); + scoped_refptr<base::SingleThreadTaskRunner> target_task_runner( + base::ThreadTaskRunnerHandle::Get()); if (LoadPluginListInProcess()) { - BrowserThread::GetBlockingPool()-> - PostSequencedWorkerTaskWithShutdownBehavior( - plugin_list_token_, - FROM_HERE, + BrowserThread::GetBlockingPool() + ->PostSequencedWorkerTaskWithShutdownBehavior( + plugin_list_token_, FROM_HERE, base::Bind(&PluginServiceImpl::GetPluginsInternal, - base::Unretained(this), - target_loop, callback), - base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); + base::Unretained(this), target_task_runner, callback), + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); return; } #if defined(OS_POSIX) - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, base::Bind(&PluginServiceImpl::GetPluginsOnIOThread, - base::Unretained(this), target_loop, callback)); + base::Unretained(this), target_task_runner, callback)); #else NOTREACHED(); #endif } void PluginServiceImpl::GetPluginsInternal( - base::MessageLoopProxy* target_loop, - const PluginService::GetPluginsCallback& callback) { + base::SingleThreadTaskRunner* target_task_runner, + const PluginService::GetPluginsCallback& callback) { DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( plugin_list_token_)); std::vector<WebPluginInfo> plugins; PluginList::Singleton()->GetPlugins(&plugins, NPAPIPluginsSupported()); - target_loop->PostTask(FROM_HERE, - base::Bind(callback, plugins)); + target_task_runner->PostTask(FROM_HERE, base::Bind(callback, plugins)); } #if defined(OS_POSIX) void PluginServiceImpl::GetPluginsOnIOThread( - base::MessageLoopProxy* target_loop, + base::SingleThreadTaskRunner* target_task_runner, const GetPluginsCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -637,8 +635,8 @@ void PluginServiceImpl::GetPluginsOnIOThread( if (!plugin_loader_.get()) plugin_loader_ = new PluginLoaderPosix; - plugin_loader_->GetPlugins( - base::Bind(&ForwardCallback, make_scoped_refptr(target_loop), callback)); + plugin_loader_->GetPlugins(base::Bind( + &ForwardCallback, make_scoped_refptr(target_task_runner), callback)); } #endif diff --git a/content/browser/plugin_service_impl.h b/content/browser/plugin_service_impl.h index 2e107a6..19fefba 100644 --- a/content/browser/plugin_service_impl.h +++ b/content/browser/plugin_service_impl.h @@ -42,7 +42,7 @@ #endif namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } namespace content { @@ -181,13 +181,12 @@ class CONTENT_EXPORT PluginServiceImpl void RegisterPepperPlugins(); // Run on the blocking pool to load the plugins synchronously. - void GetPluginsInternal(base::MessageLoopProxy* target_loop, + void GetPluginsInternal(base::SingleThreadTaskRunner* target_task_runner, const GetPluginsCallback& callback); #if defined(OS_POSIX) - void GetPluginsOnIOThread( - base::MessageLoopProxy* target_loop, - const GetPluginsCallback& callback); + void GetPluginsOnIOThread(base::SingleThreadTaskRunner* target_task_runner, + const GetPluginsCallback& callback); #endif // Binding directly to GetAllowedPluginForOpenChannelToPlugin() isn't possible diff --git a/content/browser/plugin_service_impl_browsertest.cc b/content/browser/plugin_service_impl_browsertest.cc index e60516e..9c1e9f1 100644 --- a/content/browser/plugin_service_impl_browsertest.cc +++ b/content/browser/plugin_service_impl_browsertest.cc @@ -7,7 +7,10 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" +#include "base/location.h" #include "base/path_service.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/plugin_service_filter.h" #include "content/public/browser/resource_context.h" @@ -261,12 +264,10 @@ class MockCanceledBeforeSentPluginProcessHostClient set_host(host); // This gets called right before we request the plugin<=>renderer channel, // so we have to post a task to cancel it. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&PluginProcessHost::CancelPendingRequest, - base::Unretained(host), - this)); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&PluginProcessHost::CancelPendingRequest, + base::Unretained(host), this)); + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&QuitUIMessageLoopFromIOThread)); } diff --git a/content/browser/power_profiler/power_profiler_service_unittest.cc b/content/browser/power_profiler/power_profiler_service_unittest.cc index 3386b6f..96e96d1 100644 --- a/content/browser/power_profiler/power_profiler_service_unittest.cc +++ b/content/browser/power_profiler/power_profiler_service_unittest.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/power_profiler/power_profiler_service.h" @@ -90,8 +89,7 @@ class PowerProfilerServiceTest : public testing::Test { service_.reset(new PowerProfilerService( make_scoped_ptr<PowerDataProvider>( new TestPowerDataProvider(kNumEvents)), - message_loop_.message_loop_proxy(), - base::TimeDelta::FromMilliseconds(1))); + message_loop_.task_runner(), base::TimeDelta::FromMilliseconds(1))); EXPECT_TRUE(service_->IsAvailable()); } diff --git a/content/browser/power_save_blocker_x11.cc b/content/browser/power_save_blocker_x11.cc index bc20e02..4ffe2e6 100644 --- a/content/browser/power_save_blocker_x11.cc +++ b/content/browser/power_save_blocker_x11.cc @@ -21,7 +21,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/nix/xdg_util.h" #include "base/synchronization/lock.h" #include "content/public/browser/browser_thread.h" diff --git a/content/browser/presentation/presentation_service_impl_unittest.cc b/content/browser/presentation/presentation_service_impl_unittest.cc index 677418f..81a2dba 100644 --- a/content/browser/presentation/presentation_service_impl_unittest.cc +++ b/content/browser/presentation/presentation_service_impl_unittest.cc @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/location.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/test/test_timeouts.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/presentation/presentation_service_impl.h" #include "content/public/browser/presentation_service_delegate.h" #include "content/public/browser/presentation_session.h" @@ -174,7 +176,7 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness { void RunLoopFor(base::TimeDelta duration) { base::RunLoop run_loop; - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, run_loop.QuitClosure(), duration); run_loop.Run(); } diff --git a/content/browser/quota/mock_quota_manager.cc b/content/browser/quota/mock_quota_manager.cc index 4884d0d..47bc304 100644 --- a/content/browser/quota/mock_quota_manager.cc +++ b/content/browser/quota/mock_quota_manager.cc @@ -4,10 +4,11 @@ #include "content/browser/quota/mock_quota_manager.h" +#include "base/location.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "url/gurl.h" using storage::kQuotaStatusOk; @@ -93,13 +94,10 @@ void MockQuotaManager::GetOriginsModifiedSince( origins_to_return->insert(current->origin); } - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&MockQuotaManager::DidGetModifiedSince, - weak_factory_.GetWeakPtr(), - callback, - base::Owned(origins_to_return), - type)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&MockQuotaManager::DidGetModifiedSince, + weak_factory_.GetWeakPtr(), callback, + base::Owned(origins_to_return), type)); } void MockQuotaManager::DeleteOriginData( @@ -119,12 +117,10 @@ void MockQuotaManager::DeleteOriginData( } } - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&MockQuotaManager::DidDeleteOriginData, - weak_factory_.GetWeakPtr(), - callback, - kQuotaStatusOk)); + weak_factory_.GetWeakPtr(), callback, kQuotaStatusOk)); } MockQuotaManager::~MockQuotaManager() {} diff --git a/content/browser/quota/mock_quota_manager_unittest.cc b/content/browser/quota/mock_quota_manager_unittest.cc index 706ca82..e5e170c 100644 --- a/content/browser/quota/mock_quota_manager_unittest.cc +++ b/content/browser/quota/mock_quota_manager_unittest.cc @@ -8,8 +8,8 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/quota/mock_quota_manager.h" #include "content/public/test/mock_special_storage_policy.h" #include "content/public/test/mock_storage_client.h" @@ -45,10 +45,9 @@ class MockQuotaManagerTest : public testing::Test { void SetUp() override { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); policy_ = new MockSpecialStoragePolicy; - manager_ = new MockQuotaManager(false /* is_incognito */, - data_dir_.path(), - base::MessageLoopProxy::current().get(), - base::MessageLoopProxy::current().get(), + manager_ = new MockQuotaManager(false /* is_incognito */, data_dir_.path(), + base::ThreadTaskRunnerHandle::Get().get(), + base::ThreadTaskRunnerHandle::Get().get(), policy_.get()); } diff --git a/content/browser/quota/quota_backend_impl_unittest.cc b/content/browser/quota/quota_backend_impl_unittest.cc index 2cf9f17..6139e8a 100644 --- a/content/browser/quota/quota_backend_impl_unittest.cc +++ b/content/browser/quota/quota_backend_impl_unittest.cc @@ -7,7 +7,7 @@ #include <string> #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop.h" +#include "base/thread_task_runner_handle.h" #include "storage/browser/fileapi/file_system_usage_cache.h" #include "storage/browser/fileapi/obfuscated_file_util.h" #include "storage/browser/quota/quota_manager_proxy.h" @@ -129,7 +129,7 @@ class QuotaBackendImplTest : public testing::Test { } base::SequencedTaskRunner* file_task_runner() { - return base::MessageLoopProxy::current().get(); + return base::ThreadTaskRunnerHandle::Get().get(); } base::FilePath GetUsageCachePath(const GURL& origin, diff --git a/content/browser/quota/quota_manager_unittest.cc b/content/browser/quota/quota_manager_unittest.cc index 1337bc3..39c2315 100644 --- a/content/browser/quota/quota_manager_unittest.cc +++ b/content/browser/quota/quota_manager_unittest.cc @@ -12,10 +12,10 @@ #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" #include "base/stl_util.h" #include "base/sys_info.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/public/test/mock_special_storage_policy.h" #include "content/public/test/mock_storage_client.h" @@ -25,7 +25,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" -using base::MessageLoopProxy; using storage::kQuotaErrorAbort; using storage::kQuotaErrorInvalidModification; using storage::kQuotaErrorNotSupported; @@ -92,10 +91,9 @@ class QuotaManagerTest : public testing::Test { protected: void ResetQuotaManager(bool is_incognito) { - quota_manager_ = new QuotaManager(is_incognito, - data_dir_.path(), - MessageLoopProxy::current().get(), - MessageLoopProxy::current().get(), + quota_manager_ = new QuotaManager(is_incognito, data_dir_.path(), + base::ThreadTaskRunnerHandle::Get().get(), + base::ThreadTaskRunnerHandle::Get().get(), mock_special_storage_policy_.get()); // Don't (automatically) start the eviction for testing. quota_manager_->eviction_disabled_ = true; diff --git a/content/browser/quota/quota_reservation_manager_unittest.cc b/content/browser/quota/quota_reservation_manager_unittest.cc index 61de3d5..05fff80 100644 --- a/content/browser/quota/quota_reservation_manager_unittest.cc +++ b/content/browser/quota/quota_reservation_manager_unittest.cc @@ -9,8 +9,10 @@ #include "base/files/file.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "storage/browser/fileapi/quota/open_file_handle.h" #include "storage/browser/fileapi/quota/quota_reservation.h" #include "testing/gtest/include/gtest/gtest.h" @@ -56,7 +58,7 @@ class FakeBackend : public QuotaReservationManager::QuotaBackend { EXPECT_EQ(GURL(kOrigin), origin); EXPECT_EQ(kType, type); on_memory_usage_ += delta; - base::MessageLoopProxy::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(base::IgnoreResult(callback), base::File::FILE_OK, delta)); } diff --git a/content/browser/quota/quota_temporary_storage_evictor_unittest.cc b/content/browser/quota/quota_temporary_storage_evictor_unittest.cc index 6c00c0f..ba414fc 100644 --- a/content/browser/quota/quota_temporary_storage_evictor_unittest.cc +++ b/content/browser/quota/quota_temporary_storage_evictor_unittest.cc @@ -10,7 +10,6 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" #include "content/public/test/mock_storage_client.h" #include "storage/browser/quota/quota_manager.h" diff --git a/content/browser/quota/storage_monitor_unittest.cc b/content/browser/quota/storage_monitor_unittest.cc index 78599de..0edd49e 100644 --- a/content/browser/quota/storage_monitor_unittest.cc +++ b/content/browser/quota/storage_monitor_unittest.cc @@ -5,9 +5,8 @@ #include <vector> #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" +#include "base/thread_task_runner_handle.h" #include "content/public/test/mock_special_storage_policy.h" #include "content/public/test/mock_storage_client.h" #include "net/base/net_util.h" @@ -63,17 +62,15 @@ class MockObserver : public StorageObserver { class UsageMockQuotaManager : public QuotaManager { public: UsageMockQuotaManager(SpecialStoragePolicy* special_storage_policy) - : QuotaManager( - false, - base::FilePath(), - base::MessageLoopProxy::current().get(), - base::MessageLoopProxy::current().get(), - special_storage_policy), + : QuotaManager(false, + base::FilePath(), + base::ThreadTaskRunnerHandle::Get().get(), + base::ThreadTaskRunnerHandle::Get().get(), + special_storage_policy), callback_usage_(0), callback_quota_(0), callback_status_(kQuotaStatusOk), - initialized_(false) { - } + initialized_(false) {} void SetCallbackParams(int64 usage, int64 quota, QuotaStatusCode status) { initialized_ = true; @@ -649,11 +646,8 @@ class StorageMonitorIntegrationTest : public testing::Test { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); storage_policy_ = new MockSpecialStoragePolicy(); quota_manager_ = new QuotaManager( - false, - data_dir_.path(), - base::MessageLoopProxy::current().get(), - base::MessageLoopProxy::current().get(), - storage_policy_.get()); + false, data_dir_.path(), base::ThreadTaskRunnerHandle::Get().get(), + base::ThreadTaskRunnerHandle::Get().get(), storage_policy_.get()); client_ = new MockStorageClient(quota_manager_->proxy(), NULL, diff --git a/content/browser/quota/usage_tracker_unittest.cc b/content/browser/quota/usage_tracker_unittest.cc index 786146a..3cfdf2cb 100644 --- a/content/browser/quota/usage_tracker_unittest.cc +++ b/content/browser/quota/usage_tracker_unittest.cc @@ -3,7 +3,10 @@ // found in the LICENSE file. #include "base/bind.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/public/test/mock_special_storage_policy.h" #include "net/base/net_util.h" #include "storage/browser/quota/usage_tracker.h" @@ -56,8 +59,8 @@ class MockQuotaClient : public QuotaClient { const GetUsageCallback& callback) override { EXPECT_EQ(kStorageTypeTemporary, type); int64 usage = GetUsage(origin); - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, usage)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback, usage)); } void GetOriginsForType(StorageType type, @@ -68,8 +71,8 @@ class MockQuotaClient : public QuotaClient { itr != usage_map_.end(); ++itr) { origins.insert(itr->first); } - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, origins)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(callback, origins)); } void GetOriginsForHost(StorageType type, @@ -82,8 +85,8 @@ class MockQuotaClient : public QuotaClient { if (net::GetHostOrSpecFromURL(itr->first) == host) origins.insert(itr->first); } - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, origins)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(callback, origins)); } void DeleteOriginData(const GURL& origin, @@ -91,7 +94,7 @@ class MockQuotaClient : public QuotaClient { const DeletionCallback& callback) override { EXPECT_EQ(kStorageTypeTemporary, type); usage_map_.erase(origin); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, kQuotaStatusOk)); } diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc index ce153f5..4a12052 100644 --- a/content/browser/renderer_host/compositor_impl_android.cc +++ b/content/browser/renderer_host/compositor_impl_android.cc @@ -82,7 +82,7 @@ class OutputSurfaceWithoutParent : public cc::OutputSurface { capabilities_.adjust_deadline_for_parent = false; capabilities_.max_frames_pending = 2; compositor_impl_ = compositor_impl; - main_thread_ = base::MessageLoopProxy::current(); + main_thread_ = base::ThreadTaskRunnerHandle::Get(); } void SwapBuffers(cc::CompositorFrame* frame) override { @@ -130,7 +130,7 @@ class OutputSurfaceWithoutParent : public cc::OutputSurface { gfx::SwapResult)> swap_buffers_completion_callback_; - scoped_refptr<base::MessageLoopProxy> main_thread_; + scoped_refptr<base::SingleThreadTaskRunner> main_thread_; base::WeakPtr<CompositorImpl> compositor_impl_; }; @@ -307,7 +307,7 @@ void CompositorImpl::PostComposite(CompositingTrigger trigger) { // Unretained because we cancel the task on shutdown. current_composite_task_.reset(new base::CancelableClosure( base::Bind(&CompositorImpl::Composite, base::Unretained(this), trigger))); - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, current_composite_task_->callback(), delay); } @@ -657,7 +657,7 @@ void CompositorImpl::CreateOutputSurface() { real_output_surface.Pass(), manager, HostSharedBitmapManager::current(), BrowserGpuMemoryBufferManager::current(), host_->settings().renderer_settings, - base::MessageLoopProxy::current())); + base::ThreadTaskRunnerHandle::Get())); scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( new cc::SurfaceDisplayOutputSurface( manager, surface_id_allocator_.get(), context_provider)); diff --git a/content/browser/renderer_host/input/gesture_event_queue_unittest.cc b/content/browser/renderer_host/input/gesture_event_queue_unittest.cc index 3e57cd0..7e7a6ea 100644 --- a/content/browser/renderer_host/input/gesture_event_queue_unittest.cc +++ b/content/browser/renderer_host/input/gesture_event_queue_unittest.cc @@ -5,9 +5,12 @@ #include <vector> #include "base/basictypes.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/browser/renderer_host/input/gesture_event_queue.h" #include "content/browser/renderer_host/input/touchpad_tap_suppression_controller.h" @@ -1083,9 +1086,8 @@ TEST_F(GestureEventQueueTest, DebounceDefersFollowingGestureEvents) { EXPECT_EQ(2U, GestureEventQueueSize()); EXPECT_EQ(3U, GestureEventDebouncingQueueSize()); - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::MessageLoop::QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(5)); base::MessageLoop::current()->Run(); diff --git a/content/browser/renderer_host/input/input_router_impl_unittest.cc b/content/browser/renderer_host/input/input_router_impl_unittest.cc index 918c260..4f2e6bb 100644 --- a/content/browser/renderer_host/input/input_router_impl_unittest.cc +++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc @@ -6,8 +6,11 @@ #include "base/basictypes.h" #include "base/command_line.h" +#include "base/location.h" #include "base/memory/scoped_ptr.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/renderer_host/input/gesture_event_queue.h" #include "content/browser/renderer_host/input/input_router_client.h" #include "content/browser/renderer_host/input/input_router_impl.h" @@ -326,7 +329,7 @@ class InputRouterImplTest : public testing::Test { } static void RunTasksAndWait(base::TimeDelta delay) { - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::MessageLoop::QuitClosure(), delay); base::MessageLoop::current()->Run(); } diff --git a/content/browser/renderer_host/input/touch_event_queue_unittest.cc b/content/browser/renderer_host/input/touch_event_queue_unittest.cc index 2467cde..f46fe50 100644 --- a/content/browser/renderer_host/input/touch_event_queue_unittest.cc +++ b/content/browser/renderer_host/input/touch_event_queue_unittest.cc @@ -3,9 +3,12 @@ // found in the LICENSE file. #include "base/basictypes.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.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/renderer_host/input/timeout_monitor.h" #include "content/browser/renderer_host/input/touch_event_queue.h" #include "content/common/input/synthetic_web_input_event_builders.h" @@ -282,7 +285,7 @@ class TouchEventQueueTest : public testing::Test, } static void RunTasksAndWait(base::TimeDelta delay) { - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::MessageLoop::QuitClosure(), delay); base::MessageLoop::current()->Run(); } diff --git a/content/browser/renderer_host/input/touch_input_browsertest.cc b/content/browser/renderer_host/input/touch_input_browsertest.cc index b6d5f99..9c9bcef 100644 --- a/content/browser/renderer_host/input/touch_input_browsertest.cc +++ b/content/browser/renderer_host/input/touch_input_browsertest.cc @@ -4,7 +4,10 @@ #include "base/auto_reset.h" #include "base/command_line.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/gpu/compositor_util.h" #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/web_contents/web_contents_impl.h" @@ -27,10 +30,8 @@ namespace { void GiveItSomeTime() { base::RunLoop run_loop; - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - run_loop.QuitClosure(), - base::TimeDelta::FromMilliseconds(10)); + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromMilliseconds(10)); run_loop.Run(); } diff --git a/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc b/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc index f6a5fb2..498806b 100644 --- a/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc +++ b/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc @@ -5,9 +5,10 @@ #include <string> #include "base/bind.h" +#include "base/location.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/renderer_host/media/audio_input_device_manager.h" @@ -71,7 +72,7 @@ class MAYBE_AudioInputDeviceManagerTest : public testing::Test { manager_->UseFakeDevice(); audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); manager_->Register(audio_input_listener_.get(), - message_loop_->message_loop_proxy().get()); + message_loop_->task_runner().get()); // Gets the enumerated device list from the AudioInputDeviceManager. manager_->EnumerateDevices(MEDIA_DEVICE_AUDIO_CAPTURE); diff --git a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc index 848f78c4..19fb35e 100644 --- a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc +++ b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc @@ -2,14 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <string> #include <queue> +#include <string> #include "base/bind.h" #include "base/callback_helpers.h" #include "base/command_line.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/renderer_host/media/audio_input_device_manager.h" #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" @@ -55,10 +57,10 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, public: MockMediaStreamDispatcherHost( const ResourceContext::SaltCallback salt_callback, - const scoped_refptr<base::MessageLoopProxy>& message_loop, + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, MediaStreamManager* manager) : MediaStreamDispatcherHost(kProcessId, salt_callback, manager), - message_loop_(message_loop), + task_runner_(task_runner), current_ipc_(NULL) {} // A list of mock methods. @@ -155,7 +157,7 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, // Notify that the event have occurred. base::Closure quit_closure = quit_closures_.front(); quit_closures_.pop(); - message_loop_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); + task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); label_ = label; audio_devices_ = audio_device_list; @@ -169,7 +171,7 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, if (!quit_closures_.empty()) { base::Closure quit_closure = quit_closures_.front(); quit_closures_.pop(); - message_loop_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); + task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); } label_= ""; @@ -190,7 +192,7 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, const StreamDeviceInfo& device) { base::Closure quit_closure = quit_closures_.front(); quit_closures_.pop(); - message_loop_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); + task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); label_ = label; opened_device_ = device; } @@ -199,11 +201,11 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, const StreamDeviceInfoArray& devices) { base::Closure quit_closure = quit_closures_.front(); quit_closures_.pop(); - message_loop_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); + task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); enumerated_devices_ = devices; } - scoped_refptr<base::MessageLoopProxy> message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; IPC::Message* current_ipc_; std::queue<base::Closure> quit_closures_; }; @@ -223,7 +225,7 @@ class MediaStreamDispatcherHostTest : public testing::Test { thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), origin_("https://test.com") { audio_manager_.reset( - new media::MockAudioManager(base::MessageLoopProxy::current())); + new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())); // Make sure we use fake devices to avoid long delays. base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kUseFakeDeviceForMediaStream); @@ -237,7 +239,7 @@ class MediaStreamDispatcherHostTest : public testing::Test { #if defined(OS_WIN) // Override the Video Capture Thread that MediaStreamManager constructs. media_stream_manager_->video_capture_manager()->set_device_task_runner( - base::MessageLoopProxy::current()); + base::ThreadTaskRunnerHandle::Get()); #endif MockResourceContext* mock_resource_context = @@ -246,8 +248,7 @@ class MediaStreamDispatcherHostTest : public testing::Test { host_ = new MockMediaStreamDispatcherHost( mock_resource_context->GetMediaDeviceIDSalt(), - base::MessageLoopProxy::current(), - media_stream_manager_.get()); + base::ThreadTaskRunnerHandle::Get(), media_stream_manager_.get()); // Use the fake content client and browser. content_client_.reset(new TestContentClient()); diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc index 1ae9fe5..9c7ac2b 100644 --- a/content/browser/renderer_host/media/media_stream_manager.cc +++ b/content/browser/renderer_host/media/media_stream_manager.cc @@ -1670,8 +1670,7 @@ void MediaStreamManager::InitializeDeviceManagersOnIOThread() { // buggy third party Direct Show modules, http://crbug.com/428958. video_capture_thread_.init_com_with_mta(false); CHECK(video_capture_thread_.Start()); - video_capture_manager_->Register(this, - video_capture_thread_.message_loop_proxy()); + video_capture_manager_->Register(this, video_capture_thread_.task_runner()); #else video_capture_manager_->Register(this, device_task_runner_); #endif diff --git a/content/browser/renderer_host/media/media_stream_manager_unittest.cc b/content/browser/renderer_host/media/media_stream_manager_unittest.cc index 51ab0a5..fc0028c 100644 --- a/content/browser/renderer_host/media/media_stream_manager_unittest.cc +++ b/content/browser/renderer_host/media/media_stream_manager_unittest.cc @@ -6,8 +6,10 @@ #include "base/bind.h" #include "base/command_line.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/renderer_host/media/media_stream_manager.h" #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" @@ -77,7 +79,7 @@ class MediaStreamManagerTest : public ::testing::Test { public: MediaStreamManagerTest() : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), - message_loop_(base::MessageLoopProxy::current()) { + task_runner_(base::ThreadTaskRunnerHandle::Get()) { // Create our own MediaStreamManager. Use fake devices to run on the bots. base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kUseFakeDeviceForMediaStream); @@ -93,7 +95,7 @@ class MediaStreamManagerTest : public ::testing::Test { const MediaStreamDevices& devices, scoped_ptr<MediaStreamUIProxy> ui_proxy) { Response(index); - message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure()); + task_runner_->PostTask(FROM_HERE, run_loop_.QuitClosure()); } protected: @@ -117,7 +119,7 @@ class MediaStreamManagerTest : public ::testing::Test { scoped_ptr<media::AudioManager> audio_manager_; scoped_ptr<MediaStreamManager> media_stream_manager_; content::TestBrowserThreadBundle thread_bundle_; - scoped_refptr<base::MessageLoopProxy> message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; base::RunLoop run_loop_; private: diff --git a/content/browser/renderer_host/media/video_capture_controller_unittest.cc b/content/browser/renderer_host/media/video_capture_controller_unittest.cc index 70cef13..d27fac3 100644 --- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc +++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc @@ -8,10 +8,11 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/location.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "content/browser/renderer_host/media/media_stream_provider.h" #include "content/browser/renderer_host/media/video_capture_controller.h" @@ -73,14 +74,10 @@ class MockVideoCaptureControllerEventHandler const base::TimeTicks& timestamp, scoped_ptr<base::DictionaryValue> metadata) override { DoBufferReady(id, coded_size); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&VideoCaptureController::ReturnBuffer, - base::Unretained(controller_), - id, - this, - buffer_id, - 0)); + base::Unretained(controller_), id, this, buffer_id, 0)); } void OnMailboxBufferReady( VideoCaptureControllerID id, @@ -90,19 +87,16 @@ class MockVideoCaptureControllerEventHandler const base::TimeTicks& timestamp, scoped_ptr<base::DictionaryValue> metadata) override { DoMailboxBufferReady(id); - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&VideoCaptureController::ReturnBuffer, - base::Unretained(controller_), - id, - this, - buffer_id, - mailbox_holder.sync_point)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&VideoCaptureController::ReturnBuffer, + base::Unretained(controller_), id, this, + buffer_id, mailbox_holder.sync_point)); } void OnEnded(VideoCaptureControllerID id) override { DoEnded(id); // OnEnded() must respond by (eventually) unregistering the client. - base::MessageLoop::current()->PostTask(FROM_HERE, + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(base::IgnoreResult(&VideoCaptureController::RemoveClient), base::Unretained(controller_), id, this)); } diff --git a/content/browser/renderer_host/media/video_capture_host_unittest.cc b/content/browser/renderer_host/media/video_capture_host_unittest.cc index 763ed1f..878ea58 100644 --- a/content/browser/renderer_host/media/video_capture_host_unittest.cc +++ b/content/browser/renderer_host/media/video_capture_host_unittest.cc @@ -9,11 +9,13 @@ #include "base/command_line.h" #include "base/files/file_util.h" #include "base/files/scoped_file.h" +#include "base/location.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/strings/stringprintf.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/renderer_host/media/media_stream_manager.h" #include "content/browser/renderer_host/media/media_stream_requester.h" @@ -272,8 +274,8 @@ class MockVideoCaptureHost : public VideoCaptureHost { DumpVideo dumper_; }; -ACTION_P2(ExitMessageLoop, message_loop, quit_closure) { - message_loop->PostTask(FROM_HERE, quit_closure); +ACTION_P2(ExitMessageLoop, task_runner, quit_closure) { + task_runner->PostTask(FROM_HERE, quit_closure); } // This is an integration test of VideoCaptureHost in conjunction with @@ -283,7 +285,7 @@ class VideoCaptureHostTest : public testing::Test { public: VideoCaptureHostTest() : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), - message_loop_(base::MessageLoopProxy::current()), + task_runner_(base::ThreadTaskRunnerHandle::Get()), opened_session_id_(kInvalidMediaCaptureSessionId) {} void SetUp() override { @@ -349,13 +351,11 @@ class VideoCaptureHostTest : public testing::Test { page_request_id, MEDIA_DEVICE_VIDEO_CAPTURE, security_origin); - EXPECT_CALL(stream_requester_, DevicesEnumerated(render_frame_id, - page_request_id, - label, - _)) - .Times(1).WillOnce( - DoAll(ExitMessageLoop(message_loop_, run_loop.QuitClosure()), - SaveArg<3>(&devices))); + EXPECT_CALL(stream_requester_, + DevicesEnumerated(render_frame_id, page_request_id, label, _)) + .Times(1) + .WillOnce(DoAll(ExitMessageLoop(task_runner_, run_loop.QuitClosure()), + SaveArg<3>(&devices))); run_loop.Run(); Mock::VerifyAndClearExpectations(&stream_requester_); media_stream_manager_->CancelRequest(label); @@ -376,14 +376,12 @@ class VideoCaptureHostTest : public testing::Test { devices[0].device.id, MEDIA_DEVICE_VIDEO_CAPTURE, security_origin); - EXPECT_CALL(stream_requester_, DeviceOpened(render_frame_id, - page_request_id, - _, - _)) - .Times(1).WillOnce( - DoAll(ExitMessageLoop(message_loop_, run_loop.QuitClosure()), - SaveArg<2>(&opened_device_label_), - SaveArg<3>(&opened_device))); + EXPECT_CALL(stream_requester_, + DeviceOpened(render_frame_id, page_request_id, _, _)) + .Times(1) + .WillOnce(DoAll(ExitMessageLoop(task_runner_, run_loop.QuitClosure()), + SaveArg<2>(&opened_device_label_), + SaveArg<3>(&opened_device))); run_loop.Run(); Mock::VerifyAndClearExpectations(&stream_requester_); ASSERT_NE(StreamDeviceInfo::kNoId, opened_device.session_id); @@ -408,7 +406,7 @@ class VideoCaptureHostTest : public testing::Test { base::RunLoop run_loop; EXPECT_CALL(*host_.get(), OnBufferFilled(kDeviceId, _, _, _, _, _)) .Times(AnyNumber()) - .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure())); + .WillOnce(ExitMessageLoop(task_runner_, run_loop.QuitClosure())); media::VideoCaptureParams params; params.requested_format = media::VideoCaptureFormat( @@ -457,7 +455,7 @@ class VideoCaptureHostTest : public testing::Test { base::RunLoop run_loop; EXPECT_CALL(*host_.get(), OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)) - .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure())); + .WillOnce(ExitMessageLoop(task_runner_, run_loop.QuitClosure())); host_->OnStopCapture(kDeviceId); host_->SetReturnReceivedDibs(true); @@ -474,7 +472,7 @@ class VideoCaptureHostTest : public testing::Test { base::RunLoop run_loop; EXPECT_CALL(*host_.get(), OnBufferFilled(kDeviceId, _, _, _, _, _)) .Times(AnyNumber()) - .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure())) + .WillOnce(ExitMessageLoop(task_runner_, run_loop.QuitClosure())) .RetiresOnSaturation(); run_loop.Run(); } @@ -512,7 +510,7 @@ class VideoCaptureHostTest : public testing::Test { content::TestBrowserThreadBundle thread_bundle_; content::TestBrowserContext browser_context_; content::TestContentBrowserClient browser_client_; - scoped_refptr<base::MessageLoopProxy> message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; int opened_session_id_; std::string opened_device_label_; diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc index a213a56..2ee8396 100644 --- a/content/browser/renderer_host/media/video_capture_manager.cc +++ b/content/browser/renderer_host/media/video_capture_manager.cc @@ -9,11 +9,13 @@ #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/metrics/histogram_macros.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/task_runner_util.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/sequenced_worker_pool.h" #include "content/browser/media/capture/web_contents_video_capture_device.h" #include "content/browser/media/media_internals.h" @@ -224,9 +226,9 @@ int VideoCaptureManager::Open(const StreamDeviceInfo& device_info) { // Notify our listener asynchronously; this ensures that we return // |capture_session_id| to the caller of this function before using that same // id in a listener event. - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(&VideoCaptureManager::OnOpened, this, - device_info.device.type, capture_session_id)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&VideoCaptureManager::OnOpened, this, + device_info.device.type, capture_session_id)); return capture_session_id; } @@ -255,9 +257,9 @@ void VideoCaptureManager::Close(int capture_session_id) { } // Notify listeners asynchronously, and forget the session. - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(&VideoCaptureManager::OnClosed, this, session_it->second.type, - capture_session_id)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&VideoCaptureManager::OnClosed, this, + session_it->second.type, capture_session_id)); sessions_.erase(session_it); } diff --git a/content/browser/renderer_host/media/video_capture_manager_unittest.cc b/content/browser/renderer_host/media/video_capture_manager_unittest.cc index a8e45ad..832b0dc 100644 --- a/content/browser/renderer_host/media/video_capture_manager_unittest.cc +++ b/content/browser/renderer_host/media/video_capture_manager_unittest.cc @@ -9,7 +9,6 @@ #include "base/bind.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/renderer_host/media/media_stream_provider.h" @@ -88,7 +87,7 @@ class VideoCaptureManagerTest : public testing::Test { vcm_->video_capture_device_factory()); const int32 kNumberOfFakeDevices = 2; video_capture_device_factory_->set_number_of_devices(kNumberOfFakeDevices); - vcm_->Register(listener_.get(), message_loop_->message_loop_proxy().get()); + vcm_->Register(listener_.get(), message_loop_->task_runner().get()); frame_observer_.reset(new MockFrameObserver()); } diff --git a/content/browser/renderer_host/p2p/socket_host_tcp.cc b/content/browser/renderer_host/p2p/socket_host_tcp.cc index a92e3e5..dd49bff 100644 --- a/content/browser/renderer_host/p2p/socket_host_tcp.cc +++ b/content/browser/renderer_host/p2p/socket_host_tcp.cc @@ -4,6 +4,8 @@ #include "content/browser/renderer_host/p2p/socket_host_tcp.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/sys_byteorder.h" #include "content/common/p2p_messages.h" #include "ipc/ipc_sender.h" @@ -117,10 +119,9 @@ bool P2PSocketHostTcpBase::Init(const net::IPEndPoint& local_address, // the connect always happens asynchronously. base::MessageLoop* message_loop = base::MessageLoop::current(); CHECK(message_loop); - message_loop->PostTask( - FROM_HERE, - base::Bind(&P2PSocketHostTcpBase::OnConnected, - base::Unretained(this), status)); + message_loop->task_runner()->PostTask( + FROM_HERE, base::Bind(&P2PSocketHostTcpBase::OnConnected, + base::Unretained(this), status)); } return state_ != STATE_ERROR; diff --git a/content/browser/renderer_host/pepper/quota_reservation_unittest.cc b/content/browser/renderer_host/pepper/quota_reservation_unittest.cc index 6eb6f13..5d7445b 100644 --- a/content/browser/renderer_host/pepper/quota_reservation_unittest.cc +++ b/content/browser/renderer_host/pepper/quota_reservation_unittest.cc @@ -9,8 +9,10 @@ #include "base/files/file.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "storage/browser/fileapi/quota/quota_reservation.h" #include "testing/gtest/include/gtest/gtest.h" @@ -40,7 +42,7 @@ class FakeBackend : public QuotaReservationManager::QuotaBackend { storage::FileSystemType type, int64 delta, const QuotaReservationManager::ReserveQuotaCallback& callback) override { - base::MessageLoopProxy::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(base::IgnoreResult(callback), base::File::FILE_OK, delta)); } diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index f32d2bb..d4da1d4 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -19,12 +19,14 @@ #include "base/debug/dump_without_crashing.h" #include "base/files/file.h" #include "base/lazy_instance.h" +#include "base/location.h" #include "base/logging.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/process/process_handle.h" #include "base/profiler/scoped_tracker.h" #include "base/rand_util.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index b987fbf..74f7ff4 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -14,9 +14,10 @@ #include "base/containers/hash_tables.h" #include "base/i18n/rtl.h" #include "base/lazy_instance.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/thread_task_runner_handle.h" @@ -1534,10 +1535,9 @@ void RenderWidgetHostImpl::OnUpdateRect( bool post_callback = new_auto_size_.IsEmpty(); new_auto_size_ = params.view_size; if (post_callback) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&RenderWidgetHostImpl::DelayedAutoResized, - weak_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&RenderWidgetHostImpl::DelayedAutoResized, + weak_factory_.GetWeakPtr())); } } diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index fc691c7..1787f66 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc @@ -5,8 +5,11 @@ #include "base/basictypes.h" #include "base/bind.h" #include "base/command_line.h" +#include "base/location.h" #include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/timer/timer.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/gpu/compositor_util.h" @@ -979,9 +982,8 @@ TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) { host_->StartHangMonitorTimeout(TimeDelta::FromSeconds(30)); // Wait long enough for first timeout and see if it fired. - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::MessageLoop::QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); base::MessageLoop::current()->Run(); EXPECT_TRUE(host_->unresponsive_timer_fired()); @@ -999,9 +1001,8 @@ TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) { host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); // Wait long enough for first timeout and see if it fired. - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::MessageLoop::QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); base::MessageLoop::current()->Run(); EXPECT_TRUE(host_->unresponsive_timer_fired()); @@ -1018,9 +1019,8 @@ TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) { host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(20)); // Wait long enough for the second timeout and see if it fired. - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::MessageLoop::QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(25)); base::MessageLoop::current()->Run(); EXPECT_TRUE(host_->unresponsive_timer_fired()); @@ -1037,18 +1037,16 @@ TEST_F(RenderWidgetHostTest, HangMonitorTimeoutDisabledForInputWhenHidden) { // The timeout should not fire. EXPECT_FALSE(host_->unresponsive_timer_fired()); - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::MessageLoop::QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), TimeDelta::FromMicroseconds(2)); base::MessageLoop::current()->Run(); EXPECT_FALSE(host_->unresponsive_timer_fired()); // The timeout should never reactivate while hidden. SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false); - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::MessageLoop::QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), TimeDelta::FromMicroseconds(2)); base::MessageLoop::current()->Run(); EXPECT_FALSE(host_->unresponsive_timer_fired()); @@ -1056,9 +1054,8 @@ TEST_F(RenderWidgetHostTest, HangMonitorTimeoutDisabledForInputWhenHidden) { // Showing the widget should restore the timeout, as the events have // not yet been ack'ed. host_->WasShown(ui::LatencyInfo()); - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::MessageLoop::QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), TimeDelta::FromMicroseconds(2)); base::MessageLoop::current()->Run(); EXPECT_TRUE(host_->unresponsive_timer_fired()); @@ -1079,9 +1076,8 @@ TEST_F(RenderWidgetHostTest, MultipleInputEvents) { INPUT_EVENT_ACK_STATE_CONSUMED); // Wait long enough for first timeout and see if it fired. - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::MessageLoop::QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), TimeDelta::FromMicroseconds(20)); base::MessageLoop::current()->Run(); EXPECT_TRUE(host_->unresponsive_timer_fired()); diff --git a/content/browser/renderer_host/render_widget_host_view_browsertest.cc b/content/browser/renderer_host/render_widget_host_view_browsertest.cc index 7e6794a..464b915 100644 --- a/content/browser/renderer_host/render_widget_host_view_browsertest.cc +++ b/content/browser/renderer_host/render_widget_host_view_browsertest.cc @@ -4,9 +4,11 @@ #include "base/barrier_closure.h" #include "base/command_line.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" #include "base/path_service.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/gpu/compositor_util.h" #include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/renderer_host/dip_util.h" @@ -129,15 +131,16 @@ class RenderWidgetHostViewBrowserTest : public ContentBrowserTest { } // Callback when using frame subscriber API. - void FrameDelivered(const scoped_refptr<base::MessageLoopProxy>& loop, - base::Closure quit_closure, - base::TimeTicks timestamp, - bool frame_captured) { + void FrameDelivered( + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, + base::Closure quit_closure, + base::TimeTicks timestamp, + bool frame_captured) { ++callback_invoke_count_; if (frame_captured) ++frames_captured_; if (!quit_closure.is_null()) - loop->PostTask(FROM_HERE, quit_closure); + task_runner->PostTask(FROM_HERE, quit_closure); } // Copy one frame using the CopyFromBackingStore API. @@ -182,9 +185,8 @@ class RenderWidgetHostViewBrowserTest : public ContentBrowserTest { // call stack. static void GiveItSomeTime() { base::RunLoop run_loop; - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - run_loop.QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromMilliseconds(10)); run_loop.Run(); } @@ -339,11 +341,10 @@ IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, base::RunLoop run_loop; scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber( - new FakeFrameSubscriber( - base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, - base::Unretained(this), - base::MessageLoopProxy::current(), - run_loop.QuitClosure()))); + new FakeFrameSubscriber(base::Bind( + &RenderWidgetHostViewBrowserTest::FrameDelivered, + base::Unretained(this), base::ThreadTaskRunnerHandle::Get(), + run_loop.QuitClosure()))); view->BeginFrameSubscription(subscriber.Pass()); run_loop.Run(); view->EndFrameSubscription(); @@ -373,12 +374,12 @@ IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, CopyTwice) { view->CopyFromCompositingSurfaceToVideoFrame( gfx::Rect(view->GetViewBounds().size()), first_output, base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, - base::Unretained(this), base::MessageLoopProxy::current(), + base::Unretained(this), base::ThreadTaskRunnerHandle::Get(), closure, base::TimeTicks::Now())); view->CopyFromCompositingSurfaceToVideoFrame( gfx::Rect(view->GetViewBounds().size()), second_output, base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, - base::Unretained(this), base::MessageLoopProxy::current(), + base::Unretained(this), base::ThreadTaskRunnerHandle::Get(), closure, base::TimeTicks::Now())); run_loop.Run(); diff --git a/content/browser/renderer_host/websocket_host.cc b/content/browser/renderer_host/websocket_host.cc index cd8dd25..801cee0 100644 --- a/content/browser/renderer_host/websocket_host.cc +++ b/content/browser/renderer_host/websocket_host.cc @@ -5,8 +5,11 @@ #include "content/browser/renderer_host/websocket_host.h" #include "base/basictypes.h" +#include "base/location.h" #include "base/memory/weak_ptr.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/renderer_host/websocket_dispatcher_host.h" #include "content/browser/ssl/ssl_error_handler.h" #include "content/browser/ssl/ssl_manager.h" @@ -355,14 +358,10 @@ void WebSocketHost::OnAddChannelRequest( DCHECK(!channel_); if (delay_ > base::TimeDelta()) { - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, - base::Bind(&WebSocketHost::AddChannel, - weak_ptr_factory_.GetWeakPtr(), - socket_url, - requested_protocols, - origin, - render_frame_id), + base::Bind(&WebSocketHost::AddChannel, weak_ptr_factory_.GetWeakPtr(), + socket_url, requested_protocols, origin, render_frame_id), delay_); } else { AddChannel(socket_url, requested_protocols, origin, render_frame_id); @@ -394,11 +393,10 @@ void WebSocketHost::AddChannel( // We post OnFlowControl() here using |weak_ptr_factory_| instead of // calling SendFlowControl directly, because |this| may have been deleted // after channel_->SendAddChannelRequest(). - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&WebSocketHost::OnFlowControl, - weak_ptr_factory_.GetWeakPtr(), - pending_flow_control_quota_)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&WebSocketHost::OnFlowControl, + weak_ptr_factory_.GetWeakPtr(), + pending_flow_control_quota_)); pending_flow_control_quota_ = 0; } diff --git a/content/browser/service_worker/service_worker_context_core.cc b/content/browser/service_worker/service_worker_context_core.cc index a76f774..fef7bcd 100644 --- a/content/browser/service_worker/service_worker_context_core.cc +++ b/content/browser/service_worker/service_worker_context_core.cc @@ -8,8 +8,10 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/files/file_path.h" +#include "base/location.h" #include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/service_worker/embedded_worker_registry.h" #include "content/browser/service_worker/service_worker_context_observer.h" #include "content/browser/service_worker/service_worker_context_wrapper.h" @@ -446,7 +448,7 @@ int ServiceWorkerContextCore::GetNewRegistrationHandleId() { void ServiceWorkerContextCore::ScheduleDeleteAndStartOver() const { storage_->Disable(); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&ServiceWorkerContextWrapper::DeleteAndStartOver, wrapper_)); } diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc index d4a189c..264c9ce 100644 --- a/content/browser/service_worker/service_worker_context_wrapper.cc +++ b/content/browser/service_worker/service_worker_context_wrapper.cc @@ -13,8 +13,11 @@ #include "base/bind.h" #include "base/files/file_path.h" #include "base/lazy_instance.h" +#include "base/location.h" #include "base/logging.h" #include "base/profiler/scoped_tracker.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/sequenced_worker_pool.h" #include "content/browser/service_worker/service_worker_context_core.h" #include "content/browser/service_worker/service_worker_context_observer.h" @@ -41,7 +44,7 @@ base::LazyInstance<HeaderNameSet> g_excluded_header_name_set = LAZY_INSTANCE_INITIALIZER; void RunSoon(const base::Closure& closure) { - base::MessageLoop::current()->PostTask(FROM_HERE, closure); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); } void WorkerStarted(const ServiceWorkerContextWrapper::StatusCallback& callback, diff --git a/content/browser/service_worker/service_worker_register_job.cc b/content/browser/service_worker/service_worker_register_job.cc index 6ab1db6..c4f7754 100644 --- a/content/browser/service_worker/service_worker_register_job.cc +++ b/content/browser/service_worker/service_worker_register_job.cc @@ -6,7 +6,9 @@ #include <vector> -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/service_worker/service_worker_context_core.h" #include "content/browser/service_worker/service_worker_job_coordinator.h" #include "content/browser/service_worker/service_worker_metrics.h" @@ -21,7 +23,7 @@ namespace content { namespace { void RunSoon(const base::Closure& closure) { - base::MessageLoop::current()->PostTask(FROM_HERE, closure); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); } } // namespace diff --git a/content/browser/service_worker/service_worker_url_request_job.cc b/content/browser/service_worker/service_worker_url_request_job.cc index 2db0cfb..0123a2e 100644 --- a/content/browser/service_worker/service_worker_url_request_job.cc +++ b/content/browser/service_worker/service_worker_url_request_job.cc @@ -10,8 +10,11 @@ #include "base/bind.h" #include "base/guid.h" +#include "base/location.h" #include "base/memory/scoped_vector.h" +#include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/browser/resource_context_impl.h" #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" @@ -320,10 +323,9 @@ ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() { void ServiceWorkerURLRequestJob::MaybeStartRequest() { if (is_started_ && response_type_ != NOT_DETERMINED) { // Start asynchronously. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&ServiceWorkerURLRequestJob::StartRequest, - weak_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ServiceWorkerURLRequestJob::StartRequest, + weak_factory_.GetWeakPtr())); } } diff --git a/content/browser/service_worker/service_worker_url_request_job_unittest.cc b/content/browser/service_worker/service_worker_url_request_job_unittest.cc index 9e8462a..2d709d0 100644 --- a/content/browser/service_worker/service_worker_url_request_job_unittest.cc +++ b/content/browser/service_worker/service_worker_url_request_job_unittest.cc @@ -101,8 +101,8 @@ class MockHttpProtocolHandler // the memory. storage::BlobProtocolHandler* CreateMockBlobProtocolHandler( storage::BlobStorageContext* blob_storage_context) { - // The FileSystemContext and MessageLoopProxy are not actually used but a - // MessageLoopProxy is needed to avoid a DCHECK in BlobURLRequestJob ctor. + // The FileSystemContext and task runner are not actually used but a + // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. return new storage::BlobProtocolHandler( blob_storage_context, nullptr, base::ThreadTaskRunnerHandle::Get().get()); } diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc index 9964b8a..9bca8ee 100644 --- a/content/browser/service_worker/service_worker_version.cc +++ b/content/browser/service_worker/service_worker_version.cc @@ -5,11 +5,14 @@ #include "content/browser/service_worker/service_worker_version.h" #include "base/command_line.h" +#include "base/location.h" #include "base/memory/ref_counted.h" #include "base/metrics/histogram_macros.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/browser/bad_message.h" #include "content/browser/child_process_security_policy_impl.h" @@ -72,7 +75,7 @@ const char kClaimClientsShutdownErrorMesage[] = void RunSoon(const base::Closure& callback) { if (!callback.is_null()) - base::MessageLoop::current()->PostTask(FROM_HERE, callback); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); } template <typename CallbackArray, typename Arg> diff --git a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc index 5fc56c4..7f6aabc 100644 --- a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc +++ b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc @@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/fileapi/mock_url_request_delegate.h" #include "content/browser/service_worker/embedded_worker_test_helper.h" #include "content/browser/service_worker/service_worker_context_core.h" @@ -95,10 +98,9 @@ class SSLCertificateErrorJob : public net::URLRequestTestJob { auto_advance), weak_factory_(this) {} void Start() override { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&SSLCertificateErrorJob::NotifyError, - weak_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&SSLCertificateErrorJob::NotifyError, + weak_factory_.GetWeakPtr())); } void NotifyError() { net::SSLInfo info; diff --git a/content/browser/shareable_file_reference_unittest.cc b/content/browser/shareable_file_reference_unittest.cc index 84d035f..c2dae30 100644 --- a/content/browser/shareable_file_reference_unittest.cc +++ b/content/browser/shareable_file_reference_unittest.cc @@ -6,8 +6,9 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "testing/gtest/include/gtest/gtest.h" using storage::ShareableFileReference; @@ -16,8 +17,8 @@ namespace content { TEST(ShareableFileReferenceTest, TestReferences) { base::MessageLoop message_loop; - scoped_refptr<base::MessageLoopProxy> loop_proxy = - base::MessageLoopProxy::current(); + scoped_refptr<base::SingleThreadTaskRunner> task_runner = + base::ThreadTaskRunnerHandle::Get(); base::ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); @@ -31,7 +32,7 @@ TEST(ShareableFileReferenceTest, TestReferences) { reference1 = ShareableFileReference::Get(file); EXPECT_FALSE(reference1.get()); reference1 = ShareableFileReference::GetOrCreate( - file, ShareableFileReference::DELETE_ON_FINAL_RELEASE, loop_proxy.get()); + file, ShareableFileReference::DELETE_ON_FINAL_RELEASE, task_runner.get()); EXPECT_TRUE(reference1.get()); EXPECT_TRUE(file == reference1->path()); @@ -40,7 +41,7 @@ TEST(ShareableFileReferenceTest, TestReferences) { reference2 = ShareableFileReference::Get(file); EXPECT_EQ(reference1.get(), reference2.get()); reference2 = ShareableFileReference::GetOrCreate( - file, ShareableFileReference::DELETE_ON_FINAL_RELEASE, loop_proxy.get()); + file, ShareableFileReference::DELETE_ON_FINAL_RELEASE, task_runner.get()); EXPECT_EQ(reference1.get(), reference2.get()); // Drop the first reference, the file and reference should still be there. diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc index b7595bc5..39effd9 100644 --- a/content/browser/site_per_process_browsertest.cc +++ b/content/browser/site_per_process_browsertest.cc @@ -8,8 +8,11 @@ #include <vector> #include "base/command_line.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/frame_host/cross_process_frame_connector.h" #include "content/browser/frame_host/frame_tree.h" #include "content/browser/frame_host/navigator.h" @@ -431,7 +434,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, // TODO(lazyboy): Find a better way to avoid sleeping like this. See // http://crbug.com/405282 for details. base::RunLoop run_loop; - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromMilliseconds(10)); run_loop.Run(); diff --git a/content/browser/speech/speech_recognition_browsertest.cc b/content/browser/speech/speech_recognition_browsertest.cc index 8bc0749..ee5e28e 100644 --- a/content/browser/speech/speech_recognition_browsertest.cc +++ b/content/browser/speech/speech_recognition_browsertest.cc @@ -5,9 +5,12 @@ #include <list> #include "base/bind.h" +#include "base/location.h" #include "base/memory/scoped_ptr.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/speech/google_streaming_remote_engine.h" #include "content/browser/speech/speech_recognition_manager_impl.h" #include "content/browser/speech/speech_recognizer_impl.h" @@ -166,11 +169,11 @@ class SpeechRecognitionBrowserTest : const int n_buffers = duration_ms / ms_per_buffer; for (int i = 0; i < n_buffers; ++i) { - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( - &FeedSingleBufferToAudioController, - scoped_refptr<media::TestAudioInputController>(controller), - buffer_size, - feed_with_noise)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::Bind(&FeedSingleBufferToAudioController, + scoped_refptr<media::TestAudioInputController>(controller), + buffer_size, feed_with_noise)); } } diff --git a/content/browser/speech/speech_recognition_manager_impl.cc b/content/browser/speech/speech_recognition_manager_impl.cc index f02c29f..019abe1 100644 --- a/content/browser/speech/speech_recognition_manager_impl.cc +++ b/content/browser/speech/speech_recognition_manager_impl.cc @@ -5,6 +5,9 @@ #include "content/browser/speech/speech_recognition_manager_impl.h" #include "base/bind.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/browser_main_loop.h" #include "content/browser/renderer_host/media/media_stream_manager.h" #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" @@ -210,21 +213,17 @@ void SpeechRecognitionManagerImpl::RecognitionAllowedCallback(int session_id, } if (is_allowed) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, - weak_factory_.GetWeakPtr(), - session_id, - EVENT_START)); + weak_factory_.GetWeakPtr(), session_id, EVENT_START)); } else { OnRecognitionError(session_id, SpeechRecognitionError( SPEECH_RECOGNITION_ERROR_NOT_ALLOWED)); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, - weak_factory_.GetWeakPtr(), - session_id, - EVENT_ABORT)); + weak_factory_.GetWeakPtr(), session_id, EVENT_ABORT)); } } @@ -267,12 +266,10 @@ void SpeechRecognitionManagerImpl::AbortSession(int session_id) { iter->second->abort_requested = true; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, - weak_factory_.GetWeakPtr(), - session_id, - EVENT_ABORT)); + weak_factory_.GetWeakPtr(), session_id, EVENT_ABORT)); } void SpeechRecognitionManagerImpl::StopAudioCaptureForSession(int session_id) { @@ -283,12 +280,10 @@ void SpeechRecognitionManagerImpl::StopAudioCaptureForSession(int session_id) { SessionsTable::iterator iter = sessions_.find(session_id); iter->second->ui.reset(); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, - weak_factory_.GetWeakPtr(), - session_id, - EVENT_STOP_CAPTURE)); + weak_factory_.GetWeakPtr(), session_id, EVENT_STOP_CAPTURE)); } // Here begins the SpeechRecognitionEventListener interface implementation, @@ -372,12 +367,10 @@ void SpeechRecognitionManagerImpl::OnAudioEnd(int session_id) { delegate_listener->OnAudioEnd(session_id); if (SpeechRecognitionEventListener* listener = GetListener(session_id)) listener->OnAudioEnd(session_id); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, - weak_factory_.GetWeakPtr(), - session_id, - EVENT_AUDIO_ENDED)); + weak_factory_.GetWeakPtr(), session_id, EVENT_AUDIO_ENDED)); } void SpeechRecognitionManagerImpl::OnRecognitionResults( @@ -425,12 +418,10 @@ void SpeechRecognitionManagerImpl::OnRecognitionEnd(int session_id) { delegate_listener->OnRecognitionEnd(session_id); if (SpeechRecognitionEventListener* listener = GetListener(session_id)) listener->OnRecognitionEnd(session_id); - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, - weak_factory_.GetWeakPtr(), - session_id, - EVENT_RECOGNITION_ENDED)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, + weak_factory_.GetWeakPtr(), session_id, + EVENT_RECOGNITION_ENDED)); } int SpeechRecognitionManagerImpl::GetSession( diff --git a/content/browser/speech/speech_recognizer_impl_unittest.cc b/content/browser/speech/speech_recognizer_impl_unittest.cc index ba6b06a..320ca81 100644 --- a/content/browser/speech/speech_recognizer_impl_unittest.cc +++ b/content/browser/speech/speech_recognizer_impl_unittest.cc @@ -19,7 +19,6 @@ #include "net/url_request/url_request_status.h" #include "testing/gtest/include/gtest/gtest.h" -using base::MessageLoopProxy; using media::AudioInputController; using media::AudioInputStream; using media::AudioManager; @@ -58,7 +57,7 @@ class SpeechRecognizerImplTest : public SpeechRecognitionEventListener, recognizer_ = new SpeechRecognizerImpl( this, kTestingSessionId, false, false, sr_engine); audio_manager_.reset(new media::MockAudioManager( - base::MessageLoop::current()->message_loop_proxy().get())); + base::MessageLoop::current()->task_runner().get())); recognizer_->SetAudioManagerForTesting(audio_manager_.get()); int audio_packet_length_bytes = diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc index 0545c3a..ceb2d23 100644 --- a/content/browser/storage_partition_impl.cc +++ b/content/browser/storage_partition_impl.cc @@ -7,7 +7,9 @@ #include <set> #include <vector> +#include "base/location.h" #include "base/sequenced_task_runner.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "content/browser/browser_main_loop.h" #include "content/browser/fileapi/browser_file_system_helper.h" @@ -484,8 +486,10 @@ StoragePartitionImpl* StoragePartitionImpl::Create( base::SequencedTaskRunner* idb_task_runner = BrowserThread::CurrentlyOn(BrowserThread::UI) && BrowserMainLoop::GetInstance() - ? BrowserMainLoop::GetInstance()->indexed_db_thread() - ->message_loop_proxy().get() + ? BrowserMainLoop::GetInstance() + ->indexed_db_thread() + ->task_runner() + .get() : NULL; scoped_refptr<IndexedDBContextImpl> indexed_db_context = new IndexedDBContextImpl(path, diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc index 7ba28d7..8b99d04 100644 --- a/content/browser/storage_partition_impl_map.cc +++ b/content/browser/storage_partition_impl_map.cc @@ -9,10 +9,13 @@ #include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/files/file_util.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/sequenced_worker_pool.h" #include "content/browser/appcache/appcache_interceptor.h" #include "content/browser/appcache/chrome_appcache_service.h" @@ -521,7 +524,7 @@ void StoragePartitionImplMap::AsyncObliterate( FROM_HERE, base::Bind(&BlockingObliteratePath, browser_context_->GetPath(), domain_root, paths_to_keep, - base::MessageLoopProxy::current(), on_gc_required)); + base::ThreadTaskRunnerHandle::Get(), on_gc_required)); } void StoragePartitionImplMap::GarbageCollect( diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc index a2950c8..79e33beb2 100644 --- a/content/browser/storage_partition_impl_unittest.cc +++ b/content/browser/storage_partition_impl_unittest.cc @@ -3,8 +3,10 @@ // found in the LICENSE file. #include "base/files/file_util.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/gpu/shader_disk_cache.h" @@ -403,11 +405,11 @@ TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) { EXPECT_EQ(1u, Size()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind( - &ClearData, - BrowserContext::GetDefaultStoragePartition(browser_context()), - &run_loop)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::Bind(&ClearData, + BrowserContext::GetDefaultStoragePartition(browser_context()), + &run_loop)); run_loop.Run(); EXPECT_EQ(0u, Size()); } @@ -475,7 +477,7 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverBoth) { GetMockManager()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); run_loop.Run(); @@ -502,7 +504,7 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyTemporary) { GetMockManager()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); run_loop.Run(); @@ -529,7 +531,7 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyPersistent) { GetMockManager()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); run_loop.Run(); @@ -554,7 +556,7 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverNeither) { GetMockManager()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); run_loop.Run(); @@ -581,10 +583,9 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverSpecificOrigin) { GetMockManager()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&ClearQuotaDataForOrigin, - partition, kOrigin1, base::Time(), - &run_loop)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ClearQuotaDataForOrigin, partition, kOrigin1, + base::Time(), &run_loop)); run_loop.Run(); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, @@ -610,11 +611,10 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastHour) { GetMockManager()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&ClearQuotaDataForOrigin, - partition, GURL(), - base::Time::Now() - base::TimeDelta::FromHours(1), - &run_loop)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::Bind(&ClearQuotaDataForOrigin, partition, GURL(), + base::Time::Now() - base::TimeDelta::FromHours(1), &run_loop)); run_loop.Run(); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, @@ -639,11 +639,10 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastWeek) { BrowserContext::GetDefaultStoragePartition(browser_context())); partition->OverrideQuotaManagerForTesting( GetMockManager()); - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&ClearQuotaDataForNonPersistent, - partition, - base::Time::Now() - base::TimeDelta::FromDays(7), - &run_loop)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::Bind(&ClearQuotaDataForNonPersistent, partition, + base::Time::Now() - base::TimeDelta::FromDays(7), &run_loop)); run_loop.Run(); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, @@ -675,9 +674,8 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedUnprotectedOrigins) { partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, - partition, GURL(), + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, partition, GURL(), base::Bind(&DoesOriginMatchForUnprotectedWeb), base::Time(), &run_loop)); run_loop.Run(); @@ -712,11 +710,11 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedProtectedSpecificOrigin) { // Try to remove kOrigin1. Expect failure. base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, - partition, kOrigin1, - base::Bind(&DoesOriginMatchForUnprotectedWeb), - base::Time(), &run_loop)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::Bind(&ClearQuotaDataWithOriginMatcher, partition, kOrigin1, + base::Bind(&DoesOriginMatchForUnprotectedWeb), base::Time(), + &run_loop)); run_loop.Run(); EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, @@ -748,10 +746,9 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedProtectedOrigins) { partition->OverrideQuotaManagerForTesting( GetMockManager()); partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, - base::Bind(&ClearQuotaDataWithOriginMatcher, - partition, GURL(), + base::Bind(&ClearQuotaDataWithOriginMatcher, partition, GURL(), base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), base::Time(), &run_loop)); run_loop.Run(); @@ -778,9 +775,8 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedIgnoreDevTools) { BrowserContext::GetDefaultStoragePartition(browser_context())); partition->OverrideQuotaManagerForTesting( GetMockManager()); - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, - partition, GURL(), + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, partition, GURL(), base::Bind(&DoesOriginMatchUnprotected), base::Time(), &run_loop)); run_loop.Run(); @@ -803,10 +799,9 @@ TEST_F(StoragePartitionImplTest, RemoveCookieForever) { partition->SetURLRequestContext(browser_context()->GetRequestContext()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&ClearCookies, - partition, base::Time(), base::Time::Max(), - &run_loop)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ClearCookies, partition, base::Time(), + base::Time::Max(), &run_loop)); run_loop.Run(); EXPECT_FALSE(tester.ContainsCookie()); @@ -824,10 +819,9 @@ TEST_F(StoragePartitionImplTest, RemoveCookieLastHour) { partition->SetURLRequestContext(browser_context()->GetRequestContext()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&ClearCookies, - partition, an_hour_ago, base::Time::Max(), - &run_loop)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ClearCookies, partition, an_hour_ago, + base::Time::Max(), &run_loop)); run_loop.Run(); EXPECT_FALSE(tester.ContainsCookie()); @@ -851,13 +845,12 @@ TEST_F(StoragePartitionImplTest, RemoveUnprotectedLocalStorageForever) { partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&ClearStuff, StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, partition, base::Time(), base::Time::Max(), - base::Bind(&DoesOriginMatchForUnprotectedWeb), - &run_loop)); + base::Bind(&DoesOriginMatchForUnprotectedWeb), &run_loop)); run_loop.Run(); EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); @@ -883,7 +876,7 @@ TEST_F(StoragePartitionImplTest, RemoveProtectedLocalStorageForever) { partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&ClearStuff, StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, @@ -912,7 +905,7 @@ TEST_F(StoragePartitionImplTest, RemoveLocalStorageForLastWeek) { base::Time a_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7); base::RunLoop run_loop; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&ClearStuff, StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, diff --git a/content/browser/streams/stream.cc b/content/browser/streams/stream.cc index fb36ad9..3f4ae680 100644 --- a/content/browser/streams/stream.cc +++ b/content/browser/streams/stream.cc @@ -6,7 +6,8 @@ #include "base/bind.h" #include "base/location.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" #include "content/browser/streams/stream_handle_impl.h" #include "content/browser/streams/stream_read_observer.h" @@ -35,11 +36,9 @@ Stream::Stream(StreamRegistry* registry, write_observer_(write_observer), stream_handle_(NULL), weak_ptr_factory_(this) { - CreateByteStream(base::MessageLoopProxy::current(), - base::MessageLoopProxy::current(), - kDeferSizeThreshold, - &writer_, - &reader_); + CreateByteStream(base::ThreadTaskRunnerHandle::Get(), + base::ThreadTaskRunnerHandle::Get(), kDeferSizeThreshold, + &writer_, &reader_); // Setup callback for writing. writer_->RegisterCallback(base::Bind(&Stream::OnSpaceAvailable, @@ -122,7 +121,7 @@ void Stream::Finalize() { writer_.reset(); // Continue asynchronously. - base::MessageLoopProxy::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&Stream::OnDataAvailable, weak_ptr_factory_.GetWeakPtr())); } diff --git a/content/browser/streams/stream_handle_impl.cc b/content/browser/streams/stream_handle_impl.cc index 5bc2acb..ba4dee2 100644 --- a/content/browser/streams/stream_handle_impl.cc +++ b/content/browser/streams/stream_handle_impl.cc @@ -6,7 +6,7 @@ #include "base/bind.h" #include "base/location.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/streams/stream.h" namespace content { @@ -23,11 +23,12 @@ void RunCloseListeners(const std::vector<base::Closure>& close_listeners) { StreamHandleImpl::StreamHandleImpl(const base::WeakPtr<Stream>& stream) : stream_(stream), url_(stream->url()), - stream_message_loop_(base::MessageLoopProxy::current().get()) {} + stream_task_runner_(base::ThreadTaskRunnerHandle::Get().get()) { +} StreamHandleImpl::~StreamHandleImpl() { - stream_message_loop_->PostTaskAndReply(FROM_HERE, - base::Bind(&Stream::CloseHandle, stream_), + stream_task_runner_->PostTaskAndReply( + FROM_HERE, base::Bind(&Stream::CloseHandle, stream_), base::Bind(&RunCloseListeners, close_listeners_)); } diff --git a/content/browser/streams/stream_handle_impl.h b/content/browser/streams/stream_handle_impl.h index d2bd94d..15e8e20 100644 --- a/content/browser/streams/stream_handle_impl.h +++ b/content/browser/streams/stream_handle_impl.h @@ -11,7 +11,7 @@ #include "content/public/browser/stream_handle.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } namespace content { @@ -30,7 +30,7 @@ class StreamHandleImpl : public StreamHandle { base::WeakPtr<Stream> stream_; GURL url_; - base::MessageLoopProxy* stream_message_loop_; + base::SingleThreadTaskRunner* stream_task_runner_; std::vector<base::Closure> close_listeners_; }; diff --git a/content/browser/streams/stream_url_request_job.cc b/content/browser/streams/stream_url_request_job.cc index 3d4ac7f..d2bce89 100644 --- a/content/browser/streams/stream_url_request_job.cc +++ b/content/browser/streams/stream_url_request_job.cc @@ -4,7 +4,10 @@ #include "content/browser/streams/stream_url_request_job.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/streams/stream.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" @@ -80,7 +83,7 @@ void StreamURLRequestJob::OnDataAvailable(Stream* stream) { // net::URLRequestJob methods. void StreamURLRequestJob::Start() { // Continue asynchronously. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&StreamURLRequestJob::DidStart, weak_factory_.GetWeakPtr())); } diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 51695bc..3cb44c6 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -8,14 +8,17 @@ #include "base/command_line.h" #include "base/lazy_instance.h" +#include "base/location.h" #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/process/process.h" #include "base/profiler/scoped_tracker.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "base/trace_event/trace_event.h" #include "components/mime_util/mime_util.h" @@ -3804,10 +3807,9 @@ void WebContentsImpl::DidChangeLoadProgress() { if (loading_weak_factory_.HasWeakPtrs()) return; - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&WebContentsImpl::SendChangeLoadProgress, - loading_weak_factory_.GetWeakPtr()), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&WebContentsImpl::SendChangeLoadProgress, + loading_weak_factory_.GetWeakPtr()), min_delay); } diff --git a/content/browser/web_contents/web_contents_view_aura_browsertest.cc b/content/browser/web_contents/web_contents_view_aura_browsertest.cc index ccd1689..e9ba331 100644 --- a/content/browser/web_contents/web_contents_view_aura_browsertest.cc +++ b/content/browser/web_contents/web_contents_view_aura_browsertest.cc @@ -5,9 +5,12 @@ #include "content/browser/web_contents/web_contents_view_aura.h" #include "base/command_line.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "base/test/test_timeouts.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" #if defined(OS_WIN) #include "base/win/windows_version.h" @@ -46,9 +49,8 @@ namespace { // for details. void GiveItSomeTime() { base::RunLoop run_loop; - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - run_loop.QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromMillisecondsD(10)); run_loop.Run(); } diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc index 1c171c2..ba1f5d46 100644 --- a/content/browser/webui/url_data_manager_backend.cc +++ b/content/browser/webui/url_data_manager_backend.cc @@ -12,11 +12,12 @@ #include "base/compiler_specific.h" #include "base/debug/alias.h" #include "base/lazy_instance.h" +#include "base/location.h" #include "base/memory/ref_counted.h" #include "base/memory/ref_counted_memory.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/profiler/scoped_tracker.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/trace_event/trace_event.h" @@ -639,19 +640,17 @@ bool URLDataManagerBackend::StartRequest(const net::URLRequest* request, // is guaranteed because request for mime type is placed in the // message loop before request for data. And correspondingly their // replies are put on the IO thread in the same order. - target_message_loop->PostTask( + target_message_loop->task_runner()->PostTask( FROM_HERE, - base::Bind(&GetMimeTypeOnUI, - scoped_refptr<URLDataSourceImpl>(source), + base::Bind(&GetMimeTypeOnUI, scoped_refptr<URLDataSourceImpl>(source), path, job->AsWeakPtr())); // The DataSource wants StartDataRequest to be called on a specific thread, // usually the UI thread, for this path. - target_message_loop->PostTask( - FROM_HERE, - base::Bind(&URLDataManagerBackend::CallStartRequest, - make_scoped_refptr(source), path, render_process_id, - render_frame_id, request_id)); + target_message_loop->task_runner()->PostTask( + FROM_HERE, base::Bind(&URLDataManagerBackend::CallStartRequest, + make_scoped_refptr(source), path, + render_process_id, render_frame_id, request_id)); } return true; } |