From 74f13dc2b62abb34e947093fe2600f9c539e60ef Mon Sep 17 00:00:00 2001 From: skyostil Date: Fri, 5 Jun 2015 08:26:08 -0700 Subject: [PATCH] Revert "content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs" This reverts commit 5d18b2493af36d77d3c491854e3d56f46f5f747c. Reason: Broke iOS build: http://build.chromium.org/p/chromium.mac/builders/iOS_Simulator_%28dbg%29/builds/27843 NOTRY=true NOTREECHECKS=true BUG=465354 TBR=sievers@chromium.org,nick@chromium.org Review URL: https://codereview.chromium.org/1153503009 Cr-Commit-Position: refs/heads/master@{#333047} --- .../fileapi/safe_iapps_library_parser.cc | 4 +- .../cloud_print_proxy_process_browsertest.cc | 6 +- chrome/browser/profiles/profile_io_data.cc | 28 +++--- content/browser/appcache/appcache_group.cc | 9 +- .../appcache_quota_client_unittest.cc | 1 + .../appcache_request_handler_unittest.cc | 15 ++- content/browser/appcache/appcache_response.cc | 6 +- .../appcache/appcache_response_unittest.cc | 11 +-- .../browser/appcache/appcache_service_impl.cc | 5 +- .../appcache/appcache_service_unittest.cc | 9 +- .../browser/appcache/appcache_storage_impl.cc | 26 ++--- .../appcache_storage_impl_unittest.cc | 45 +++++---- .../appcache/appcache_update_job_unittest.cc | 12 +-- .../appcache/appcache_url_request_job.cc | 11 +-- .../appcache_url_request_job_unittest.cc | 14 ++- .../chrome_appcache_service_unittest.cc | 17 ++-- .../browser/appcache/mock_appcache_service.cc | 12 +-- .../browser/appcache/mock_appcache_storage.cc | 11 +-- .../background_sync_manager.cc | 81 +++++++--------- .../background_sync_manager_unittest.cc | 6 +- .../background_sync_network_observer.cc | 6 +- content/browser/browser_main_loop.cc | 23 +++-- .../browser_shutdown_profile_dumper.cc | 11 +-- content/browser/browser_thread_impl.cc | 43 +++++---- content/browser/browser_thread_unittest.cc | 26 +++-- content/browser/byte_stream_unittest.cc | 78 +++++++++------ .../browser/cache_storage/cache_storage.cc | 23 ++--- .../cache_storage/cache_storage_cache.cc | 3 +- .../cache_storage_cache_unittest.cc | 13 +-- .../cache_storage_manager_unittest.cc | 8 +- .../cache_storage/cache_storage_scheduler.cc | 6 +- .../gpu_process_transport_factory.cc | 5 +- content/browser/compositor/reflector_impl.h | 2 + .../compositor/reflector_impl_unittest.cc | 5 +- ...tware_browser_compositor_output_surface.cc | 12 +-- ...wser_compositor_output_surface_unittest.cc | 4 +- .../software_output_device_ozone_unittest.cc | 3 +- .../browser/database_quota_client_unittest.cc | 19 ++-- content/browser/database_tracker_unittest.cc | 20 ++-- .../data_fetcher_shared_memory_base.cc | 16 ++-- .../devtools/devtools_manager_unittest.cc | 13 ++- .../browser/devtools/protocol/page_handler.cc | 10 +- .../devtools/protocol/tethering_handler.h | 1 + .../dom_storage/dom_storage_area_unittest.cc | 35 +++---- .../dom_storage_context_impl_unittest.cc | 4 +- .../dom_storage_context_wrapper.cc | 44 +++++---- .../dom_storage/dom_storage_task_runner.cc | 18 ++-- .../dom_storage/dom_storage_task_runner.h | 11 +-- .../browser/download/download_file_impl.cc | 1 + .../download/download_file_unittest.cc | 18 ++-- .../download/download_resource_handler.cc | 6 +- .../browser/download/drag_download_file.cc | 15 ++- .../fileapi/blob_url_request_job_unittest.cc | 3 +- .../copy_or_move_file_validator_unittest.cc | 7 +- ...opy_or_move_operation_delegate_unittest.cc | 35 ++++--- .../fileapi/dragged_file_util_unittest.cc | 1 + .../fileapi/file_system_browsertest.cc | 2 - .../fileapi/file_system_context_unittest.cc | 23 +++-- ...ile_system_dir_url_request_job_unittest.cc | 7 +- .../file_system_operation_impl_unittest.cc | 12 +-- ...le_system_operation_impl_write_unittest.cc | 11 ++- .../file_system_quota_client_unittest.cc | 1 + .../file_system_url_request_job_unittest.cc | 6 +- .../file_system_usage_cache_unittest.cc | 3 +- .../fileapi/file_writer_delegate_unittest.cc | 10 +- .../local_file_stream_reader_unittest.cc | 6 +- .../local_file_stream_writer_unittest.cc | 6 +- .../fileapi/local_file_util_unittest.cc | 1 + .../fileapi/mock_file_change_observer.cc | 4 +- .../fileapi/obfuscated_file_util_unittest.cc | 18 ++-- ...in_private_file_system_backend_unittest.cc | 1 + .../recursive_operation_delegate_unittest.cc | 7 +- ...x_file_system_backend_delegate_unittest.cc | 9 +- .../sandbox_file_system_backend_unittest.cc | 8 +- .../fileapi/timed_task_helper_unittest.cc | 5 +- .../frame_host/interstitial_page_impl.cc | 11 +-- .../render_frame_host_manager_browsertest.cc | 5 +- content/browser/gamepad/gamepad_provider.cc | 37 ++++---- content/browser/gamepad/gamepad_provider.h | 7 +- .../browser/geofencing/geofencing_service.cc | 6 +- .../geofencing/mock_geofencing_service.cc | 8 +- .../geolocation/fake_access_token_store.cc | 14 +-- .../geolocation/fake_access_token_store.h | 4 +- .../geolocation/geolocation_provider_impl.cc | 6 +- .../geolocation_provider_impl_unittest.cc | 19 ++-- .../location_api_adapter_android.cc | 24 ++--- .../location_api_adapter_android.h | 7 +- .../geolocation/mock_location_provider.cc | 23 +++-- .../geolocation/mock_location_provider.h | 3 +- .../geolocation/network_location_provider.cc | 10 +- .../browser/geolocation/wifi_data_provider.cc | 4 +- .../geolocation/wifi_data_provider_common.cc | 9 +- .../gpu/browser_gpu_channel_host_factory.cc | 17 ++-- content/browser/histogram_synchronizer.cc | 4 +- .../indexed_db/indexed_db_browsertest.cc | 21 ++-- .../indexed_db/indexed_db_quota_client.h | 1 + .../indexed_db_quota_client_unittest.cc | 8 +- .../indexed_db/indexed_db_transaction.cc | 6 +- .../loader/buffered_resource_handler.cc | 5 +- .../resource_dispatcher_host_unittest.cc | 8 +- content/browser/loader/resource_loader.cc | 38 ++++---- .../loader/resource_loader_unittest.cc | 19 ++-- .../upload_data_stream_builder_unittest.cc | 57 +++++++---- .../content_video_capture_device_core.cc | 1 + ...eb_contents_audio_input_stream_unittest.cc | 7 +- .../web_contents_video_capture_device.cc | 9 +- .../browser/media/media_internals_proxy.cc | 6 +- .../net/view_http_cache_job_factory.cc | 6 +- .../platform_notification_context_unittest.cc | 3 +- content/browser/plugin_loader_posix.cc | 11 +-- content/browser/plugin_loader_posix.h | 4 + content/browser/plugin_service_impl.cc | 42 ++++---- content/browser/plugin_service_impl.h | 9 +- .../plugin_service_impl_browsertest.cc | 13 ++- .../power_profiler_service_unittest.cc | 4 +- content/browser/power_save_blocker_x11.cc | 1 + .../presentation_service_impl_unittest.cc | 6 +- content/browser/quota/mock_quota_manager.cc | 20 ++-- .../quota/mock_quota_manager_unittest.cc | 9 +- .../quota/quota_backend_impl_unittest.cc | 4 +- .../browser/quota/quota_manager_unittest.cc | 10 +- .../quota_reservation_manager_unittest.cc | 6 +- ...uota_temporary_storage_evictor_unittest.cc | 1 + .../browser/quota/storage_monitor_unittest.cc | 24 +++-- .../browser/quota/usage_tracker_unittest.cc | 17 ++-- .../renderer_host/compositor_impl_android.cc | 8 +- .../input/gesture_event_queue_unittest.cc | 8 +- .../input/input_router_impl_unittest.cc | 5 +- .../input/touch_event_queue_unittest.cc | 5 +- .../input/touch_input_browsertest.cc | 9 +- .../audio_input_device_manager_unittest.cc | 5 +- .../media_stream_dispatcher_host_unittest.cc | 27 +++--- .../media/media_stream_manager.cc | 3 +- .../media/media_stream_manager_unittest.cc | 10 +- .../video_capture_controller_unittest.cc | 26 +++-- .../media/video_capture_host_unittest.cc | 44 +++++---- .../media/video_capture_manager.cc | 16 ++-- .../media/video_capture_manager_unittest.cc | 3 +- .../renderer_host/p2p/socket_host_tcp.cc | 9 +- .../pepper/quota_reservation_unittest.cc | 6 +- .../renderer_host/render_process_host_impl.cc | 2 - .../renderer_host/render_widget_host_impl.cc | 10 +- .../render_widget_host_unittest.cc | 38 ++++---- .../render_widget_host_view_browsertest.cc | 33 ++++--- .../browser/renderer_host/websocket_host.cc | 22 +++-- .../service_worker_context_core.cc | 4 +- .../service_worker_context_wrapper.cc | 5 +- .../service_worker_register_job.cc | 6 +- .../service_worker_url_request_job.cc | 10 +- ...service_worker_url_request_job_unittest.cc | 4 +- .../service_worker/service_worker_version.cc | 5 +- ...vice_worker_write_to_cache_job_unittest.cc | 10 +- .../shareable_file_reference_unittest.cc | 11 +-- .../browser/site_per_process_browsertest.cc | 5 +- .../speech/speech_recognition_browsertest.cc | 13 +-- .../speech/speech_recognition_manager_impl.cc | 43 +++++---- .../speech/speech_recognizer_impl_unittest.cc | 3 +- content/browser/storage_partition_impl.cc | 8 +- content/browser/storage_partition_impl_map.cc | 5 +- .../storage_partition_impl_unittest.cc | 95 ++++++++++--------- content/browser/streams/stream.cc | 13 +-- content/browser/streams/stream_handle_impl.cc | 9 +- content/browser/streams/stream_handle_impl.h | 4 +- .../browser/streams/stream_url_request_job.cc | 5 +- .../browser/web_contents/web_contents_impl.cc | 10 +- .../web_contents_view_aura_browsertest.cc | 8 +- .../browser/webui/url_data_manager_backend.cc | 17 ++-- content/gpu/gpu_watchdog_thread.cc | 26 ++--- content/public/browser/browser_thread.h | 16 ++-- content/public/browser/devtools_agent_host.h | 5 +- content/public/renderer/render_thread.h | 1 + content/public/test/browser_test_base.cc | 5 +- .../test/fake_speech_recognition_manager.cc | 6 +- content/public/test/frame_load_waiter.cc | 6 +- .../test/mock_blob_url_request_context.cc | 8 +- content/public/test/mock_render_thread.cc | 5 +- content/public/test/mock_storage_client.cc | 22 ++--- content/public/test/render_view_test.cc | 5 +- .../test/sandbox_file_system_test_helper.cc | 1 + .../public/test/test_file_system_context.cc | 34 ++++--- content/public/test/test_utils.cc | 10 +- .../shell/browser/blink_test_controller.cc | 20 ++-- .../layout_test/layout_test_browser_main.cc | 12 +-- content/shell/browser/shell.cc | 8 +- .../shell_url_request_context_getter.cc | 3 +- .../renderer/layout_test/blink_test_runner.cc | 6 +- .../layout_test/test_video_frame_provider.cc | 25 ++--- .../layout_test/test_video_frame_provider.h | 4 +- content/test/content_browser_test_test.cc | 5 +- content/test/fake_compositor_dependencies.cc | 5 +- .../test/net/url_request_abort_on_end_job.cc | 10 +- .../test/test_blink_web_unit_test_support.cc | 2 +- content/utility/in_process_utility_thread.cc | 10 +- .../webthread_impl_for_utility_thread.cc | 4 +- 194 files changed, 1212 insertions(+), 1245 deletions(-) diff --git a/chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.cc b/chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.cc index a4389b7ceed69c..f9dafa91cfb58c 100644 --- a/chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.cc +++ b/chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.cc @@ -64,10 +64,10 @@ void SafeIAppsLibraryParser::StartProcessOnIOThread() { DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_EQ(INITIAL_STATE, parser_state_); - scoped_refptr task_runner = + scoped_refptr message_loop_proxy = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); utility_process_host_ = - UtilityProcessHost::Create(this, task_runner.get())->AsWeakPtr(); + UtilityProcessHost::Create(this, message_loop_proxy.get())->AsWeakPtr(); utility_process_host_->SetName(l10n_util::GetStringUTF16( IDS_UTILITY_PROCESS_MEDIA_LIBRARY_FILE_CHECKER_NAME)); // Wait for the startup notification before sending the main IPC to the diff --git a/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc b/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc index 766693adbd2261..c9cd628d9ca0a3 100644 --- a/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc +++ b/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc @@ -307,7 +307,7 @@ class CloudPrintProxyPolicyStartupTest : public base::MultiProcessTest, void SetUp() override; void TearDown() override; - scoped_refptr IOTaskRunner() { + scoped_refptr IOMessageLoopProxy() { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } base::Process Launch(const std::string& name); @@ -442,7 +442,7 @@ base::Process CloudPrintProxyPolicyStartupTest::Launch( startup_channel_ = IPC::ChannelProxy::Create(startup_channel_id_, IPC::Channel::MODE_SERVER, this, - IOTaskRunner()); + IOMessageLoopProxy()); #if defined(OS_POSIX) base::FileHandleMappingVector ipc_file_list; @@ -467,7 +467,7 @@ void CloudPrintProxyPolicyStartupTest::WaitForConnect() { IPC::ChannelProxy::Create(GetServiceProcessChannel(), IPC::Channel::MODE_NAMED_CLIENT, ServiceProcessControl::GetInstance(), - IOTaskRunner())); + IOMessageLoopProxy())); } bool CloudPrintProxyPolicyStartupTest::Send(IPC::Message* message) { diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index e625178150d05d..6c5b7085f55d0b 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -456,7 +456,7 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { &force_youtube_safety_mode_, pref_service); - scoped_refptr io_task_runner = + scoped_refptr io_message_loop_proxy = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); chrome_http_user_agent_settings_.reset( @@ -467,25 +467,25 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { if (!IsOffTheRecord()) { google_services_user_account_id_.Init( prefs::kGoogleServicesUserAccountId, pref_service); - google_services_user_account_id_.MoveToThread(io_task_runner); + google_services_user_account_id_.MoveToThread(io_message_loop_proxy); sync_disabled_.Init(sync_driver::prefs::kSyncManaged, pref_service); - sync_disabled_.MoveToThread(io_task_runner); + sync_disabled_.MoveToThread(io_message_loop_proxy); signin_allowed_.Init(prefs::kSigninAllowed, pref_service); - signin_allowed_.MoveToThread(io_task_runner); + signin_allowed_.MoveToThread(io_message_loop_proxy); } quick_check_enabled_.Init(prefs::kQuickCheckEnabled, local_state_pref_service); - quick_check_enabled_.MoveToThread(io_task_runner); + quick_check_enabled_.MoveToThread(io_message_loop_proxy); media_device_id_salt_ = new MediaDeviceIDSalt(pref_service, IsOffTheRecord()); network_prediction_options_.Init(prefs::kNetworkPredictionOptions, pref_service); - network_prediction_options_.MoveToThread(io_task_runner); + network_prediction_options_.MoveToThread(io_message_loop_proxy); #if defined(OS_CHROMEOS) scoped_ptr verifier = @@ -505,24 +505,28 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); scoped_refptr background_task_runner = pool->GetSequencedTaskRunner(pool->GetSequenceToken()); - url_blacklist_manager_.reset(new policy::URLBlacklistManager( - pref_service, background_task_runner, io_task_runner, callback, - base::Bind(policy::OverrideBlacklistForURL))); + url_blacklist_manager_.reset( + new policy::URLBlacklistManager( + pref_service, + background_task_runner, + io_message_loop_proxy, + callback, + base::Bind(policy::OverrideBlacklistForURL))); if (!IsOffTheRecord()) { // Add policy headers for non-incognito requests. policy::PolicyHeaderService* policy_header_service = policy::PolicyHeaderServiceFactory::GetForBrowserContext(profile); if (policy_header_service) { - policy_header_helper_ = - policy_header_service->CreatePolicyHeaderIOHelper(io_task_runner); + policy_header_helper_ = policy_header_service->CreatePolicyHeaderIOHelper( + io_message_loop_proxy); } } #endif incognito_availibility_pref_.Init( prefs::kIncognitoModeAvailability, pref_service); - incognito_availibility_pref_.MoveToThread(io_task_runner); + incognito_availibility_pref_.MoveToThread(io_message_loop_proxy); initialized_on_UI_thread_ = true; diff --git a/content/browser/appcache/appcache_group.cc b/content/browser/appcache/appcache_group.cc index dbd089c9a328b9..4e16e7faad6874 100644 --- a/content/browser/appcache/appcache_group.cc +++ b/content/browser/appcache/appcache_group.cc @@ -7,10 +7,8 @@ #include #include "base/bind.h" -#include "base/location.h" #include "base/logging.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.h" #include "content/browser/appcache/appcache.h" #include "content/browser/appcache/appcache_host.h" #include "content/browser/appcache/appcache_service_impl.h" @@ -232,8 +230,9 @@ void AppCacheGroup::ScheduleUpdateRestart(int delay_ms) { DCHECK(restart_update_task_.IsCancelled()); restart_update_task_.Reset( base::Bind(&AppCacheGroup::RunQueuedUpdates, this)); - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, restart_update_task_.callback(), + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + restart_update_task_.callback(), base::TimeDelta::FromMilliseconds(delay_ms)); } diff --git a/content/browser/appcache/appcache_quota_client_unittest.cc b/content/browser/appcache/appcache_quota_client_unittest.cc index de17324034f62c..a453ee1c7739e7 100644 --- a/content/browser/appcache/appcache_quota_client_unittest.cc +++ b/content/browser/appcache/appcache_quota_client_unittest.cc @@ -6,6 +6,7 @@ #include #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 3dbaf8532e76d8..f05fed29544956 100644 --- a/content/browser/appcache/appcache_request_handler_unittest.cc +++ b/content/browser/appcache/appcache_request_handler_unittest.cc @@ -9,10 +9,8 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" #include "base/synchronization/waitable_event.h" -#include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "content/browser/appcache/appcache.h" #include "content/browser/appcache/appcache_backend_impl.h" @@ -182,7 +180,7 @@ class AppCacheRequestHandlerTest : public testing::Test { template void RunTestOnIOThread(Method method) { test_finished_event_ .reset(new base::WaitableEvent(false, false)); - io_thread_->task_runner()->PostTask( + io_thread_->message_loop()->PostTask( FROM_HERE, base::Bind(&AppCacheRequestHandlerTest::MethodWrapper, base::Unretained(this), method)); @@ -223,9 +221,10 @@ class AppCacheRequestHandlerTest : public testing::Test { // We unwind the stack prior to finishing up to let stack // based objects get deleted. DCHECK(base::MessageLoop::current() == io_thread_->message_loop()); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&AppCacheRequestHandlerTest::TestFinishedUnwound, - base::Unretained(this))); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&AppCacheRequestHandlerTest::TestFinishedUnwound, + base::Unretained(this))); } void TestFinishedUnwound() { @@ -243,7 +242,7 @@ class AppCacheRequestHandlerTest : public testing::Test { TestFinished(); return; } - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task_stack_.top()); + base::MessageLoop::current()->PostTask(FROM_HERE, task_stack_.top()); task_stack_.pop(); } diff --git a/content/browser/appcache/appcache_response.cc b/content/browser/appcache/appcache_response.cc index f113adf940d216..66ec22ec81b31e 100644 --- a/content/browser/appcache/appcache_response.cc +++ b/content/browser/appcache/appcache_response.cc @@ -7,14 +7,12 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/compiler_specific.h" -#include "base/location.h" #include "base/logging.h" +#include "base/message_loop/message_loop.h" #include "base/numerics/safe_math.h" #include "base/pickle.h" #include "base/profiler/scoped_tracker.h" -#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" -#include "base/thread_task_runner_handle.h" #include "content/browser/appcache/appcache_storage.h" #include "net/base/completion_callback.h" #include "net/base/io_buffer.h" @@ -92,7 +90,7 @@ AppCacheResponseIO::~AppCacheResponseIO() { } void AppCacheResponseIO::ScheduleIOCompletionCallback(int result) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&AppCacheResponseIO::OnIOComplete, weak_factory_.GetWeakPtr(), result)); } diff --git a/content/browser/appcache/appcache_response_unittest.cc b/content/browser/appcache/appcache_response_unittest.cc index 743a624556f4bd..f5eb417dc69382 100644 --- a/content/browser/appcache/appcache_response_unittest.cc +++ b/content/browser/appcache/appcache_response_unittest.cc @@ -10,11 +10,8 @@ #include "base/bind_helpers.h" #include "base/callback.h" #include "base/compiler_specific.h" -#include "base/location.h" #include "base/pickle.h" -#include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" -#include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "content/browser/appcache/appcache_response.h" #include "content/browser/appcache/mock_appcache_service.h" @@ -78,7 +75,7 @@ class AppCacheResponseTest : public testing::Test { template void RunTestOnIOThread(Method method) { test_finished_event_ .reset(new base::WaitableEvent(false, false)); - io_thread_->task_runner()->PostTask( + io_thread_->message_loop()->PostTask( FROM_HERE, base::Bind(&AppCacheResponseTest::MethodWrapper, base::Unretained(this), method)); test_finished_event_->Wait(); @@ -119,7 +116,7 @@ class AppCacheResponseTest : public testing::Test { // We unwind the stack prior to finishing up to let stack // based objects get deleted. DCHECK(base::MessageLoop::current() == io_thread_->message_loop()); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&AppCacheResponseTest::TestFinishedUnwound, base::Unretained(this))); } @@ -149,7 +146,7 @@ class AppCacheResponseTest : public testing::Test { if (immediate) task.Run(); else - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); + base::MessageLoop::current()->PostTask(FROM_HERE, task); } // Wrappers to call AppCacheResponseReader/Writer Read and Write methods @@ -739,7 +736,7 @@ class AppCacheResponseTest : public testing::Test { reader_.reset(); // Wait a moment to verify no callbacks. - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + base::MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&AppCacheResponseTest::VerifyNoCallbacks, base::Unretained(this)), base::TimeDelta::FromMilliseconds(10)); diff --git a/content/browser/appcache/appcache_service_impl.cc b/content/browser/appcache/appcache_service_impl.cc index 47e81a4d2869d0..0c784dfd3dcc55 100644 --- a/content/browser/appcache/appcache_service_impl.cc +++ b/content/browser/appcache/appcache_service_impl.cc @@ -8,11 +8,10 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/location.h" #include "base/logging.h" +#include "base/message_loop/message_loop.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" -#include "base/thread_task_runner_handle.h" #include "content/browser/appcache/appcache.h" #include "content/browser/appcache/appcache_backend_impl.h" #include "content/browser/appcache/appcache_entry.h" @@ -64,7 +63,7 @@ class AppCacheServiceImpl::AsyncHelper void CallCallback(int rv) { if (!callback_.is_null()) { // Defer to guarantee async completion. - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&DeferredCallback, callback_, rv)); } callback_.Reset(); diff --git a/content/browser/appcache/appcache_service_unittest.cc b/content/browser/appcache/appcache_service_unittest.cc index 62e6a4dbe0b216..4159245710c116 100644 --- a/content/browser/appcache/appcache_service_unittest.cc +++ b/content/browser/appcache/appcache_service_unittest.cc @@ -6,11 +6,8 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/location.h" #include "base/pickle.h" #include "base/run_loop.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" #include "content/browser/appcache/appcache_response.h" #include "content/browser/appcache/appcache_service_impl.h" #include "content/browser/appcache/mock_appcache_storage.h" @@ -70,9 +67,9 @@ class MockResponseReader : public AppCacheResponseReader { private: void ScheduleUserCallback(int result) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&MockResponseReader::InvokeUserCompletionCallback, - weak_factory_.GetWeakPtr(), result)); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(&MockResponseReader::InvokeUserCompletionCallback, + weak_factory_.GetWeakPtr(), result)); } scoped_ptr info_; diff --git a/content/browser/appcache/appcache_storage_impl.cc b/content/browser/appcache/appcache_storage_impl.cc index 7494f5a4666f3c..3653488f188485 100644 --- a/content/browser/appcache/appcache_storage_impl.cc +++ b/content/browser/appcache/appcache_storage_impl.cc @@ -12,13 +12,12 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/files/file_util.h" -#include "base/location.h" #include "base/logging.h" +#include "base/message_loop/message_loop.h" #include "base/profiler/scoped_tracker.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/strings/string_util.h" -#include "base/thread_task_runner_handle.h" #include "content/browser/appcache/appcache.h" #include "content/browser/appcache/appcache_database.h" #include "content/browser/appcache/appcache_entry.h" @@ -137,9 +136,8 @@ class AppCacheStorageImpl::DatabaseTask : public base::RefCountedThreadSafe { public: explicit DatabaseTask(AppCacheStorageImpl* storage) - : storage_(storage), - database_(storage->database_), - io_thread_(base::ThreadTaskRunnerHandle::Get()) { + : storage_(storage), database_(storage->database_), + io_thread_(base::MessageLoopProxy::current()) { DCHECK(io_thread_.get()); } @@ -180,7 +178,7 @@ class AppCacheStorageImpl::DatabaseTask void CallRunCompleted(base::TimeTicks schedule_time); void OnFatalError(); - scoped_refptr io_thread_; + scoped_refptr io_thread_; }; void AppCacheStorageImpl::DatabaseTask::Schedule() { @@ -316,7 +314,7 @@ void AppCacheStorageImpl::InitTask::RunCompleted() { if (!storage_->is_disabled()) { storage_->usage_map_.swap(usage_map_); const base::TimeDelta kDelay = base::TimeDelta::FromMinutes(5); - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + base::MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&AppCacheStorageImpl::DelayedStartDeletingUnusedResponses, storage_->weak_factory_.GetWeakPtr()), @@ -1740,9 +1738,10 @@ void AppCacheStorageImpl::StartDeletingResponses( void AppCacheStorageImpl::ScheduleDeleteOneResponse() { DCHECK(!is_response_deletion_scheduled_); const base::TimeDelta kBriefDelay = base::TimeDelta::FromMilliseconds(10); - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::Bind(&AppCacheStorageImpl::DeleteOneResponse, - weak_factory_.GetWeakPtr()), + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&AppCacheStorageImpl::DeleteOneResponse, + weak_factory_.GetWeakPtr()), kBriefDelay); is_response_deletion_scheduled_ = true; } @@ -1825,9 +1824,10 @@ void AppCacheStorageImpl::GetPendingForeignMarkingsForCache( void AppCacheStorageImpl::ScheduleSimpleTask(const base::Closure& task) { pending_simple_tasks_.push_back(task); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&AppCacheStorageImpl::RunOnePendingSimpleTask, - weak_factory_.GetWeakPtr())); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&AppCacheStorageImpl::RunOnePendingSimpleTask, + weak_factory_.GetWeakPtr())); } void AppCacheStorageImpl::RunOnePendingSimpleTask() { diff --git a/content/browser/appcache/appcache_storage_impl_unittest.cc b/content/browser/appcache/appcache_storage_impl_unittest.cc index 9c980dab17e7db..37c295dbb433c0 100644 --- a/content/browser/appcache/appcache_storage_impl_unittest.cc +++ b/content/browser/appcache/appcache_storage_impl_unittest.cc @@ -9,11 +9,9 @@ #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/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" #include "base/synchronization/waitable_event.h" -#include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "content/browser/appcache/appcache.h" #include "content/browser/appcache/appcache_backend_impl.h" @@ -271,8 +269,8 @@ class AppCacheStorageImplTest : public testing::Test { MockQuotaManager() : QuotaManager(true /* is_incognito */, base::FilePath(), - io_thread->task_runner().get(), - db_thread->task_runner().get(), + io_thread->message_loop_proxy().get(), + db_thread->message_loop_proxy().get(), NULL), async_(false) {} @@ -281,9 +279,11 @@ class AppCacheStorageImplTest : public testing::Test { const GetUsageAndQuotaCallback& callback) override { EXPECT_EQ(storage::kStorageTypeTemporary, type); if (async_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&MockQuotaManager::CallCallback, - base::Unretained(this), callback)); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&MockQuotaManager::CallCallback, + base::Unretained(this), + callback)); return; } CallCallback(callback); @@ -370,9 +370,11 @@ 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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&AppCacheStorageImplTest::RunMethod, - base::Unretained(this), method)); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&AppCacheStorageImplTest::RunMethod, + base::Unretained(this), + method)); } static void SetUpTestCase() { @@ -398,7 +400,7 @@ class AppCacheStorageImplTest : public testing::Test { template void RunTestOnIOThread(Method method) { test_finished_event_ .reset(new base::WaitableEvent(false, false)); - io_thread->task_runner()->PostTask( + io_thread->message_loop()->PostTask( FROM_HERE, base::Bind(&AppCacheStorageImplTest::MethodWrapper, base::Unretained(this), method)); test_finished_event_->Wait(); @@ -429,9 +431,10 @@ 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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&AppCacheStorageImplTest::TestFinishedUnwound, - base::Unretained(this))); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&AppCacheStorageImplTest::TestFinishedUnwound, + base::Unretained(this))); } void TestFinishedUnwound() { @@ -448,7 +451,7 @@ class AppCacheStorageImplTest : public testing::Test { if (task_stack_.empty()) { return; } - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task_stack_.top()); + base::MessageLoop::current()->PostTask(FROM_HERE, task_stack_.top()); task_stack_.pop(); } @@ -460,7 +463,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->task_runner()->PostTask( + db_thread->message_loop()->PostTask( FROM_HERE, base::Bind(&AppCacheStorageImplTest::SignalEvent, &event)); event.Wait(); } @@ -1729,9 +1732,11 @@ class AppCacheStorageImplTest : public testing::Test { // We continue after the init task is complete including the callback // on the current thread. FlushDbThreadTasks(); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&AppCacheStorageImplTest::Continue_Reinitialize, - base::Unretained(this), test_case)); + base::MessageLoop::current()->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 c5ddf4f87cde38..b69af526d3ba92 100644 --- a/content/browser/appcache/appcache_update_job_unittest.cc +++ b/content/browser/appcache/appcache_update_job_unittest.cc @@ -4,11 +4,8 @@ #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" @@ -606,7 +603,7 @@ class AppCacheUpdateJobTest : public testing::Test, template void RunTestOnIOThread(Method method) { event_.reset(new base::WaitableEvent(false, false)); - io_thread_->task_runner()->PostTask( + io_thread_->message_loop()->PostTask( FROM_HERE, base::Bind(method, base::Unretained(this))); // Wait until task is done before exiting the test. @@ -2986,9 +2983,10 @@ class AppCacheUpdateJobTest : public testing::Test, void UpdateFinished() { // We unwind the stack prior to finishing up to let stack-based objects // get deleted. - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&AppCacheUpdateJobTest::UpdateFinishedUnwound, - base::Unretained(this))); + base::MessageLoop::current()->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 d66c795ce53263..9bf70e7c242732 100644 --- a/content/browser/appcache/appcache_url_request_job.cc +++ b/content/browser/appcache/appcache_url_request_job.cc @@ -10,11 +10,9 @@ #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/compiler_specific.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.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" @@ -81,9 +79,10 @@ 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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&AppCacheURLRequestJob::BeginDelivery, - weak_factory_.GetWeakPtr())); + base::MessageLoop::current()->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 0e27295a0ebfdc..fdd1c9b45de324 100644 --- a/content/browser/appcache/appcache_url_request_job_unittest.cc +++ b/content/browser/appcache/appcache_url_request_job_unittest.cc @@ -9,13 +9,10 @@ #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" @@ -220,7 +217,7 @@ class AppCacheURLRequestJobTest : public testing::Test { template void RunTestOnIOThread(Method method) { test_finished_event_ .reset(new base::WaitableEvent(false, false)); - io_thread_->task_runner()->PostTask( + io_thread_->message_loop()->PostTask( FROM_HERE, base::Bind(&AppCacheURLRequestJobTest::MethodWrapper, base::Unretained(this), method)); test_finished_event_->Wait(); @@ -270,9 +267,10 @@ 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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&AppCacheURLRequestJobTest::TestFinishedUnwound, - base::Unretained(this))); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&AppCacheURLRequestJobTest::TestFinishedUnwound, + base::Unretained(this))); } void TestFinishedUnwound() { @@ -300,7 +298,7 @@ class AppCacheURLRequestJobTest : public testing::Test { if (immediate) task.Run(); else - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); + base::MessageLoop::current()->PostTask(FROM_HERE, task); } // Wrappers to call AppCacheResponseReader/Writer Read and Write methods diff --git a/content/browser/appcache/chrome_appcache_service_unittest.cc b/content/browser/appcache/chrome_appcache_service_unittest.cc index 0eca5fe0cfb2f1..450bfe2c49ece0 100644 --- a/content/browser/appcache/chrome_appcache_service_unittest.cc +++ b/content/browser/appcache/chrome_appcache_service_unittest.cc @@ -5,9 +5,8 @@ #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/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" #include "content/browser/appcache/appcache_database.h" #include "content/browser/appcache/appcache_storage_impl.h" #include "content/browser/appcache/chrome_appcache_service.h" @@ -34,15 +33,17 @@ const char kSessionOnlyManifest[] = "http://www.sessiononly.com/cache.manifest"; class MockURLRequestContextGetter : public net::URLRequestContextGetter { public: - MockURLRequestContextGetter(net::URLRequestContext* context, - base::SingleThreadTaskRunner* task_runner) - : context_(context), task_runner_(task_runner) {} + MockURLRequestContextGetter( + net::URLRequestContext* context, + base::MessageLoopProxy* message_loop_proxy) + : context_(context), message_loop_proxy_(message_loop_proxy) { + } net::URLRequestContext* GetURLRequestContext() override { return context_; } scoped_refptr GetNetworkTaskRunner() const override { - return task_runner_; + return message_loop_proxy_; } protected: @@ -50,7 +51,7 @@ class MockURLRequestContextGetter : public net::URLRequestContextGetter { private: net::URLRequestContext* context_; - scoped_refptr task_runner_; + scoped_refptr message_loop_proxy_; }; } // namespace @@ -100,7 +101,7 @@ ChromeAppCacheServiceTest::CreateAppCacheServiceImpl( scoped_refptr mock_request_context_getter = new MockURLRequestContextGetter( browser_context_.GetResourceContext()->GetRequestContext(), - message_loop_.task_runner().get()); + message_loop_.message_loop_proxy().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 4f3e2234248729..549d20bc39375a 100644 --- a/content/browser/appcache/mock_appcache_service.cc +++ b/content/browser/appcache/mock_appcache_service.cc @@ -5,9 +5,7 @@ #include "content/browser/appcache/mock_appcache_service.h" #include "base/bind.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.h" namespace content { @@ -19,9 +17,11 @@ static void DeferredCallCallback( void MockAppCacheService::DeleteAppCachesForOrigin( const GURL& origin, const net::CompletionCallback& callback) { ++delete_called_count_; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&DeferredCallCallback, callback, - mock_delete_appcaches_for_origin_result_)); + base::MessageLoop::current()->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 efac9ba992ea50..2a337a0e4a2b7c 100644 --- a/content/browser/appcache/mock_appcache_storage.cc +++ b/content/browser/appcache/mock_appcache_storage.cc @@ -5,12 +5,10 @@ #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/single_thread_task_runner.h" +#include "base/message_loop/message_loop.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" @@ -460,9 +458,10 @@ void MockAppCacheStorage::ProcessMakeGroupObsolete( void MockAppCacheStorage::ScheduleTask(const base::Closure& task) { pending_tasks_.push_back(task); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&MockAppCacheStorage::RunOnePendingTask, - weak_factory_.GetWeakPtr())); + base::MessageLoop::current()->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 b82103d59b7ce4..c7c78cb0b259dd 100644 --- a/content/browser/background_sync/background_sync_manager.cc +++ b/content/browser/background_sync/background_sync_manager.cc @@ -6,9 +6,6 @@ #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" @@ -78,7 +75,7 @@ void BackgroundSyncManager::Register( sync_registration.id); if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); return; @@ -99,7 +96,7 @@ void BackgroundSyncManager::Unregister( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); return; } @@ -120,7 +117,7 @@ void BackgroundSyncManager::GetRegistration( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); return; @@ -141,7 +138,7 @@ void BackgroundSyncManager::GetRegistrations( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, std::vector())); return; @@ -206,8 +203,7 @@ void BackgroundSyncManager::InitImpl(const base::Closure& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); return; } @@ -280,8 +276,7 @@ void BackgroundSyncManager::InitDidGetDataFromBackend( FireReadyEvents(); - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); } void BackgroundSyncManager::RegisterImpl( @@ -291,7 +286,7 @@ void BackgroundSyncManager::RegisterImpl( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); return; @@ -301,7 +296,7 @@ void BackgroundSyncManager::RegisterImpl( sw_registration_id, RegistrationKey(sync_registration)); if (existing_registration && existing_registration->Equals(sync_registration)) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, *existing_registration)); return; } @@ -314,7 +309,7 @@ void BackgroundSyncManager::RegisterImpl( ServiceWorkerRegistration* sw_registration = service_worker_context_->GetLiveRegistration(sw_registration_id); if (!sw_registration || !sw_registration->active_version()) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_NO_SERVICE_WORKER, BackgroundSyncRegistration())); return; @@ -336,8 +331,7 @@ void BackgroundSyncManager::DisableAndClearManager( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); return; } @@ -360,8 +354,7 @@ void BackgroundSyncManager::DisableAndClearDidGetRegistrations( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (status != SERVICE_WORKER_OK || user_data.empty()) { - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); return; } @@ -382,8 +375,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::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(barrier_closure)); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(barrier_closure)); } BackgroundSyncManager::BackgroundSyncRegistration* @@ -452,7 +445,7 @@ void BackgroundSyncManager::RegisterDidStore( if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { // The registration is gone. sw_to_registrations_map_.erase(sw_registration_id); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); return; @@ -467,7 +460,7 @@ void BackgroundSyncManager::RegisterDidStore( } FireReadyEvents(); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, new_registration)); } @@ -537,7 +530,7 @@ void BackgroundSyncManager::UnregisterImpl( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); return; } @@ -546,7 +539,7 @@ void BackgroundSyncManager::UnregisterImpl( LookupRegistration(sw_registration_id, registration_key); if (!existing_registration || existing_registration->id != sync_registration_id) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND)); return; } @@ -568,7 +561,7 @@ void BackgroundSyncManager::UnregisterDidStore( if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { // ServiceWorker was unregistered. sw_to_registrations_map_.erase(sw_registration_id); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE)); return; } @@ -579,8 +572,8 @@ void BackgroundSyncManager::UnregisterDidStore( return; } - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(callback, ERROR_TYPE_OK)); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(callback, ERROR_TYPE_OK)); } void BackgroundSyncManager::GetRegistrationImpl( @@ -590,7 +583,7 @@ void BackgroundSyncManager::GetRegistrationImpl( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, BackgroundSyncRegistration())); return; @@ -599,13 +592,13 @@ void BackgroundSyncManager::GetRegistrationImpl( const BackgroundSyncRegistration* out_registration = LookupRegistration(sw_registration_id, registration_key); if (!out_registration) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND, BackgroundSyncRegistration())); return; } - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, *out_registration)); } @@ -618,7 +611,7 @@ void BackgroundSyncManager::GetRegistrationsImpl( std::vector out_registrations; if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_STORAGE, out_registrations)); return; } @@ -636,7 +629,7 @@ void BackgroundSyncManager::GetRegistrationsImpl( } } - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, ERROR_TYPE_OK, out_registrations)); } @@ -703,8 +696,7 @@ void BackgroundSyncManager::FireReadyEventsImpl(const base::Closure& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); return; } @@ -757,8 +749,7 @@ void BackgroundSyncManager::FireReadyEventsDidFindRegistration( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (service_worker_status != SERVICE_WORKER_OK) { - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); return; } @@ -769,8 +760,7 @@ void BackgroundSyncManager::FireReadyEventsDidFindRegistration( service_worker_registration->id(), registration_key, registration_id)); - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); } // |service_worker_registration| is just to keep the registration alive @@ -801,16 +791,14 @@ void BackgroundSyncManager::EventCompleteImpl( DCHECK_CURRENTLY_ON(BrowserThread::IO); if (disabled_) { - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); return; } BackgroundSyncRegistration* registration = LookupRegistration(service_worker_id, key); if (!registration || registration->id != sync_registration_id) { - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); return; } @@ -843,8 +831,7 @@ void BackgroundSyncManager::EventCompleteDidStore( if (status_code == SERVICE_WORKER_ERROR_NOT_FOUND) { // The registration is gone. sw_to_registrations_map_.erase(service_worker_id); - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); return; } @@ -855,8 +842,7 @@ void BackgroundSyncManager::EventCompleteDidStore( return; } - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback)); } void BackgroundSyncManager::OnRegistrationDeletedImpl( @@ -867,8 +853,7 @@ 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::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback)); + base::MessageLoop::current()->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 5a10068a962a10..426f56f37f2f35 100644 --- a/content/browser/background_sync/background_sync_manager_unittest.cc +++ b/content/browser/background_sync/background_sync_manager_unittest.cc @@ -5,12 +5,10 @@ #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" @@ -147,7 +145,7 @@ class TestBackgroundSyncManager : public BackgroundSyncManager { const ServiceWorkerStorage::StatusCallback& callback) override { EXPECT_TRUE(continuation_.is_null()); if (corrupt_backend_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_FAILED)); return; } @@ -167,7 +165,7 @@ class TestBackgroundSyncManager : public BackgroundSyncManager { callback) override { EXPECT_TRUE(continuation_.is_null()); if (corrupt_backend_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, std::vector>(), 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 1c6f2bd9816386..fafb1e68a1f9e4 100644 --- a/content/browser/background_sync/background_sync_network_observer.cc +++ b/content/browser/background_sync/background_sync_network_observer.cc @@ -4,9 +4,6 @@ #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 { @@ -50,8 +47,7 @@ bool BackgroundSyncNetworkObserver::NetworkSufficient( void BackgroundSyncNetworkObserver::NotifyNetworkChanged() { DCHECK_CURRENTLY_ON(BrowserThread::IO); - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - network_changed_callback_); + base::MessageLoop::current()->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 9ed607ac11baf8..eeeb4d1ddfb4e5 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,7 +17,6 @@ #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" @@ -630,7 +629,7 @@ void BrowserMainLoop::PostMainMessageLoopStart() { #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) trace_memory_controller_.reset(new base::trace_event::TraceMemoryController( - base::MessageLoop::current()->task_runner(), + base::MessageLoop::current()->message_loop_proxy(), ::HeapProfilerWithPseudoStackStart, ::HeapProfilerStop, ::GetHeapProfile)); #endif @@ -715,13 +714,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::ThreadTaskRunnerHandle::Get())); + startup_task_runner_ = make_scoped_ptr(new StartupTaskRunner( + base::Bind(&BrowserStartupComplete), + base::MessageLoop::current()->message_loop_proxy())); #else - startup_task_runner_ = make_scoped_ptr( - new StartupTaskRunner(base::Callback(), - base::ThreadTaskRunnerHandle::Get())); + startup_task_runner_ = make_scoped_ptr(new StartupTaskRunner( + base::Callback(), + base::MessageLoop::current()->message_loop_proxy())); #endif StartupTask pre_create_threads = base::Bind(&BrowserMainLoop::PreCreateThreads, base::Unretained(this)); @@ -1208,7 +1207,7 @@ int BrowserMainLoop::BrowserThreadsStarted() { "startup", "BrowserMainLoop::BrowserThreadsStarted::InitUserInputMonitor"); user_input_monitor_ = media::UserInputMonitor::Create( - io_thread_->task_runner(), main_thread_->task_runner()); + io_thread_->message_loop_proxy(), main_thread_->message_loop_proxy()); } { @@ -1312,8 +1311,8 @@ void BrowserMainLoop::MainMessageLoopRun() { #else DCHECK(base::MessageLoopForUI::IsCurrent()); if (parameters_.ui_task) { - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - *parameters_.ui_task); + base::MessageLoopForUI::current()->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 c23d8d16000d0f..6c4d8c8c14a764 100644 --- a/content/browser/browser_shutdown_profile_dumper.cc +++ b/content/browser/browser_shutdown_profile_dumper.cc @@ -8,9 +8,7 @@ #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" @@ -61,10 +59,11 @@ void BrowserShutdownProfileDumper::WriteTracesToDisc() { base::WaitableEvent flush_complete_event(false, false); base::Thread flush_thread("browser_shutdown_trace_event_flush"); flush_thread.Start(); - flush_thread.task_runner()->PostTask( - FROM_HERE, base::Bind(&BrowserShutdownProfileDumper::EndTraceAndFlush, - base::Unretained(this), - base::Unretained(&flush_complete_event))); + flush_thread.message_loop()->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 b0a24ae06c0e13..1aac305bcb8b2a 100644 --- a/content/browser/browser_thread_impl.cc +++ b/content/browser/browser_thread_impl.cc @@ -10,7 +10,8 @@ #include "base/bind.h" #include "base/compiler_specific.h" #include "base/lazy_instance.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" +#include "base/message_loop/message_loop_proxy.h" #include "base/threading/sequenced_worker_pool.h" #include "base/threading/thread_restrictions.h" #include "content/public/browser/browser_thread_delegate.h" @@ -36,14 +37,15 @@ static const char* g_browser_thread_names[BrowserThread::ID_COUNT] = { "Chrome_IOThread", // IO }; -// An implementation of SingleThreadTaskRunner to be used in conjunction +// An implementation of MessageLoopProxy to be used in conjunction // with BrowserThread. -class BrowserThreadTaskRunner : public base::SingleThreadTaskRunner { +class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { public: - explicit BrowserThreadTaskRunner(BrowserThread::ID identifier) - : id_(identifier) {} + explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) + : id_(identifier) { + } - // SingleThreadTaskRunner implementation. + // MessageLoopProxy implementation. bool PostDelayedTask(const tracked_objects::Location& from_here, const base::Closure& task, base::TimeDelta delay) override { @@ -62,28 +64,28 @@ class BrowserThreadTaskRunner : public base::SingleThreadTaskRunner { } protected: - ~BrowserThreadTaskRunner() override {} + ~BrowserThreadMessageLoopProxy() override {} private: BrowserThread::ID id_; - DISALLOW_COPY_AND_ASSIGN(BrowserThreadTaskRunner); + DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); }; -// 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() { +// 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() { for (int i = 0; i < BrowserThread::ID_COUNT; ++i) { proxies[i] = - new BrowserThreadTaskRunner(static_cast(i)); + new BrowserThreadMessageLoopProxy(static_cast(i)); } } - scoped_refptr proxies[BrowserThread::ID_COUNT]; + scoped_refptr proxies[BrowserThread::ID_COUNT]; }; -base::LazyInstance::Leaky g_task_runners = - LAZY_INSTANCE_INITIALIZER; +base::LazyInstance::Leaky + g_proxies = LAZY_INSTANCE_INITIALIZER; struct BrowserThreadGlobals { BrowserThreadGlobals() @@ -329,10 +331,9 @@ bool BrowserThreadImpl::PostTaskHelper( : NULL; if (message_loop) { if (nestable) { - message_loop->task_runner()->PostDelayedTask(from_here, task, delay); + message_loop->PostDelayedTask(from_here, task, delay); } else { - message_loop->task_runner()->PostNonNestableDelayedTask(from_here, task, - delay); + message_loop->PostNonNestableDelayedTask(from_here, task, delay); } } @@ -516,9 +517,9 @@ bool BrowserThread::GetCurrentThreadIdentifier(ID* identifier) { } // static -scoped_refptr +scoped_refptr BrowserThread::GetMessageLoopProxyForThread(ID identifier) { - return g_task_runners.Get().proxies[identifier]; + return g_proxies.Get().proxies[identifier]; } // static diff --git a/content/browser/browser_thread_unittest.cc b/content/browser/browser_thread_unittest.cc index 9b23057f6232d2..3f1f8cdd2eeae2 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_.task_runner()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); + loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); } protected: @@ -37,8 +37,7 @@ class BrowserThreadTest : public testing::Test { static void BasicFunction(base::MessageLoop* message_loop) { CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - message_loop->task_runner()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); + message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); } class DeletedOnFile @@ -54,8 +53,7 @@ class BrowserThreadTest : public testing::Test { ~DeletedOnFile() { CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - message_loop_->task_runner()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); + message_loop_->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); } base::MessageLoop* message_loop_; @@ -90,24 +88,24 @@ TEST_F(BrowserThreadTest, ReleasedOnCorrectThread) { base::MessageLoop::current()->Run(); } -TEST_F(BrowserThreadTest, PostTaskViaTaskRunner) { - scoped_refptr task_runner = +TEST_F(BrowserThreadTest, PostTaskViaMessageLoopProxy) { + scoped_refptr message_loop_proxy = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); - task_runner->PostTask( + message_loop_proxy->PostTask( FROM_HERE, base::Bind(&BasicFunction, base::MessageLoop::current())); base::MessageLoop::current()->Run(); } -TEST_F(BrowserThreadTest, ReleaseViaTaskRunner) { - scoped_refptr task_runner = +TEST_F(BrowserThreadTest, ReleaseViaMessageLoopProxy) { + scoped_refptr message_loop_proxy = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); - task_runner->ReleaseSoon(FROM_HERE, this); + message_loop_proxy->ReleaseSoon(FROM_HERE, this); base::MessageLoop::current()->Run(); } TEST_F(BrowserThreadTest, PostTaskAndReply) { // Most of the heavy testing for PostTaskAndReply() is done inside the - // task runner test. This just makes sure we get piped through at all. + // MessageLoopProxy 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 f750cf2cdfdcc6..f814e2f5d083f4 100644 --- a/content/browser/byte_stream_unittest.cc +++ b/content/browser/byte_stream_unittest.cc @@ -10,6 +10,7 @@ #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" @@ -103,8 +104,9 @@ ByteStreamTest::ByteStreamTest() TEST_F(ByteStreamTest, ByteStream_PushBack) { scoped_ptr byte_stream_input; scoped_ptr byte_stream_output; - CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + 3 * 1024, &byte_stream_input, &byte_stream_output); // Push a series of IO buffers on; test pushback happening and // that it's advisory. @@ -157,8 +159,9 @@ TEST_F(ByteStreamTest, ByteStream_PushBack) { TEST_F(ByteStreamTest, ByteStream_Flush) { scoped_ptr byte_stream_input; scoped_ptr byte_stream_output; - CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), - 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + 1024, &byte_stream_input, &byte_stream_output); EXPECT_TRUE(Write(byte_stream_input.get(), 1)); message_loop_.RunUntilIdle(); @@ -196,8 +199,9 @@ TEST_F(ByteStreamTest, ByteStream_Flush) { TEST_F(ByteStreamTest, ByteStream_PushBackSplit) { scoped_ptr byte_stream_input; scoped_ptr byte_stream_output; - CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), - 9 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + 9 * 1024, &byte_stream_input, &byte_stream_output); // Push a series of IO buffers on; test pushback happening and // that it's advisory. @@ -250,8 +254,9 @@ TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) { size_t output_length; // Empty stream, non-error case. - CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + 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); @@ -261,8 +266,9 @@ TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) { EXPECT_EQ(0, byte_stream_output->GetStatus()); // Non-empty stream, non-error case. - CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + 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)); @@ -278,8 +284,9 @@ TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) { const int kFakeErrorCode = 22; // Empty stream, error case. - CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + 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); @@ -289,8 +296,9 @@ TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) { EXPECT_EQ(kFakeErrorCode, byte_stream_output->GetStatus()); // Non-empty stream, error case. - CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + 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)); @@ -311,8 +319,9 @@ TEST_F(ByteStreamTest, ByteStream_SinkCallback) { scoped_ptr byte_stream_input; scoped_ptr byte_stream_output; - CreateByteStream(message_loop_.task_runner(), task_runner, 10000, - &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), task_runner, + 10000, &byte_stream_input, &byte_stream_output); scoped_refptr output_io_buffer; size_t output_length; @@ -362,8 +371,9 @@ TEST_F(ByteStreamTest, ByteStream_SourceCallback) { scoped_ptr byte_stream_input; scoped_ptr byte_stream_output; - CreateByteStream(task_runner, message_loop_.task_runner(), 10000, - &byte_stream_input, &byte_stream_output); + CreateByteStream( + task_runner, message_loop_.message_loop_proxy(), + 10000, &byte_stream_input, &byte_stream_output); scoped_refptr output_io_buffer; size_t output_length; @@ -423,8 +433,9 @@ TEST_F(ByteStreamTest, ByteStream_SinkInterrupt) { scoped_ptr byte_stream_input; scoped_ptr byte_stream_output; - CreateByteStream(message_loop_.task_runner(), task_runner, 10000, - &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), task_runner, + 10000, &byte_stream_input, &byte_stream_output); scoped_refptr output_io_buffer; size_t output_length; @@ -469,8 +480,9 @@ TEST_F(ByteStreamTest, ByteStream_SourceInterrupt) { scoped_ptr byte_stream_input; scoped_ptr byte_stream_output; - CreateByteStream(task_runner, message_loop_.task_runner(), 10000, - &byte_stream_input, &byte_stream_output); + CreateByteStream( + task_runner, message_loop_.message_loop_proxy(), + 10000, &byte_stream_input, &byte_stream_output); scoped_refptr output_io_buffer; size_t output_length; @@ -520,8 +532,9 @@ TEST_F(ByteStreamTest, ByteStream_ZeroCallback) { scoped_ptr byte_stream_input; scoped_ptr byte_stream_output; - CreateByteStream(message_loop_.task_runner(), task_runner, 10000, - &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), task_runner, + 10000, &byte_stream_input, &byte_stream_output); base::Closure intermediate_callback; @@ -539,8 +552,9 @@ TEST_F(ByteStreamTest, ByteStream_ZeroCallback) { TEST_F(ByteStreamTest, ByteStream_CloseWithoutAnyWrite) { scoped_ptr byte_stream_input; scoped_ptr byte_stream_output; - CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + 3 * 1024, &byte_stream_input, &byte_stream_output); byte_stream_input->Close(0); message_loop_.RunUntilIdle(); @@ -554,8 +568,9 @@ TEST_F(ByteStreamTest, ByteStream_CloseWithoutAnyWrite) { TEST_F(ByteStreamTest, ByteStream_FlushWithoutAnyWrite) { scoped_ptr byte_stream_input; scoped_ptr byte_stream_output; - CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), - 3 * 1024, &byte_stream_input, &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + 3 * 1024, &byte_stream_input, &byte_stream_output); byte_stream_input->Flush(); message_loop_.RunUntilIdle(); @@ -575,9 +590,10 @@ TEST_F(ByteStreamTest, ByteStream_FlushWithoutAnyWrite) { TEST_F(ByteStreamTest, ByteStream_WriteOverflow) { scoped_ptr byte_stream_input; scoped_ptr byte_stream_output; - CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), - std::numeric_limits::max(), &byte_stream_input, - &byte_stream_output); + CreateByteStream( + message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), + std::numeric_limits::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 24cc38bdee0eff..a6a32b9893d371 100644 --- a/content/browser/cache_storage/cache_storage.cc +++ b/content/browser/cache_storage/cache_storage.cc @@ -9,15 +9,12 @@ #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" @@ -228,15 +225,15 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader { cache_task_runner_->PostTask( FROM_HERE, base::Bind(&SimpleCacheLoader::CleanUpDeleteCacheDirInPool, cache_path, - callback, base::ThreadTaskRunnerHandle::Get())); + callback, base::MessageLoopProxy::current())); } static void CleanUpDeleteCacheDirInPool( const base::FilePath& cache_path, const BoolCallback& callback, - const scoped_refptr& original_task_runner) { + const scoped_refptr& original_loop) { bool rv = base::DeleteFile(cache_path, true); - original_task_runner->PostTask(FROM_HERE, base::Bind(callback, rv)); + original_loop->PostTask(FROM_HERE, base::Bind(callback, rv)); } void WriteIndex(const StringVector& cache_names, @@ -265,7 +262,7 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader { cache_task_runner_->PostTask( FROM_HERE, base::Bind(&SimpleCacheLoader::WriteIndexWriteToFileInPool, tmp_path, index_path, serialized, callback, - base::ThreadTaskRunnerHandle::Get())); + base::MessageLoopProxy::current())); } static void WriteIndexWriteToFileInPool( @@ -273,16 +270,16 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader { const base::FilePath& index_path, const std::string& data, const BoolCallback& callback, - const scoped_refptr& original_task_runner) { + const scoped_refptr& original_loop) { int bytes_written = base::WriteFile(tmp_path, data.c_str(), data.size()); if (bytes_written != implicit_cast(data.size())) { base::DeleteFile(tmp_path, /* recursive */ false); - original_task_runner->PostTask(FROM_HERE, base::Bind(callback, false)); + original_loop->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_task_runner->PostTask(FROM_HERE, base::Bind(callback, rv)); + original_loop->PostTask(FROM_HERE, base::Bind(callback, rv)); } void LoadIndex(scoped_ptr> names, @@ -298,18 +295,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::ThreadTaskRunnerHandle::Get())); + base::MessageLoopProxy::current())); } static void LoadIndexReadFileInPool( const base::FilePath& index_path, scoped_ptr> names, const StringVectorCallback& callback, - const scoped_refptr& original_task_runner) { + const scoped_refptr& original_loop) { std::string body; base::ReadFileToString(index_path, &body); - original_task_runner->PostTask( + original_loop->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 ab57e308e7ed83..279dfc3d8663dc 100644 --- a/content/browser/cache_storage/cache_storage_cache.cc +++ b/content/browser/cache_storage/cache_storage_cache.cc @@ -9,6 +9,7 @@ #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" @@ -1179,7 +1180,7 @@ void CacheStorageCache::CreateBackend(const ErrorCallback& callback) { weak_ptr_factory_.GetWeakPtr(), callback, base::Passed(backend_ptr.Pass())); - // TODO(jkarlin): Use the cache task runner that ServiceWorkerCacheCore + // TODO(jkarlin): Use the cache MessageLoopProxy 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 2f11ab7735025b..57350d2cc27a2b 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 thread task runner are not actually used but a - // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. + // The FileSystemContext and MessageLoopProxy are not actually used but a + // MessageLoopProxy is needed to avoid a DCHECK in BlobURLRequestJob ctor. return new storage::BlobProtocolHandler( - blob_storage_context, NULL, base::ThreadTaskRunnerHandle::Get().get()); + blob_storage_context, NULL, base::MessageLoopProxy::current().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::ThreadTaskRunnerHandle::Get().get()); + nullptr, base::MessageLoopProxy::current().get()); url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); url_request_job_factory_->SetProtocolHandler( @@ -261,7 +261,8 @@ 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 task runner instead of the CACHE thread. + // once the cache uses a passed in MessageLoopProxy 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 61963b1ba8d2ea..4fb7e7fb4a8163 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::ThreadTaskRunnerHandle::Get().get()); + nullptr, base::MessageLoopProxy::current().get()); net::URLRequestContext* url_request_context = browser_context_.GetRequestContext()->GetURLRequestContext(); if (MemoryOnly()) { cache_manager_ = CacheStorageManager::Create( - base::FilePath(), base::ThreadTaskRunnerHandle::Get(), + base::FilePath(), base::MessageLoopProxy::current(), quota_manager_proxy_); } else { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); cache_manager_ = CacheStorageManager::Create( - temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(), + temp_dir_.path(), base::MessageLoopProxy::current(), quota_manager_proxy_); } diff --git a/content/browser/cache_storage/cache_storage_scheduler.cc b/content/browser/cache_storage/cache_storage_scheduler.cc index 86db5f2dc8f8b9..33447b93787db7 100644 --- a/content/browser/cache_storage/cache_storage_scheduler.cc +++ b/content/browser/cache_storage/cache_storage_scheduler.cc @@ -9,8 +9,7 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop_proxy.h" namespace content { @@ -41,8 +40,7 @@ void CacheStorageScheduler::RunOperationIfIdle() { // TODO(jkarlin): Run multiple operations in parallel where allowed. base::Closure closure = pending_operations_.front(); pending_operations_.pop_front(); - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(closure)); + base::MessageLoopProxy::current()->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 e1b4cfa4a4b901..68ee72c1e10bdb 100644 --- a/content/browser/compositor/gpu_process_transport_factory.cc +++ b/content/browser/compositor/gpu_process_transport_factory.cc @@ -9,10 +9,9 @@ #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" @@ -595,7 +594,7 @@ GpuProcessTransportFactory::CreateContextCommon( } void GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback() { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 ca1a89f8b4ef13..957dfc305fae5f 100644 --- a/content/browser/compositor/reflector_impl.h +++ b/content/browser/compositor/reflector_impl.h @@ -18,6 +18,8 @@ #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 ce9fbb9e6613fa..a80b4fb9099146 100644 --- a/content/browser/compositor/reflector_impl_unittest.cc +++ b/content/browser/compositor/reflector_impl_unittest.cc @@ -2,6 +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/run_loop.h" #include "base/single_thread_task_runner.h" #include "cc/test/fake_output_surface_client.h" @@ -118,7 +119,7 @@ class ReflectorImplTest : public testing::Test { scoped_ptr( new NoTransportImageTransportFactory)); message_loop_.reset(new base::MessageLoop()); - task_runner_ = message_loop_->task_runner(); + proxy_ = message_loop_->message_loop_proxy(); compositor_task_runner_ = new FakeTaskRunner(); compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget, context_factory, @@ -165,7 +166,7 @@ class ReflectorImplTest : public testing::Test { scoped_refptr context_provider_; cc::FakeOutputSurfaceClient output_surface_client_; scoped_ptr message_loop_; - scoped_refptr task_runner_; + scoped_refptr proxy_; scoped_ptr compositor_; scoped_ptr root_layer_; scoped_ptr 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 866853c697243a..c2b70d40c94bd1 100644 --- a/content/browser/compositor/software_browser_compositor_output_surface.cc +++ b/content/browser/compositor/software_browser_compositor_output_surface.cc @@ -4,10 +4,8 @@ #include "content/browser/compositor/software_browser_compositor_output_surface.h" -#include "base/location.h" #include "base/memory/ref_counted.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.h" #include "base/time/time.h" #include "cc/output/compositor_frame.h" #include "cc/output/output_surface_client.h" @@ -40,9 +38,11 @@ void SoftwareBrowserCompositorOutputSurface::SwapBuffers( ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, swap_time, 1); } - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&RenderWidgetHostImpl::CompositorFrameDrawn, - frame->metadata.latency_info)); + base::MessageLoop::current()->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 ae4962e4154d4c..68534f0cacd15c 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/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.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::ThreadTaskRunnerHandle::Get())); + base::MessageLoopProxy::current())); } 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 99c55bdb85909f..a19465b35afc75 100644 --- a/content/browser/compositor/software_output_device_ozone_unittest.cc +++ b/content/browser/compositor/software_output_device_ozone_unittest.cc @@ -4,7 +4,6 @@ #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" @@ -89,7 +88,7 @@ void SoftwareOutputDeviceOzoneTest::SetUp() { &window_delegate_, gfx::Rect(size)); compositor_.reset(new ui::Compositor(window_delegate_.GetAcceleratedWidget(), context_factory, - base::ThreadTaskRunnerHandle::Get())); + base::MessageLoopProxy::current())); 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 3c2c6f314709e5..a439b5176d4079 100644 --- a/content/browser/database_quota_client_unittest.cc +++ b/content/browser/database_quota_client_unittest.cc @@ -6,11 +6,9 @@ #include "base/bind.h" #include "base/files/file_path.h" -#include "base/location.h" +#include "base/message_loop/message_loop_proxy.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" @@ -74,9 +72,10 @@ class MockDatabaseTracker : public DatabaseTracker { const net::CompletionCallback& callback) override { ++delete_called_count_; if (async_delete()) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&MockDatabaseTracker::AsyncDeleteDataForOrigin, - this, callback)); + base::MessageLoopProxy::current()->PostTask( + FROM_HERE, + base::Bind(&MockDatabaseTracker::AsyncDeleteDataForOrigin, this, + callback)); return net::ERR_IO_PENDING; } return net::OK; @@ -208,7 +207,7 @@ class DatabaseQuotaClientTest : public testing::Test { TEST_F(DatabaseQuotaClientTest, GetOriginUsage) { - DatabaseQuotaClient client(base::ThreadTaskRunnerHandle::Get().get(), + DatabaseQuotaClient client(base::MessageLoopProxy::current().get(), mock_tracker()); EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); @@ -223,7 +222,7 @@ TEST_F(DatabaseQuotaClientTest, GetOriginUsage) { } TEST_F(DatabaseQuotaClientTest, GetOriginsForHost) { - DatabaseQuotaClient client(base::ThreadTaskRunnerHandle::Get().get(), + DatabaseQuotaClient client(base::MessageLoopProxy::current().get(), mock_tracker()); EXPECT_EQ(kOriginA.host(), kOriginB.host()); @@ -248,7 +247,7 @@ TEST_F(DatabaseQuotaClientTest, GetOriginsForHost) { } TEST_F(DatabaseQuotaClientTest, GetOriginsForType) { - DatabaseQuotaClient client(base::ThreadTaskRunnerHandle::Get().get(), + DatabaseQuotaClient client(base::MessageLoopProxy::current().get(), mock_tracker()); EXPECT_TRUE(GetOriginsForType(&client, kTemp).empty()); @@ -263,7 +262,7 @@ TEST_F(DatabaseQuotaClientTest, GetOriginsForType) { } TEST_F(DatabaseQuotaClientTest, DeleteOriginData) { - DatabaseQuotaClient client(base::ThreadTaskRunnerHandle::Get().get(), + DatabaseQuotaClient client(base::MessageLoopProxy::current().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 a068b4d5d27989..14557de29c85f2 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,9 +564,12 @@ class DatabaseTracker_TestHelper_Test { scoped_refptr special_storage_policy = new MockSpecialStoragePolicy; special_storage_policy->AddSessionOnly(GURL(kOrigin2Url)); - scoped_refptr tracker(new DatabaseTracker( - temp_dir.path(), false, special_storage_policy.get(), NULL, - base::ThreadTaskRunnerHandle::Get().get())); + scoped_refptr tracker( + new DatabaseTracker(temp_dir.path(), + false, + special_storage_policy.get(), + NULL, + base::MessageLoopProxy::current().get())); // Open two new databases. tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0, @@ -641,9 +644,12 @@ class DatabaseTracker_TestHelper_Test { scoped_refptr special_storage_policy = new MockSpecialStoragePolicy; special_storage_policy->AddSessionOnly(GURL(kOrigin2Url)); - scoped_refptr tracker(new DatabaseTracker( - temp_dir.path(), false, special_storage_policy.get(), NULL, - base::ThreadTaskRunnerHandle::Get().get())); + scoped_refptr tracker( + new DatabaseTracker(temp_dir.path(), + false, + special_storage_policy.get(), + NULL, + base::MessageLoopProxy::current().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 ac86c6f8c69613..f2b2d40c6431a2 100644 --- a/content/browser/device_sensors/data_fetcher_shared_memory_base.cc +++ b/content/browser/device_sensors/data_fetcher_shared_memory_base.cc @@ -5,9 +5,7 @@ #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" @@ -131,10 +129,11 @@ bool DataFetcherSharedMemoryBase::StartFetchingDeviceData( if (GetType() != FETCHER_TYPE_DEFAULT) { if (!InitAndStartPollingThreadIfNecessary()) return false; - polling_thread_->task_runner()->PostTask( - FROM_HERE, base::Bind(&PollingThread::AddConsumer, - base::Unretained(polling_thread_.get()), - consumer_type, buffer)); + polling_thread_->message_loop()->PostTask( + FROM_HERE, + base::Bind(&PollingThread::AddConsumer, + base::Unretained(polling_thread_.get()), + consumer_type, buffer)); } else { if (!Start(consumer_type, buffer)) return false; @@ -151,10 +150,11 @@ bool DataFetcherSharedMemoryBase::StopFetchingDeviceData( return true; if (GetType() != FETCHER_TYPE_DEFAULT) { - polling_thread_->task_runner()->PostTask( + polling_thread_->message_loop()->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 9ace6fa6825b0d..cd632c1aecadd2 100644 --- a/content/browser/devtools/devtools_manager_unittest.cc +++ b/content/browser/devtools/devtools_manager_unittest.cc @@ -3,10 +3,7 @@ // 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" @@ -143,8 +140,9 @@ 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::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::MessageLoop::QuitClosure(), + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); base::MessageLoop::current()->Run(); EXPECT_FALSE(delegate.renderer_unresponsive_received()); @@ -154,8 +152,9 @@ 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::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::MessageLoop::QuitClosure(), + base::MessageLoop::current()->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 63550c016f0bd2..cc69f7d2a291fc 100644 --- a/content/browser/devtools/protocol/page_handler.cc +++ b/content/browser/devtools/protocol/page_handler.cc @@ -8,11 +8,8 @@ #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" @@ -429,9 +426,10 @@ void PageHandler::ScreencastFrameCaptured( processing_screencast_frame_ = false; if (capture_retry_count_) { --capture_retry_count_; - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::Bind(&PageHandler::InnerSwapCompositorFrame, - weak_factory_.GetWeakPtr()), + base::MessageLoop::current()->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 21f1a9a27a6050..246fdd31a05f92 100644 --- a/content/browser/devtools/protocol/tethering_handler.h +++ b/content/browser/devtools/protocol/tethering_handler.h @@ -6,6 +6,7 @@ #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 ba91f2697dd43a..aa5653da319a55 100644 --- a/content/browser/dom_storage/dom_storage_area_unittest.cc +++ b/content/browser/dom_storage/dom_storage_area_unittest.cc @@ -5,9 +5,7 @@ #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" @@ -47,10 +45,11 @@ 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::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&DOMStorageAreaTest::InjectedCommitSequencingTask2, - base::Unretained(this), area)); + base::Unretained(this), + area)); } void InjectedCommitSequencingTask2( @@ -174,10 +173,10 @@ TEST_F(DOMStorageAreaTest, BackingDatabaseOpened) { // This should set up a DOMStorageArea that is correctly backed to disk. { - scoped_refptr area( - new DOMStorageArea(kOrigin, temp_dir.path(), - new MockDOMStorageTaskRunner( - base::ThreadTaskRunnerHandle::Get().get()))); + scoped_refptr area(new DOMStorageArea( + kOrigin, + temp_dir.path(), + new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()))); EXPECT_TRUE(area->backing_.get()); DOMStorageDatabase* database = static_cast( @@ -222,8 +221,9 @@ TEST_F(DOMStorageAreaTest, CommitTasks) { ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); scoped_refptr area(new DOMStorageArea( - kOrigin, temp_dir.path(), - new MockDOMStorageTaskRunner(base::ThreadTaskRunnerHandle::Get().get()))); + kOrigin, + temp_dir.path(), + new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()))); // Inject an in-memory db to speed up the test. area->backing_.reset(new LocalStorageDatabaseAdapter()); @@ -300,8 +300,9 @@ TEST_F(DOMStorageAreaTest, CommitChangesAtShutdown) { base::ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); scoped_refptr area(new DOMStorageArea( - kOrigin, temp_dir.path(), - new MockDOMStorageTaskRunner(base::ThreadTaskRunnerHandle::Get().get()))); + kOrigin, + temp_dir.path(), + new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()))); // Inject an in-memory db to speed up the test and also to verify // the final changes are commited in it's dtor. @@ -326,8 +327,9 @@ TEST_F(DOMStorageAreaTest, DeleteOrigin) { base::ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); scoped_refptr area(new DOMStorageArea( - kOrigin, temp_dir.path(), - new MockDOMStorageTaskRunner(base::ThreadTaskRunnerHandle::Get().get()))); + kOrigin, + temp_dir.path(), + new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()))); // This test puts files on disk. base::FilePath db_file_path = static_cast( @@ -386,8 +388,9 @@ TEST_F(DOMStorageAreaTest, PurgeMemory) { base::ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); scoped_refptr area(new DOMStorageArea( - kOrigin, temp_dir.path(), - new MockDOMStorageTaskRunner(base::ThreadTaskRunnerHandle::Get().get()))); + kOrigin, + temp_dir.path(), + new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().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 fe99fbfaf4ef12..9ea46028b6f5b9 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::ThreadTaskRunnerHandle::Get().get()); + new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().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 db486f35e36a6e..fef44e8eff3a91 100644 --- a/content/browser/dom_storage/dom_storage_context_wrapper.cc +++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc @@ -10,9 +10,7 @@ #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/thread_task_runner_handle.h" +#include "base/message_loop/message_loop_proxy.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" @@ -34,15 +32,16 @@ void InvokeLocalStorageUsageCallbackHelper( } void GetLocalStorageUsageHelper( - base::SingleThreadTaskRunner* reply_task_runner, + base::MessageLoopProxy* reply_loop, DOMStorageContextImpl* context, const DOMStorageContext::GetLocalStorageUsageCallback& callback) { std::vector* infos = new std::vector; context->GetLocalStorageUsage(infos, true); - reply_task_runner->PostTask( - FROM_HERE, base::Bind(&InvokeLocalStorageUsageCallbackHelper, callback, - base::Owned(infos))); + reply_loop->PostTask( + FROM_HERE, + base::Bind(&InvokeLocalStorageUsageCallbackHelper, + callback, base::Owned(infos))); } void InvokeSessionStorageUsageCallbackHelper( @@ -52,15 +51,16 @@ void InvokeSessionStorageUsageCallbackHelper( } void GetSessionStorageUsageHelper( - base::SingleThreadTaskRunner* reply_task_runner, + base::MessageLoopProxy* reply_loop, DOMStorageContextImpl* context, const DOMStorageContext::GetSessionStorageUsageCallback& callback) { std::vector* infos = new std::vector; context->GetSessionStorageUsage(infos); - reply_task_runner->PostTask( - FROM_HERE, base::Bind(&InvokeSessionStorageUsageCallbackHelper, callback, - base::Owned(infos))); + reply_loop->PostTask( + FROM_HERE, + base::Bind(&InvokeSessionStorageUsageCallbackHelper, + callback, base::Owned(infos))); } } // namespace @@ -89,19 +89,25 @@ DOMStorageContextWrapper::~DOMStorageContextWrapper() { void DOMStorageContextWrapper::GetLocalStorageUsage( const GetLocalStorageUsageCallback& callback) { DCHECK(context_.get()); - context_->task_runner()->PostShutdownBlockingTask( - FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, - base::Bind(&GetLocalStorageUsageHelper, - base::ThreadTaskRunnerHandle::Get(), context_, callback)); + context_->task_runner() + ->PostShutdownBlockingTask(FROM_HERE, + DOMStorageTaskRunner::PRIMARY_SEQUENCE, + base::Bind(&GetLocalStorageUsageHelper, + base::MessageLoopProxy::current(), + context_, + callback)); } void DOMStorageContextWrapper::GetSessionStorageUsage( const GetSessionStorageUsageCallback& callback) { DCHECK(context_.get()); - context_->task_runner()->PostShutdownBlockingTask( - FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, - base::Bind(&GetSessionStorageUsageHelper, - base::ThreadTaskRunnerHandle::Get(), context_, callback)); + context_->task_runner() + ->PostShutdownBlockingTask(FROM_HERE, + DOMStorageTaskRunner::PRIMARY_SEQUENCE, + base::Bind(&GetSessionStorageUsageHelper, + base::MessageLoopProxy::current(), + 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 cf2204d5b4ef8c..aa75c3c530a1fd 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/location.h" +#include "base/message_loop/message_loop_proxy.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::SingleThreadTaskRunner* delayed_task_task_runner) - : task_runner_(delayed_task_task_runner), + base::MessageLoopProxy* delayed_task_loop) + : message_loop_(delayed_task_loop), 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 task_runner_->PostDelayedTask( + return message_loop_->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::SingleThreadTaskRunner* task_runner) - : task_runner_(task_runner) { + base::MessageLoopProxy* message_loop) + : message_loop_(message_loop) { } MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() { @@ -90,18 +90,18 @@ bool MockDOMStorageTaskRunner::PostDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, base::TimeDelta delay) { - return task_runner_->PostTask(from_here, task); + return message_loop_->PostTask(from_here, task); } bool MockDOMStorageTaskRunner::PostShutdownBlockingTask( const tracked_objects::Location& from_here, SequenceID sequence_id, const base::Closure& task) { - return task_runner_->PostTask(from_here, task); + return message_loop_->PostTask(from_here, task); } bool MockDOMStorageTaskRunner::IsRunningOnSequence(SequenceID) const { - return task_runner_->RunsTasksOnCurrentThread(); + return message_loop_->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 f71c9c8b63eb71..1d4485c9bd801d 100644 --- a/content/browser/dom_storage/dom_storage_task_runner.h +++ b/content/browser/dom_storage/dom_storage_task_runner.h @@ -7,13 +7,12 @@ #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 SingleThreadTaskRunner; +class MessageLoopProxy; } namespace content { @@ -74,7 +73,7 @@ class CONTENT_EXPORT DOMStorageWorkerPoolTaskRunner : base::SequencedWorkerPool* sequenced_worker_pool, base::SequencedWorkerPool::SequenceToken primary_sequence_token, base::SequencedWorkerPool::SequenceToken commit_sequence_token, - base::SingleThreadTaskRunner* delayed_task_task_runner); + base::MessageLoopProxy* delayed_task_loop); bool PostDelayedTask(const tracked_objects::Location& from_here, const base::Closure& task, @@ -93,7 +92,7 @@ class CONTENT_EXPORT DOMStorageWorkerPoolTaskRunner : base::SequencedWorkerPool::SequenceToken IDtoToken(SequenceID id) const; - const scoped_refptr task_runner_; + const scoped_refptr message_loop_; const scoped_refptr sequenced_worker_pool_; base::SequencedWorkerPool::SequenceToken primary_sequence_token_; base::SequencedWorkerPool::SequenceToken commit_sequence_token_; @@ -107,7 +106,7 @@ class CONTENT_EXPORT DOMStorageWorkerPoolTaskRunner : class CONTENT_EXPORT MockDOMStorageTaskRunner : public DOMStorageTaskRunner { public: - explicit MockDOMStorageTaskRunner(base::SingleThreadTaskRunner* task_runner); + explicit MockDOMStorageTaskRunner(base::MessageLoopProxy* message_loop); bool PostDelayedTask(const tracked_objects::Location& from_here, const base::Closure& task, @@ -123,7 +122,7 @@ class CONTENT_EXPORT MockDOMStorageTaskRunner : ~MockDOMStorageTaskRunner() override; private: - const scoped_refptr task_runner_; + const scoped_refptr message_loop_; }; } // namespace content diff --git a/content/browser/download/download_file_impl.cc b/content/browser/download/download_file_impl.cc index 343672268e1bd1..5597703fa76852 100644 --- a/content/browser/download/download_file_impl.cc +++ b/content/browser/download/download_file_impl.cc @@ -8,6 +8,7 @@ #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 59cc4a766de9e7..620efa36ff0e09 100644 --- a/content/browser/download/download_file_unittest.cc +++ b/content/browser/download/download_file_unittest.cc @@ -4,12 +4,10 @@ #include "base/files/file.h" #include "base/files/file_util.h" -#include "base/location.h" +#include "base/message_loop/message_loop.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" @@ -652,16 +650,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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, first_failing_run.QuitClosure()); + base::MessageLoop::current()->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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, second_failing_run.QuitClosure()); + base::MessageLoop::current()->PostTask(FROM_HERE, + second_failing_run.QuitClosure()); second_failing_run.Run(); EXPECT_FALSE(did_run_callback); } @@ -777,9 +775,9 @@ TEST_F(DownloadFileTest, ConfirmUpdate) { AppendDataToFile(chunks1, 2); // Run the message loops for 750ms and check for results. - loop_.task_runner()->PostDelayedTask(FROM_HERE, - base::MessageLoop::QuitClosure(), - base::TimeDelta::FromMilliseconds(750)); + loop_.PostDelayedTask(FROM_HERE, + base::MessageLoop::QuitClosure(), + base::TimeDelta::FromMilliseconds(750)); loop_.Run(); EXPECT_EQ(static_cast(strlen(kTestData1) + strlen(kTestData2)), diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc index 99a57b197f35c2..ee610e4bba7faf 100644 --- a/content/browser/download/download_resource_handler.cc +++ b/content/browser/download/download_resource_handler.cc @@ -7,13 +7,11 @@ #include #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" @@ -193,7 +191,7 @@ bool DownloadResourceHandler::OnResponseStarted( // Create the ByteStream for sending data to the download sink. scoped_ptr stream_reader; CreateByteStream( - base::ThreadTaskRunnerHandle::Get(), + base::MessageLoopProxy::current(), 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 2014270e38c1a3..13950a1e2aaefb 100644 --- a/content/browser/download/drag_download_file.cc +++ b/content/browser/download/drag_download_file.cc @@ -6,8 +6,7 @@ #include "base/bind.h" #include "base/files/file.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" #include "content/browser/download/download_stats.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/browser_context.h" @@ -95,8 +94,7 @@ class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer { DCHECK_CURRENTLY_ON(BrowserThread::UI); if (!item) { DCHECK_NE(DOWNLOAD_INTERRUPT_REASON_NONE, interrupt_reason); - on_completed_loop_->task_runner()->PostTask( - FROM_HERE, base::Bind(on_completed_, false)); + on_completed_loop_->PostTask(FROM_HERE, base::Bind(on_completed_, false)); return; } DCHECK_EQ(DOWNLOAD_INTERRUPT_REASON_NONE, interrupt_reason); @@ -113,9 +111,8 @@ class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer { state == DownloadItem::CANCELLED || state == DownloadItem::INTERRUPTED) { if (!on_completed_.is_null()) { - on_completed_loop_->task_runner()->PostTask( - FROM_HERE, - base::Bind(on_completed_, state == DownloadItem::COMPLETE)); + on_completed_loop_->PostTask(FROM_HERE, base::Bind( + on_completed_, state == DownloadItem::COMPLETE)); on_completed_.Reset(); } download_item_->RemoveObserver(this); @@ -130,8 +127,8 @@ class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer { if (!on_completed_.is_null()) { const bool is_complete = download_item_->GetState() == DownloadItem::COMPLETE; - on_completed_loop_->task_runner()->PostTask( - FROM_HERE, base::Bind(on_completed_, is_complete)); + on_completed_loop_->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 e2fa5feaa56d96..ed90f1d60483fc 100644 --- a/content/browser/fileapi/blob_url_request_job_unittest.cc +++ b/content/browser/fileapi/blob_url_request_job_unittest.cc @@ -11,7 +11,6 @@ #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" @@ -72,7 +71,7 @@ class BlobURLRequestJobTest : public testing::Test { return new BlobURLRequestJob(request, network_delegate, test_->GetSnapshotFromBuilder(), test_->file_system_context_.get(), - base::ThreadTaskRunnerHandle::Get().get()); + base::MessageLoopProxy::current().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 c07db9db006b61..f9b8d1506f4583 100644 --- a/content/browser/fileapi/copy_or_move_file_validator_unittest.cc +++ b/content/browser/fileapi/copy_or_move_file_validator_unittest.cc @@ -6,10 +6,7 @@ #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" @@ -224,7 +221,7 @@ class TestCopyOrMoveFileValidatorFactory void StartPreWriteValidation( const ResultCallback& result_callback) override { // Post the result since a real validator must do work asynchronously. - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(result_callback, result_)); } @@ -232,7 +229,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::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 bbcae168c8a8c2..451353d1cd91e7 100644 --- a/content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc +++ b/content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc @@ -9,11 +9,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/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" @@ -81,7 +79,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::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(result_callback, result_)); } @@ -94,7 +92,7 @@ class TestValidatorFactory : public storage::CopyOrMoveFileValidatorFactory { result = base::File::FILE_ERROR_SECURITY; } // Post the result since a real validator must do work asynchronously. - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(result_callback, result)); } @@ -149,7 +147,7 @@ class ScopedThreadStopper { if (thread_) { // Give another chance for deleted streams to perform Close. base::RunLoop run_loop; - thread_->task_runner()->PostTaskAndReply( + thread_->message_loop_proxy()->PostTaskAndReply( FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure()); run_loop.Run(); thread_->Stop(); @@ -193,12 +191,13 @@ class CopyOrMoveOperationTestHelper { ASSERT_TRUE(base_.CreateUniqueTempDir()); base::FilePath base_dir = base_.path(); quota_manager_ = - new MockQuotaManager(false /* is_incognito */, base_dir, - base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), - NULL /* special storage policy */); + new MockQuotaManager(false /* is_incognito */, + base_dir, + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().get(), + NULL /* special storage policy */); quota_manager_proxy_ = new MockQuotaManagerProxy( - quota_manager_.get(), base::ThreadTaskRunnerHandle::Get().get()); + quota_manager_.get(), base::MessageLoopProxy::current().get()); file_system_context_ = CreateFileSystemContextForTesting(quota_manager_proxy_.get(), base_dir); @@ -729,8 +728,8 @@ TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelper) { ScopedThreadStopper thread_stopper(&file_thread); ASSERT_TRUE(thread_stopper.is_valid()); - scoped_refptr task_runner = - file_thread.task_runner(); + scoped_refptr task_runner = + file_thread.message_loop_proxy(); scoped_ptr reader( storage::FileStreamReader::CreateForLocalFile( @@ -785,8 +784,8 @@ TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelperWithFlush) { ScopedThreadStopper thread_stopper(&file_thread); ASSERT_TRUE(thread_stopper.is_valid()); - scoped_refptr task_runner = - file_thread.task_runner(); + scoped_refptr task_runner = + file_thread.message_loop_proxy(); scoped_ptr reader( storage::FileStreamReader::CreateForLocalFile( @@ -836,8 +835,8 @@ TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelper_Cancel) { ScopedThreadStopper thread_stopper(&file_thread); ASSERT_TRUE(thread_stopper.is_valid()); - scoped_refptr task_runner = - file_thread.task_runner(); + scoped_refptr task_runner = + file_thread.message_loop_proxy(); scoped_ptr reader( storage::FileStreamReader::CreateForLocalFile( @@ -855,7 +854,7 @@ TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelper_Cancel) { base::TimeDelta()); // For testing, we need all the progress. // Call Cancel() later. - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoopProxy::current()->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 38d83374baa31d..98b2ceec421118 100644 --- a/content/browser/fileapi/dragged_file_util_unittest.cc +++ b/content/browser/fileapi/dragged_file_util_unittest.cc @@ -13,6 +13,7 @@ #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 5ff96006abcc5c..79e9f3cb05faf1 100644 --- a/content/browser/fileapi/file_system_browsertest.cc +++ b/content/browser/fileapi/file_system_browsertest.cc @@ -5,9 +5,7 @@ #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 b1ffb6359d0f7d..c071c4b4d536d9 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,21 +54,26 @@ class FileSystemContextTest : public testing::Test { storage_policy_ = new MockSpecialStoragePolicy(); - mock_quota_manager_ = new MockQuotaManager( - false /* is_incognito */, data_dir_.path(), - base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), storage_policy_.get()); + mock_quota_manager_ = + new MockQuotaManager(false /* is_incognito */, + data_dir_.path(), + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().get(), + storage_policy_.get()); } protected: FileSystemContext* CreateFileSystemContextForTest( storage::ExternalMountPoints* external_mount_points) { return new FileSystemContext( - base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), external_mount_points, - storage_policy_.get(), mock_quota_manager_->proxy(), + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().get(), + external_mount_points, + storage_policy_.get(), + mock_quota_manager_->proxy(), ScopedVector(), - std::vector(), data_dir_.path(), + std::vector(), + 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 43dd81295c16e2..ff913ecaa18270 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,13 +10,12 @@ #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" @@ -154,7 +153,7 @@ class FileSystemDirURLRequestJobTest : public testing::Test { ScopedVector additional_providers; additional_providers.push_back(new TestFileSystemBackend( - base::ThreadTaskRunnerHandle::Get().get(), *mnt_point)); + base::MessageLoopProxy::current().get(), *mnt_point)); std::vector handlers; handlers.push_back(base::Bind(&TestAutoMountForURLRequest)); @@ -286,7 +285,7 @@ class FileSystemDirURLRequestJobTest : public testing::Test { } // Put the message loop at the top, so that it's the last thing deleted. - // Delete all task runner objects before the MessageLoop, to help prevent + // Delete all MessageLoopProxy 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 e4a1e6ccf55313..6f84204a4ac674 100644 --- a/content/browser/fileapi/file_system_operation_impl_unittest.cc +++ b/content/browser/fileapi/file_system_operation_impl_unittest.cc @@ -12,7 +12,6 @@ #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" @@ -58,12 +57,13 @@ class FileSystemOperationImplTest base::FilePath base_dir = base_.path().AppendASCII("filesystem"); quota_manager_ = - new MockQuotaManager(false /* is_incognito */, base_dir, - base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), - NULL /* special storage policy */); + new MockQuotaManager(false /* is_incognito */, + base_dir, + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().get(), + NULL /* special storage policy */); quota_manager_proxy_ = new MockQuotaManagerProxy( - quota_manager(), base::ThreadTaskRunnerHandle::Get().get()); + quota_manager(), base::MessageLoopProxy::current().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 ae3277fc2c86ff..ca324ae4653309 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,10 +66,11 @@ class FileSystemOperationImplWriteTest ASSERT_TRUE(dir_.CreateUniqueTempDir()); quota_manager_ = - new MockQuotaManager(false /* is_incognito */, dir_.path(), - base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), - NULL /* special storage policy */); + new MockQuotaManager(false /* is_incognito */, + dir_.path(), + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().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 b3333a0af1bf2d..5ab33e1b9238ef 100644 --- a/content/browser/fileapi/file_system_quota_client_unittest.cc +++ b/content/browser/fileapi/file_system_quota_client_unittest.cc @@ -6,6 +6,7 @@ #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 dca1c535083cb3..5e932f2b370605 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 additional_providers; additional_providers.push_back(new TestFileSystemBackend( - base::ThreadTaskRunnerHandle::Get().get(), mnt_point)); + base::MessageLoopProxy::current().get(), mnt_point)); std::vector 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 f67485c8c90263..13f1d659d301a1 100644 --- a/content/browser/fileapi/file_system_usage_cache_unittest.cc +++ b/content/browser/fileapi/file_system_usage_cache_unittest.cc @@ -8,7 +8,6 @@ #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; @@ -18,7 +17,7 @@ namespace content { class FileSystemUsageCacheTest : public testing::Test { public: FileSystemUsageCacheTest() - : usage_cache_(base::ThreadTaskRunnerHandle::Get().get()) {} + : usage_cache_(base::MessageLoopProxy::current().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 af60d3fcfa4dc1..1aacaccd2bbc92 100644 --- a/content/browser/fileapi/file_writer_delegate_unittest.cc +++ b/content/browser/fileapi/file_writer_delegate_unittest.cc @@ -9,10 +9,8 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/files/scoped_temp_dir.h" -#include "base/location.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/public/test/async_file_test_helper.h" #include "content/public/test/test_file_system_context.h" #include "net/base/io_buffer.h" @@ -98,8 +96,8 @@ class FileWriterDelegateTest : public PlatformTest { int64 GetFileSizeOnDisk(const char* test_file_path) { // There might be in-flight flush/write. - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(&base::DoNothing)); + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&base::DoNothing)); base::RunLoop().RunUntilIdle(); FileSystemURL url = GetFileSystemURL(test_file_path); @@ -179,7 +177,7 @@ class FileWriterDelegateTestJob : public net::URLRequestJob { } void Start() override { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 d8e30ce7ec56ad..5e17165d6b50e7 100644 --- a/content/browser/fileapi/local_file_stream_reader_unittest.cc +++ b/content/browser/fileapi/local_file_stream_reader_unittest.cc @@ -10,10 +10,8 @@ #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" @@ -103,8 +101,8 @@ class LocalFileStreamReaderTest : public testing::Test { new_modified_time)); } - base::SingleThreadTaskRunner* file_task_runner() const { - return file_thread_.task_runner().get(); + base::MessageLoopProxy* file_task_runner() const { + return file_thread_.message_loop_proxy().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 9e05310eb8f98b..48f5560ff8b909 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::SingleThreadTaskRunner* file_task_runner() const { - return file_thread_.task_runner().get(); + base::MessageLoopProxy* file_task_runner() const { + return file_thread_.message_loop_proxy().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 a0c9615d5fbd71..bf2f2f874a376c 100644 --- a/content/browser/fileapi/local_file_util_unittest.cc +++ b/content/browser/fileapi/local_file_util_unittest.cc @@ -8,6 +8,7 @@ #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 6677607deb6386..f6a86e964a016a 100644 --- a/content/browser/fileapi/mock_file_change_observer.cc +++ b/content/browser/fileapi/mock_file_change_observer.cc @@ -4,8 +4,6 @@ #include "content/browser/fileapi/mock_file_change_observer.h" -#include "base/thread_task_runner_handle.h" - namespace storage { MockFileChangeObserver::MockFileChangeObserver() @@ -22,7 +20,7 @@ MockFileChangeObserver::~MockFileChangeObserver() {} ChangeObserverList MockFileChangeObserver::CreateList( MockFileChangeObserver* observer) { ChangeObserverList list; - return list.AddObserver(observer, base::ThreadTaskRunnerHandle::Get().get()); + return list.AddObserver(observer, base::MessageLoopProxy::current().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 06638ff9b8a0bd..7abaf7e895881d 100644 --- a/content/browser/fileapi/obfuscated_file_util_unittest.cc +++ b/content/browser/fileapi/obfuscated_file_util_unittest.cc @@ -13,7 +13,6 @@ #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" @@ -157,10 +156,12 @@ class ObfuscatedFileUtilTest : public testing::Test { storage_policy_ = new MockSpecialStoragePolicy(); - quota_manager_ = new storage::QuotaManager( - false /* is_incognito */, data_dir_.path(), - base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), storage_policy_.get()); + quota_manager_ = + new storage::QuotaManager(false /* is_incognito */, + data_dir_.path(), + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().get(), + storage_policy_.get()); // Every time we create a new sandbox_file_system helper, // it creates another context, which creates another path manager, @@ -230,9 +231,10 @@ class ObfuscatedFileUtilTest : public testing::Test { scoped_ptr CreateObfuscatedFileUtil( storage::SpecialStoragePolicy* storage_policy) { - return scoped_ptr(ObfuscatedFileUtil::CreateForTesting( - storage_policy, data_dir_path(), NULL, - base::ThreadTaskRunnerHandle::Get().get())); + return scoped_ptr( + ObfuscatedFileUtil::CreateForTesting( + storage_policy, data_dir_path(), NULL, + base::MessageLoopProxy::current().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 8c5e45d0d37901..ef88fed2f83cd3 100644 --- a/content/browser/fileapi/plugin_private_file_system_backend_unittest.cc +++ b/content/browser/fileapi/plugin_private_file_system_backend_unittest.cc @@ -7,6 +7,7 @@ #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 54b9626ae0d512..3885384462898a 100644 --- a/content/browser/fileapi/recursive_operation_delegate_unittest.cc +++ b/content/browser/fileapi/recursive_operation_delegate_unittest.cc @@ -10,10 +10,9 @@ #include "base/bind.h" #include "base/callback.h" #include "base/files/scoped_temp_dir.h" -#include "base/location.h" +#include "base/message_loop/message_loop.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/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" @@ -116,7 +115,7 @@ void ReportStatus(base::File::Error* out_error, void CallCancelLater(storage::RecursiveOperationDelegate* operation, int counter) { if (counter > 0) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoopProxy::current()->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 fd25aa7f93774d..1b5b19b122cb15 100644 --- a/content/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc +++ b/content/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc @@ -8,7 +8,8 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.h" +#include "base/message_loop/message_loop_proxy.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" @@ -36,8 +37,10 @@ class SandboxFileSystemBackendDelegateTest : public testing::Test { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); delegate_.reset(new storage::SandboxFileSystemBackendDelegate( NULL /* quota_manager_proxy */, - base::ThreadTaskRunnerHandle::Get().get(), data_dir_.path(), - NULL /* special_storage_policy */, CreateAllowFileAccessOptions())); + base::MessageLoopProxy::current().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 38630b87790861..efa7259fd4441a 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,8 +79,10 @@ class SandboxFileSystemBackendTest : public testing::Test { void SetUpNewDelegate(const storage::FileSystemOptions& options) { delegate_.reset(new SandboxFileSystemBackendDelegate( NULL /* quota_manager_proxy */, - base::ThreadTaskRunnerHandle::Get().get(), data_dir_.path(), - NULL /* special_storage_policy */, options)); + base::MessageLoopProxy::current().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 1bdc25d727a4e2..5a6ac8df0e5e10 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,8 +21,7 @@ namespace { class Embedder { public: Embedder() - : timer_(base::ThreadTaskRunnerHandle::Get().get()), - timer_fired_(false) {} + : timer_(base::MessageLoopProxy::current().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 03e1bac4aa9912..455ac74ebe69af 100644 --- a/content/browser/frame_host/interstitial_page_impl.cc +++ b/content/browser/frame_host/interstitial_page_impl.cc @@ -8,11 +8,9 @@ #include "base/bind.h" #include "base/compiler_specific.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.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" @@ -291,9 +289,10 @@ 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::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( - FROM_HERE, base::Bind(&InterstitialPageImpl::Shutdown, - weak_ptr_factory_.GetWeakPtr())); + base::MessageLoop::current()->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 7cb7328c7e57c1..aec9dac07487b8 100644 --- a/content/browser/frame_host/render_frame_host_manager_browsertest.cc +++ b/content/browser/frame_host/render_frame_host_manager_browsertest.cc @@ -6,12 +6,9 @@ #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" @@ -1763,7 +1760,7 @@ class RenderFrameHostDestructionObserver : public WebContentsObserver { } if (deleted_ && message_loop_runner_->loop_running()) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, message_loop_runner_->QuitClosure()); } } diff --git a/content/browser/gamepad/gamepad_provider.cc b/content/browser/gamepad/gamepad_provider.cc index eef900133b0f6e..e16339cbc96904 100644 --- a/content/browser/gamepad/gamepad_provider.cc +++ b/content/browser/gamepad/gamepad_provider.cc @@ -7,11 +7,10 @@ #include #include "base/bind.h" -#include "base/location.h" #include "base/logging.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" +#include "base/message_loop/message_loop_proxy.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" @@ -30,8 +29,9 @@ namespace content { GamepadProvider::ClosureAndThread::ClosureAndThread( const base::Closure& c, - const scoped_refptr& m) - : closure(c), task_runner(m) { + const scoped_refptr& m) + : closure(c), + message_loop(m) { } GamepadProvider::ClosureAndThread::~ClosureAndThread() { @@ -83,7 +83,7 @@ void GamepadProvider::Pause() { is_paused_ = true; } base::MessageLoop* polling_loop = polling_thread_->message_loop(); - polling_loop->task_runner()->PostTask( + polling_loop->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->task_runner()->PostTask( + polling_loop->PostTask( FROM_HERE, base::Bind(&GamepadProvider::SendPauseHint, Unretained(this), false)); - polling_loop->task_runner()->PostTask( + polling_loop->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()->task_runner())); + user_gesture_observers_.push_back(ClosureAndThread( + closure, base::MessageLoop::current()->message_loop_proxy())); } void GamepadProvider::OnDevicesChanged(base::SystemMonitor::DeviceType type) { @@ -144,9 +144,11 @@ void GamepadProvider::Initialize(scoped_ptr fetcher) { #endif polling_thread_->StartWithOptions(base::Thread::Options(kMessageLoopType, 0)); - polling_thread_->task_runner()->PostTask( - FROM_HERE, base::Bind(&GamepadProvider::DoInitializePollingThread, - base::Unretained(this), base::Passed(&fetcher))); + polling_thread_->message_loop()->PostTask( + FROM_HERE, + base::Bind(&GamepadProvider::DoInitializePollingThread, + base::Unretained(this), + base::Passed(&fetcher))); } void GamepadProvider::DoInitializePollingThread( @@ -262,8 +264,9 @@ void GamepadProvider::ScheduleDoPoll() { return; } - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::Bind(&GamepadProvider::DoPoll, Unretained(this)), + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&GamepadProvider::DoPoll, Unretained(this)), base::TimeDelta::FromMilliseconds(kDesiredSamplingIntervalMs)); have_scheduled_do_poll_ = true; } @@ -310,8 +313,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].task_runner->PostTask( - FROM_HERE, user_gesture_observers_[i].closure); + user_gesture_observers_[i].message_loop->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 ce9c11a8e0963e..a81061a21f53c0 100644 --- a/content/browser/gamepad/gamepad_provider.h +++ b/content/browser/gamepad/gamepad_provider.h @@ -13,13 +13,14 @@ #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 SingleThreadTaskRunner; +class MessageLoopProxy; class Thread; } @@ -104,11 +105,11 @@ class CONTENT_EXPORT GamepadProvider : base::Lock user_gesture_lock_; struct ClosureAndThread { ClosureAndThread(const base::Closure& c, - const scoped_refptr& m); + const scoped_refptr& m); ~ClosureAndThread(); base::Closure closure; - scoped_refptr task_runner; + scoped_refptr message_loop; }; typedef std::vector UserGestureObserverVector; UserGestureObserverVector user_gesture_observers_; diff --git a/content/browser/geofencing/geofencing_service.cc b/content/browser/geofencing/geofencing_service.cc index c9ea83d893fe36..11df9529e4d34c 100644 --- a/content/browser/geofencing/geofencing_service.cc +++ b/content/browser/geofencing/geofencing_service.cc @@ -4,10 +4,8 @@ #include "content/browser/geofencing/geofencing_service.h" -#include "base/location.h" #include "base/memory/singleton.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.h" #include "content/browser/geofencing/geofencing_provider.h" #include "content/browser/geofencing/geofencing_registration_delegate.h" #include "content/public/browser/browser_thread.h" @@ -19,7 +17,7 @@ namespace { void RunSoon(const base::Closure& callback) { if (!callback.is_null()) - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); + base::MessageLoop::current()->PostTask(FROM_HERE, callback); } } // namespace diff --git a/content/browser/geofencing/mock_geofencing_service.cc b/content/browser/geofencing/mock_geofencing_service.cc index c3a1f27a3d343a..e53b8c72f55d8b 100644 --- a/content/browser/geofencing/mock_geofencing_service.cc +++ b/content/browser/geofencing/mock_geofencing_service.cc @@ -10,9 +10,7 @@ #include #include "base/bind.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.h" #include "content/browser/geofencing/geofencing_registration_delegate.h" #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h" @@ -23,7 +21,7 @@ namespace { void RegisterRegionResult(GeofencingRegistrationDelegate* delegate, int64 geofencing_registration_id, GeofencingStatus status) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&GeofencingRegistrationDelegate::RegistrationFinished, base::Unretained(delegate), geofencing_registration_id, @@ -111,7 +109,7 @@ int64 MockGeofencingService::RegisterRegion( PositionInRegion(last_latitude_, last_longitude_, region); RegisterRegionResult(delegate, id, GEOFENCING_STATUS_OK); if (registration.is_inside) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 9e8704a07923bb..0e5fe401289563 100644 --- a/content/browser/geolocation/fake_access_token_store.cc +++ b/content/browser/geolocation/fake_access_token_store.cc @@ -7,14 +7,16 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop_proxy.h" +using base::MessageLoopProxy; using testing::_; using testing::Invoke; namespace content { -FakeAccessTokenStore::FakeAccessTokenStore() : originating_task_runner_(NULL) { +FakeAccessTokenStore::FakeAccessTokenStore() + : originating_message_loop_(NULL) { ON_CALL(*this, LoadAccessTokens(_)) .WillByDefault(Invoke(this, &FakeAccessTokenStore::DefaultLoadAccessTokens)); @@ -24,9 +26,9 @@ FakeAccessTokenStore::FakeAccessTokenStore() : originating_task_runner_(NULL) { } void FakeAccessTokenStore::NotifyDelegateTokensLoaded() { - DCHECK(originating_task_runner_); - if (!originating_task_runner_->BelongsToCurrentThread()) { - originating_task_runner_->PostTask( + DCHECK(originating_message_loop_); + if (!originating_message_loop_->BelongsToCurrentThread()) { + originating_message_loop_->PostTask( FROM_HERE, base::Bind(&FakeAccessTokenStore::NotifyDelegateTokensLoaded, this)); return; @@ -38,7 +40,7 @@ void FakeAccessTokenStore::NotifyDelegateTokensLoaded() { void FakeAccessTokenStore::DefaultLoadAccessTokens( const LoadAccessTokensCallbackType& callback) { - originating_task_runner_ = base::ThreadTaskRunnerHandle::Get().get(); + originating_message_loop_ = MessageLoopProxy::current().get(); callback_ = callback; } diff --git a/content/browser/geolocation/fake_access_token_store.h b/content/browser/geolocation/fake_access_token_store.h index 423b317e489358..30a01859d101bf 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/single_thread_task_runner.h" +#include "base/message_loop/message_loop_proxy.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::SingleThreadTaskRunner* originating_task_runner_; + base::MessageLoopProxy* originating_message_loop_; DISALLOW_COPY_AND_ASSIGN(FakeAccessTokenStore); }; diff --git a/content/browser/geolocation/geolocation_provider_impl.cc b/content/browser/geolocation/geolocation_provider_impl.cc index 4c322696e1a22b..7375d578665316 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/single_thread_task_runner.h" +#include "base/message_loop/message_loop.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); } - task_runner()->PostTask(FROM_HERE, task); + message_loop()->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()) { - task_runner()->PostTask( + message_loop()->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 3ba4dae1baa228..685818b8279aa8 100644 --- a/content/browser/geolocation/geolocation_provider_impl_unittest.cc +++ b/content/browser/geolocation/geolocation_provider_impl_unittest.cc @@ -4,10 +4,9 @@ #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/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" #include "base/strings/string16.h" #include "base/time/time.h" #include "content/browser/geolocation/geolocation_provider_impl.h" @@ -141,9 +140,11 @@ bool GeolocationProviderTest::ProvidersStarted() { DCHECK(provider_->IsRunning()); DCHECK(base::MessageLoop::current() == &message_loop_); bool started; - provider_->task_runner()->PostTaskAndReply( - FROM_HERE, base::Bind(&GeolocationProviderTest::GetProvidersStarted, - base::Unretained(this), &started), + provider_->message_loop_proxy()->PostTaskAndReply( + FROM_HERE, + base::Bind(&GeolocationProviderTest::GetProvidersStarted, + base::Unretained(this), + &started), base::MessageLoop::QuitClosure()); message_loop_.Run(); return started; @@ -157,9 +158,11 @@ void GeolocationProviderTest::GetProvidersStarted(bool* started) { void GeolocationProviderTest::SendMockLocation(const Geoposition& position) { DCHECK(provider_->IsRunning()); DCHECK(base::MessageLoop::current() == &message_loop_); - provider_->task_runner()->PostTask( - FROM_HERE, base::Bind(&GeolocationProviderImpl::OnLocationUpdate, - base::Unretained(provider_.get()), position)); + provider_->message_loop() + ->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 a78cae228cfbb7..84cfd101fd335b 100644 --- a/content/browser/geolocation/location_api_adapter_android.cc +++ b/content/browser/geolocation/location_api_adapter_android.cc @@ -8,7 +8,6 @@ #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" @@ -42,7 +41,7 @@ AndroidLocationApiAdapter::AndroidLocationApiAdapter() AndroidLocationApiAdapter::~AndroidLocationApiAdapter() { CHECK(!location_provider_); - CHECK(!task_runner_.get()); + CHECK(!message_loop_.get()); CHECK(java_location_provider_android_object_.is_null()); } @@ -55,14 +54,14 @@ bool AndroidLocationApiAdapter::Start( CreateJavaObject(env); { base::AutoLock lock(lock_); - CHECK(!task_runner_.get()); - task_runner_ = base::ThreadTaskRunnerHandle::Get(); + CHECK(!message_loop_.get()); + message_loop_ = base::MessageLoopProxy::current(); } } // 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(task_runner_.get()); + CHECK(message_loop_.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. @@ -72,14 +71,14 @@ bool AndroidLocationApiAdapter::Start( void AndroidLocationApiAdapter::Stop() { if (!location_provider_) { - CHECK(!task_runner_.get()); + CHECK(!message_loop_.get()); CHECK(java_location_provider_android_object_.is_null()); return; } { base::AutoLock lock(lock_); - task_runner_ = NULL; + message_loop_ = NULL; } location_provider_ = NULL; @@ -95,7 +94,7 @@ void AndroidLocationApiAdapter::NotifyProviderNewGeoposition( const Geoposition& geoposition) { // Called on the geolocation thread, safe to access location_provider_ here. if (GetInstance()->location_provider_) { - CHECK(GetInstance()->task_runner_->BelongsToCurrentThread()); + CHECK(GetInstance()->message_loop_->BelongsToCurrentThread()); GetInstance()->location_provider_->NotifyNewGeoposition(geoposition); } } @@ -153,12 +152,13 @@ void AndroidLocationApiAdapter::CreateJavaObject(JNIEnv* env) { void AndroidLocationApiAdapter::OnNewGeopositionInternal( const Geoposition& geoposition) { base::AutoLock lock(lock_); - if (!task_runner_.get()) + if (!message_loop_.get()) return; - task_runner_->PostTask( + message_loop_->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 8cba148ae2cd15..d1d2fa52ee74e2 100644 --- a/content/browser/geolocation/location_api_adapter_android.h +++ b/content/browser/geolocation/location_api_adapter_android.h @@ -9,12 +9,9 @@ #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; @@ -76,7 +73,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 task_runner_; + scoped_refptr message_loop_; }; } // namespace content diff --git a/content/browser/geolocation/mock_location_provider.cc b/content/browser/geolocation/mock_location_provider.cc index 0bb760f06b165e..2953ba1be17491 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/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.h" +#include "base/message_loop/message_loop_proxy.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_task_runner_(base::ThreadTaskRunnerHandle::Get()) { + provider_loop_(base::MessageLoopProxy::current()) { CHECK(self_ref_); CHECK(*self_ref_ == NULL); *self_ref_ = this; @@ -34,15 +34,16 @@ MockLocationProvider::~MockLocationProvider() { } void MockLocationProvider::HandlePositionChanged(const Geoposition& position) { - if (provider_task_runner_->BelongsToCurrentThread()) { + if (provider_loop_->BelongsToCurrentThread()) { // The location arbitrator unit tests rely on this method running // synchronously. position_ = position; NotifyCallback(position_); } else { - provider_task_runner_->PostTask( - FROM_HERE, base::Bind(&MockLocationProvider::HandlePositionChanged, - base::Unretained(this), position)); + provider_loop_->PostTask( + FROM_HERE, + base::Bind(&MockLocationProvider::HandlePositionChanged, + base::Unretained(this), position)); } } @@ -103,9 +104,11 @@ class AutoMockLocationProvider : public MockLocationProvider { void UpdateListenersIfNeeded() { if (!listeners_updated_) { listeners_updated_ = true; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&MockLocationProvider::HandlePositionChanged, - weak_factory_.GetWeakPtr(), position_)); + base::MessageLoop::current()->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 bedd2a4fad614c..882a447330d0d5 100644 --- a/content/browser/geolocation/mock_location_provider.h +++ b/content/browser/geolocation/mock_location_provider.h @@ -8,7 +8,6 @@ #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" @@ -37,7 +36,7 @@ class MockLocationProvider : public LocationProviderBase { bool is_permission_granted_; MockLocationProvider** self_ref_; - scoped_refptr provider_task_runner_; + scoped_refptr provider_loop_; // 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 5db43fa6784175..13a6504d006dc1 100644 --- a/content/browser/geolocation/network_location_provider.cc +++ b/content/browser/geolocation/network_location_provider.cc @@ -5,10 +5,7 @@ #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" @@ -202,9 +199,10 @@ bool NetworkLocationProvider::StartProvider(bool high_accuracy) { wifi_data_provider_manager_ = WifiDataProviderManager::Register(&wifi_data_update_callback_); - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::Bind(&NetworkLocationProvider::RequestPosition, - weak_factory_.GetWeakPtr()), + base::MessageLoop::current()->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 71b78c4765ed94..cd739e7fb7cb70 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_->task_runner()->PostTask( - FROM_HERE, base::Bind(&WifiDataProvider::DoRunCallbacks, this)); + client_loop_->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 7bac7abf95c535..388a17e5a9bf3a 100644 --- a/content/browser/geolocation/wifi_data_provider_common.cc +++ b/content/browser/geolocation/wifi_data_provider_common.cc @@ -5,8 +5,6 @@ #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" @@ -82,9 +80,10 @@ void WifiDataProviderCommon::DoWifiScanTask() { } void WifiDataProviderCommon::ScheduleNextScan(int interval) { - client_loop()->task_runner()->PostDelayedTask( - FROM_HERE, base::Bind(&WifiDataProviderCommon::DoWifiScanTask, - weak_factory_.GetWeakPtr()), + client_loop()->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 d14dd4c392c2f7..4019ccb8fc7125 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.cc +++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc @@ -7,11 +7,8 @@ #include #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" @@ -126,7 +123,7 @@ class BrowserGpuChannelHostFactory::EstablishRequest IPC::ChannelHandle channel_handle_; gpu::GPUInfo gpu_info_; bool finished_; - scoped_refptr main_task_runner_; + scoped_refptr main_loop_; }; scoped_refptr @@ -135,10 +132,10 @@ BrowserGpuChannelHostFactory::EstablishRequest::Create(CauseForGpuLaunch cause, int gpu_host_id) { scoped_refptr establish_request = new EstablishRequest(cause, gpu_client_id, gpu_host_id); - scoped_refptr task_runner = + scoped_refptr loop = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); // PostTask outside the constructor to ensure at least one reference exists. - task_runner->PostTask( + loop->PostTask( FROM_HERE, base::Bind(&BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO, establish_request)); @@ -155,7 +152,7 @@ BrowserGpuChannelHostFactory::EstablishRequest::EstablishRequest( gpu_host_id_(gpu_host_id), reused_gpu_process_(false), finished_(false), - main_task_runner_(base::ThreadTaskRunnerHandle::Get()) { + main_loop_(base::MessageLoopProxy::current()) { } void BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO() { @@ -215,7 +212,7 @@ void BrowserGpuChannelHostFactory::EstablishRequest::OnEstablishedOnIO( void BrowserGpuChannelHostFactory::EstablishRequest::FinishOnIO() { event_.Signal(); - main_task_runner_->PostTask( + main_loop_->PostTask( FROM_HERE, base::Bind(&BrowserGpuChannelHostFactory::EstablishRequest::FinishOnMain, this)); @@ -231,7 +228,7 @@ void BrowserGpuChannelHostFactory::EstablishRequest::FinishOnMain() { } void BrowserGpuChannelHostFactory::EstablishRequest::Wait() { - DCHECK(main_task_runner_->BelongsToCurrentThread()); + DCHECK(main_loop_->BelongsToCurrentThread()); { // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. tracked_objects::ScopedTracker tracking_profile( @@ -251,7 +248,7 @@ void BrowserGpuChannelHostFactory::EstablishRequest::Wait() { } void BrowserGpuChannelHostFactory::EstablishRequest::Cancel() { - DCHECK(main_task_runner_->BelongsToCurrentThread()); + DCHECK(main_loop_->BelongsToCurrentThread()); finished_ = true; } diff --git a/content/browser/histogram_synchronizer.cc b/content/browser/histogram_synchronizer.cc index 585179031e3b64..9b15b73b30f4f7 100644 --- a/content/browser/histogram_synchronizer.cc +++ b/content/browser/histogram_synchronizer.cc @@ -6,12 +6,10 @@ #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" @@ -321,7 +319,7 @@ void HistogramSynchronizer::InternalPostTask(base::MessageLoop* thread, const base::Closure& callback) { if (callback.is_null() || !thread) return; - thread->task_runner()->PostTask(FROM_HERE, callback); + thread->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 cf5b049e059673..2ab58c2cd2b03c 100644 --- a/content/browser/indexed_db/indexed_db_browsertest.cc +++ b/content/browser/indexed_db/indexed_db_browsertest.cc @@ -9,9 +9,8 @@ #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/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" #include "base/strings/utf_string_conversions.h" #include "base/test/thread_test_helper.h" #include "content/browser/browser_main_loop.h" @@ -143,7 +142,8 @@ class IndexedDBBrowserTest : public ContentBrowserTest { GURL("file:///")), base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, this)); scoped_refptr helper(new base::ThreadTestHelper( - BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); + BrowserMainLoop::GetInstance()->indexed_db_thread()-> + message_loop_proxy())); EXPECT_TRUE(helper->Run()); // Wait for DidGetDiskUsage to be called. base::MessageLoop::current()->RunUntilIdle(); @@ -156,8 +156,10 @@ class IndexedDBBrowserTest : public ContentBrowserTest { base::Bind(&IndexedDBContextImpl::GetOriginBlobFileCount, GetContext(), GURL("file:///")), base::Bind(&IndexedDBBrowserTest::DidGetBlobFileCount, this)); - scoped_refptr helper(new base::ThreadTestHelper( - BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); + scoped_refptr helper( + new base::ThreadTestHelper(BrowserMainLoop::GetInstance() + ->indexed_db_thread() + ->message_loop_proxy())); EXPECT_TRUE(helper->Run()); // Wait for DidGetBlobFileCount to be called. base::MessageLoop::current()->RunUntilIdle(); @@ -321,7 +323,8 @@ class IndexedDBBrowserTestWithPreexistingLevelDB : public IndexedDBBrowserTest { base::Bind( &CopyLevelDBToProfile, shell(), context, EnclosingLevelDBDir())); scoped_refptr helper(new base::ThreadTestHelper( - BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); + BrowserMainLoop::GetInstance()->indexed_db_thread()-> + message_loop_proxy())); ASSERT_TRUE(helper->Run()); } @@ -474,8 +477,10 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DeleteForOriginDeletesBlobs) { GetContext()->TaskRunner()->PostTask( FROM_HERE, base::Bind(&IndexedDBContextImpl::DeleteForOrigin, GetContext(), GURL("file:///"))); - scoped_refptr helper(new base::ThreadTestHelper( - BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); + scoped_refptr helper( + new base::ThreadTestHelper(BrowserMainLoop::GetInstance() + ->indexed_db_thread() + ->message_loop_proxy())); 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 a99588ca3f94a4..b9e9bceed0add6 100644 --- a/content/browser/indexed_db/indexed_db_quota_client.h +++ b/content/browser/indexed_db/indexed_db_quota_client.h @@ -10,6 +10,7 @@ #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 3bec0b045320fb..f0befd24666f6d 100644 --- a/content/browser/indexed_db/indexed_db_quota_client_unittest.cc +++ b/content/browser/indexed_db/indexed_db_quota_client_unittest.cc @@ -8,6 +8,7 @@ #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" @@ -43,9 +44,10 @@ class IndexedDBQuotaClientTest : public testing::Test { browser_context_.reset(new TestBrowserContext()); scoped_refptr quota_manager = - new MockQuotaManager(false /*in_memory*/, browser_context_->GetPath(), - base::MessageLoop::current()->task_runner(), - base::MessageLoop::current()->task_runner(), + new MockQuotaManager(false /*in_memory*/, + browser_context_->GetPath(), + base::MessageLoop::current()->message_loop_proxy(), + base::MessageLoop::current()->message_loop_proxy(), 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 92679997104233..cb6fad6a01ae6a 100644 --- a/content/browser/indexed_db/indexed_db_transaction.cc +++ b/content/browser/indexed_db/indexed_db_transaction.cc @@ -5,11 +5,9 @@ #include "content/browser/indexed_db/indexed_db_transaction.h" #include "base/bind.h" -#include "base/location.h" #include "base/logging.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.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" @@ -124,7 +122,7 @@ void IndexedDBTransaction::RunTasksIfStarted() { return; should_process_queue_ = true; - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 a160eed36f46ab..2d4e088318de72 100644 --- a/content/browser/loader/buffered_resource_handler.cc +++ b/content/browser/loader/buffered_resource_handler.cc @@ -7,12 +7,9 @@ #include #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" @@ -199,7 +196,7 @@ void BufferedResourceHandler::Resume() { NOTREACHED(); break; case STATE_REPLAYING: - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 5df1109cb8ba68..c3b4eca5233c01 100644 --- a/content/browser/loader/resource_dispatcher_host_unittest.cc +++ b/content/browser/loader/resource_dispatcher_host_unittest.cc @@ -8,15 +8,13 @@ #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" @@ -444,7 +442,7 @@ class URLRequestBigJob : public net::URLRequestSimpleJob { } base::TaskRunner* GetTaskRunner() const override { - return base::ThreadTaskRunnerHandle::Get().get(); + return base::MessageLoopProxy::current().get(); } private: @@ -924,7 +922,7 @@ class ResourceDispatcherHostTest : public testing::Test, scoped_ptr ack( new ResourceHostMsg_DataReceived_ACK(request_id)); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 63b9f9c8439c41..f3be2a80c55f33 100644 --- a/content/browser/loader/resource_loader.cc +++ b/content/browser/loader/resource_loader.cc @@ -5,11 +5,9 @@ #include "content/browser/loader/resource_loader.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/time/time.h" #include "content/browser/appcache/appcache_interceptor.h" #include "content/browser/child_process_security_policy_impl.h" @@ -467,20 +465,23 @@ void ResourceLoader::Resume() { request_->FollowDeferredRedirect(); break; case DEFERRED_READ: - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ResourceLoader::ResumeReading, - weak_ptr_factory_.GetWeakPtr())); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&ResourceLoader::ResumeReading, + weak_ptr_factory_.GetWeakPtr())); break; case DEFERRED_RESPONSE_COMPLETE: - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ResourceLoader::ResponseCompleted, - weak_ptr_factory_.GetWeakPtr())); + base::MessageLoop::current()->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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ResourceLoader::CallDidFinishLoading, - weak_ptr_factory_.GetWeakPtr())); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&ResourceLoader::CallDidFinishLoading, + weak_ptr_factory_.GetWeakPtr())); break; } } @@ -544,9 +545,10 @@ 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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ResourceLoader::ResponseCompleted, - weak_ptr_factory_.GetWeakPtr())); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&ResourceLoader::ResponseCompleted, + weak_ptr_factory_.GetWeakPtr())); } } @@ -621,10 +623,12 @@ 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::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 7b4000e3e3344f..16cab3a255ca49 100644 --- a/content/browser/loader/resource_loader_unittest.cc +++ b/content/browser/loader/resource_loader_unittest.cc @@ -6,11 +6,9 @@ #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" @@ -106,7 +104,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::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&LoaderDestroyingCertStore::DoCallback, base::Unretained(loader_), callback)); } @@ -137,7 +135,7 @@ class MockClientCertURLRequestJob : public net::URLRequestTestJob { scoped_refptr cert_request_info( new net::SSLCertRequestInfo); cert_request_info->cert_authorities = test_authorities(); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&MockClientCertURLRequestJob::NotifyCertificateRequested, this, cert_request_info)); @@ -409,7 +407,7 @@ class NonChunkedUploadDataStream : public net::UploadDataStream { void CreateTemporaryError( base::File::Error error, const CreateTemporaryFileStreamCallback& callback) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, error, base::Passed(scoped_ptr()), scoped_refptr())); @@ -781,7 +779,7 @@ class ResourceLoaderRedirectToFileTest : public ResourceLoaderTest { // Create mock file streams and a ShareableFileReference. scoped_ptr file_stream( new net::testing::MockFileStream(file.Pass(), - base::ThreadTaskRunnerHandle::Get())); + base::MessageLoopProxy::current())); file_stream_ = file_stream.get(); deletable_file_ = ShareableFileReference::GetOrCreate( temp_path_, @@ -804,9 +802,10 @@ class ResourceLoaderRedirectToFileTest : public ResourceLoaderTest { void PostCallback( scoped_ptr file_stream, const CreateTemporaryFileStreamCallback& callback) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(callback, base::File::FILE_OK, - base::Passed(&file_stream), deletable_file_)); + base::MessageLoop::current()->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 174a89bff0d439..57161eaf4caf1a 100644 --- a/content/browser/loader/upload_data_stream_builder_unittest.cc +++ b/content/browser/loader/upload_data_stream_builder_unittest.cc @@ -9,8 +9,9 @@ #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" @@ -77,8 +78,7 @@ TEST(UploadDataStreamBuilderTest, CreateUploadDataStreamWithoutBlob) { request_body->set_identifier(kIdentifier); scoped_ptr upload(UploadDataStreamBuilder::Build( - request_body.get(), NULL, NULL, - base::ThreadTaskRunnerHandle::Get().get())); + request_body.get(), NULL, NULL, base::MessageLoopProxy::current().get())); EXPECT_EQ(kIdentifier, upload->identifier()); ASSERT_TRUE(upload->GetElementReaders()); @@ -146,9 +146,12 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { upload_element2.length(), upload_element2.expected_modification_time()); - scoped_ptr upload(UploadDataStreamBuilder::Build( - request_body.get(), &blob_storage_context, NULL, - base::ThreadTaskRunnerHandle::Get().get())); + scoped_ptr upload( + UploadDataStreamBuilder::Build( + request_body.get(), + &blob_storage_context, + NULL, + base::MessageLoopProxy::current().get())); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(2U, upload->GetElementReaders()->size()); @@ -162,8 +165,10 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { request_body->AppendBlob(blob_id0); upload = UploadDataStreamBuilder::Build( - request_body.get(), &blob_storage_context, NULL, - base::ThreadTaskRunnerHandle::Get().get()); + request_body.get(), + &blob_storage_context, + NULL, + base::MessageLoopProxy::current().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(0U, upload->GetElementReaders()->size()); @@ -172,8 +177,10 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { request_body->AppendBlob(blob_id1); upload = UploadDataStreamBuilder::Build( - request_body.get(), &blob_storage_context, NULL, - base::ThreadTaskRunnerHandle::Get().get()); + request_body.get(), + &blob_storage_context, + NULL, + base::MessageLoopProxy::current().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(2U, upload->GetElementReaders()->size()); EXPECT_TRUE(AreElementsEqual( @@ -194,8 +201,10 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { upload_element2.expected_modification_time()); upload = UploadDataStreamBuilder::Build( - request_body.get(), &blob_storage_context, NULL, - base::ThreadTaskRunnerHandle::Get().get()); + request_body.get(), + &blob_storage_context, + NULL, + base::MessageLoopProxy::current().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(4U, upload->GetElementReaders()->size()); EXPECT_TRUE(AreElementsEqual( @@ -219,9 +228,11 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { upload_element2.expected_modification_time()); request_body->AppendBlob(blob_id1); - upload = UploadDataStreamBuilder::Build( - request_body.get(), &blob_storage_context, NULL, - base::ThreadTaskRunnerHandle::Get().get()); + upload = + UploadDataStreamBuilder::Build(request_body.get(), + &blob_storage_context, + NULL, + base::MessageLoopProxy::current().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(4U, upload->GetElementReaders()->size()); EXPECT_TRUE(AreElementsEqual( @@ -246,8 +257,10 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { upload_element2.expected_modification_time()); upload = UploadDataStreamBuilder::Build( - request_body.get(), &blob_storage_context, NULL, - base::ThreadTaskRunnerHandle::Get().get()); + request_body.get(), + &blob_storage_context, + NULL, + base::MessageLoopProxy::current().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(4U, upload->GetElementReaders()->size()); EXPECT_TRUE(AreElementsEqual( @@ -274,8 +287,10 @@ TEST(UploadDataStreamBuilderTest, ResolveBlobAndCreateUploadDataStream) { upload_element2.expected_modification_time()); upload = UploadDataStreamBuilder::Build( - request_body.get(), &blob_storage_context, NULL, - base::ThreadTaskRunnerHandle::Get().get()); + request_body.get(), + &blob_storage_context, + NULL, + base::MessageLoopProxy::current().get()); ASSERT_TRUE(upload->GetElementReaders()); ASSERT_EQ(8U, upload->GetElementReaders()->size()); EXPECT_TRUE(AreElementsEqual( @@ -326,7 +341,7 @@ TEST(UploadDataStreamBuilderTest, scoped_refptr request_body(new ResourceRequestBody()); scoped_ptr upload(UploadDataStreamBuilder::Build( request_body.get(), &blob_storage_context, NULL, - base::ThreadTaskRunnerHandle::Get().get())); + base::MessageLoopProxy::current().get())); request_body = new ResourceRequestBody(); request_body->AppendBlob(blob_id); @@ -335,7 +350,7 @@ TEST(UploadDataStreamBuilderTest, upload = UploadDataStreamBuilder::Build( request_body.get(), &blob_storage_context, NULL, - base::ThreadTaskRunnerHandle::Get().get()); + base::MessageLoopProxy::current().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 96cef236741e8a..051aec10348538 100644 --- a/content/browser/media/capture/content_video_capture_device_core.cc +++ b/content/browser/media/capture/content_video_capture_device_core.cc @@ -11,6 +11,7 @@ #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 c7c9c84204b7a6..0eebd7a8083b9f 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/location.h" +#include "base/message_loop/message_loop.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" @@ -201,7 +201,8 @@ class WebContentsAudioInputStreamTest : public testing::Test { } void Open() { - mock_vais_ = new MockVirtualAudioInputStream(audio_thread_.task_runner()); + mock_vais_ = + new MockVirtualAudioInputStream(audio_thread_.message_loop_proxy()); EXPECT_CALL(*mock_vais_, Open()); EXPECT_CALL(*mock_vais_, Close()); // At Close() time. @@ -340,7 +341,7 @@ class WebContentsAudioInputStreamTest : public testing::Test { } void RunOnAudioThread(const base::Closure& closure) { - audio_thread_.task_runner()->PostTask(FROM_HERE, closure); + audio_thread_.message_loop()->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 dca65d372608f8..def9f9a744781c 100644 --- a/content/browser/media/capture/web_contents_video_capture_device.cc +++ b/content/browser/media/capture/web_contents_video_capture_device.cc @@ -53,13 +53,12 @@ #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" @@ -634,9 +633,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_->task_runner()->PostTask( - FROM_HERE, base::Bind(&RenderVideoFrame, bitmap, target, - base::Bind(deliver_frame_cb, start_time))); + render_thread_->message_loop_proxy()->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 8a0fbd40b035e0..05f4dd82a63064 100644 --- a/content/browser/media/media_internals_proxy.cc +++ b/content/browser/media/media_internals_proxy.cc @@ -5,9 +5,7 @@ #include "content/browser/media/media_internals_proxy.h" #include "base/bind.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.h" #include "content/browser/media/media_internals_handler.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/notification_service.h" @@ -158,7 +156,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::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + base::MessageLoop::current()->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 6b46b618ea26f2..e80cac725e7449 100644 --- a/content/browser/net/view_http_cache_job_factory.cc +++ b/content/browser/net/view_http_cache_job_factory.cc @@ -8,11 +8,9 @@ #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/single_thread_task_runner.h" +#include "base/message_loop/message_loop.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" @@ -98,7 +96,7 @@ class ViewHttpCacheJob : public net::URLRequestJob { }; void ViewHttpCacheJob::Start() { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 4560f7d5c1879f..30ab46a78fab77 100644 --- a/content/browser/notifications/platform_notification_context_unittest.cc +++ b/content/browser/notifications/platform_notification_context_unittest.cc @@ -6,7 +6,6 @@ #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" @@ -100,7 +99,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::ThreadTaskRunnerHandle::Get()); + context->SetTaskRunnerForTesting(base::MessageLoopProxy::current()); } // 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 bfc9032f665bfe..b8750ed90ea3cf 100644 --- a/content/browser/plugin_loader_posix.cc +++ b/content/browser/plugin_loader_posix.cc @@ -5,10 +5,9 @@ #include "content/browser/plugin_loader_posix.h" #include "base/bind.h" -#include "base/location.h" +#include "base/message_loop/message_loop.h" +#include "base/message_loop/message_loop_proxy.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" @@ -30,8 +29,8 @@ void PluginLoaderPosix::GetPlugins( std::vector cached_plugins; if (PluginList::Singleton()->GetPluginsNoRefresh(&cached_plugins)) { // Can't assume the caller is reentrant. - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(callback, cached_plugins)); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(callback, cached_plugins)); return; } @@ -227,7 +226,7 @@ void PluginLoaderPosix::FinishedLoadingPlugins() { PluginList::Singleton()->SetPlugins(loaded_plugins_); for (auto& callback : callbacks_) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 2db16341b0d5c2..3a50bcd496ccb5 100644 --- a/content/browser/plugin_loader_posix.h +++ b/content/browser/plugin_loader_posix.h @@ -16,6 +16,10 @@ #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 678171c7532771..ed7f64c483e606 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/location.h" +#include "base/message_loop/message_loop.h" +#include "base/message_loop/message_loop_proxy.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::SingleThreadTaskRunner* target_task_runner, +void ForwardCallback(base::MessageLoopProxy* target_loop, const PluginService::GetPluginsCallback& callback, const std::vector& plugins) { - target_task_runner->PostTask(FROM_HERE, base::Bind(callback, plugins)); + target_loop->PostTask(FROM_HERE, base::Bind(callback, plugins)); } } // namespace @@ -589,43 +589,45 @@ base::string16 PluginServiceImpl::GetPluginDisplayNameByPath( } void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) { - scoped_refptr target_task_runner( - base::ThreadTaskRunnerHandle::Get()); + scoped_refptr target_loop( + base::MessageLoop::current()->message_loop_proxy()); 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_task_runner, callback), - base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); + base::Unretained(this), + target_loop, 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_task_runner, callback)); + base::Unretained(this), target_loop, callback)); #else NOTREACHED(); #endif } void PluginServiceImpl::GetPluginsInternal( - base::SingleThreadTaskRunner* target_task_runner, - const PluginService::GetPluginsCallback& callback) { + base::MessageLoopProxy* target_loop, + const PluginService::GetPluginsCallback& callback) { DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( plugin_list_token_)); std::vector plugins; PluginList::Singleton()->GetPlugins(&plugins, NPAPIPluginsSupported()); - target_task_runner->PostTask(FROM_HERE, base::Bind(callback, plugins)); + target_loop->PostTask(FROM_HERE, + base::Bind(callback, plugins)); } #if defined(OS_POSIX) void PluginServiceImpl::GetPluginsOnIOThread( - base::SingleThreadTaskRunner* target_task_runner, + base::MessageLoopProxy* target_loop, const GetPluginsCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -635,8 +637,8 @@ void PluginServiceImpl::GetPluginsOnIOThread( if (!plugin_loader_.get()) plugin_loader_ = new PluginLoaderPosix; - plugin_loader_->GetPlugins(base::Bind( - &ForwardCallback, make_scoped_refptr(target_task_runner), callback)); + plugin_loader_->GetPlugins( + base::Bind(&ForwardCallback, make_scoped_refptr(target_loop), callback)); } #endif diff --git a/content/browser/plugin_service_impl.h b/content/browser/plugin_service_impl.h index 19fefba66415dd..2e107a6d40a679 100644 --- a/content/browser/plugin_service_impl.h +++ b/content/browser/plugin_service_impl.h @@ -42,7 +42,7 @@ #endif namespace base { -class SingleThreadTaskRunner; +class MessageLoopProxy; } namespace content { @@ -181,12 +181,13 @@ class CONTENT_EXPORT PluginServiceImpl void RegisterPepperPlugins(); // Run on the blocking pool to load the plugins synchronously. - void GetPluginsInternal(base::SingleThreadTaskRunner* target_task_runner, + void GetPluginsInternal(base::MessageLoopProxy* target_loop, const GetPluginsCallback& callback); #if defined(OS_POSIX) - void GetPluginsOnIOThread(base::SingleThreadTaskRunner* target_task_runner, - const GetPluginsCallback& callback); + void GetPluginsOnIOThread( + base::MessageLoopProxy* target_loop, + 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 9c1e9f172fdb4d..e60516e67e01e8 100644 --- a/content/browser/plugin_service_impl_browsertest.cc +++ b/content/browser/plugin_service_impl_browsertest.cc @@ -7,10 +7,7 @@ #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" @@ -264,10 +261,12 @@ 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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&PluginProcessHost::CancelPendingRequest, - base::Unretained(host), this)); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&PluginProcessHost::CancelPendingRequest, + base::Unretained(host), + this)); + base::MessageLoop::current()->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 96e96d14ac66e5..3386b6f618c2e4 100644 --- a/content/browser/power_profiler/power_profiler_service_unittest.cc +++ b/content/browser/power_profiler/power_profiler_service_unittest.cc @@ -2,6 +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/run_loop.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/power_profiler/power_profiler_service.h" @@ -89,7 +90,8 @@ class PowerProfilerServiceTest : public testing::Test { service_.reset(new PowerProfilerService( make_scoped_ptr( new TestPowerDataProvider(kNumEvents)), - message_loop_.task_runner(), base::TimeDelta::FromMilliseconds(1))); + message_loop_.message_loop_proxy(), + 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 4ffe2e6b0eb722..bc20e025b8be00 100644 --- a/content/browser/power_save_blocker_x11.cc +++ b/content/browser/power_save_blocker_x11.cc @@ -21,6 +21,7 @@ #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 81a2dba6ef451d..677418fd90a10e 100644 --- a/content/browser/presentation/presentation_service_impl_unittest.cc +++ b/content/browser/presentation/presentation_service_impl_unittest.cc @@ -2,12 +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/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" @@ -176,7 +174,7 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness { void RunLoopFor(base::TimeDelta duration) { base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + base::MessageLoop::current()->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 47bc304537e4e8..4884d0d7dfe164 100644 --- a/content/browser/quota/mock_quota_manager.cc +++ b/content/browser/quota/mock_quota_manager.cc @@ -4,11 +4,10 @@ #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; @@ -94,10 +93,13 @@ void MockQuotaManager::GetOriginsModifiedSince( origins_to_return->insert(current->origin); } - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&MockQuotaManager::DidGetModifiedSince, - weak_factory_.GetWeakPtr(), callback, - base::Owned(origins_to_return), type)); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&MockQuotaManager::DidGetModifiedSince, + weak_factory_.GetWeakPtr(), + callback, + base::Owned(origins_to_return), + type)); } void MockQuotaManager::DeleteOriginData( @@ -117,10 +119,12 @@ void MockQuotaManager::DeleteOriginData( } } - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 e5e170cb998273..706ca821972431 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,9 +45,10 @@ 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::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), + manager_ = new MockQuotaManager(false /* is_incognito */, + data_dir_.path(), + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().get(), policy_.get()); } diff --git a/content/browser/quota/quota_backend_impl_unittest.cc b/content/browser/quota/quota_backend_impl_unittest.cc index 6139e8a0075a7d..2cf9f175774a24 100644 --- a/content/browser/quota/quota_backend_impl_unittest.cc +++ b/content/browser/quota/quota_backend_impl_unittest.cc @@ -7,7 +7,7 @@ #include #include "base/files/scoped_temp_dir.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.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::ThreadTaskRunnerHandle::Get().get(); + return base::MessageLoopProxy::current().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 39c2315689fa99..1337bc389f47b0 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,6 +25,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" +using base::MessageLoopProxy; using storage::kQuotaErrorAbort; using storage::kQuotaErrorInvalidModification; using storage::kQuotaErrorNotSupported; @@ -91,9 +92,10 @@ class QuotaManagerTest : public testing::Test { protected: void ResetQuotaManager(bool is_incognito) { - quota_manager_ = new QuotaManager(is_incognito, data_dir_.path(), - base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), + quota_manager_ = new QuotaManager(is_incognito, + data_dir_.path(), + MessageLoopProxy::current().get(), + MessageLoopProxy::current().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 05fff80b609c66..61de3d574e87ab 100644 --- a/content/browser/quota/quota_reservation_manager_unittest.cc +++ b/content/browser/quota/quota_reservation_manager_unittest.cc @@ -9,10 +9,8 @@ #include "base/files/file.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/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" @@ -58,7 +56,7 @@ class FakeBackend : public QuotaReservationManager::QuotaBackend { EXPECT_EQ(GURL(kOrigin), origin); EXPECT_EQ(kType, type); on_memory_usage_ += delta; - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoopProxy::current()->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 ba414fc333d733..6c00c0f877f9d6 100644 --- a/content/browser/quota/quota_temporary_storage_evictor_unittest.cc +++ b/content/browser/quota/quota_temporary_storage_evictor_unittest.cc @@ -10,6 +10,7 @@ #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 0edd49eb60dada..78599de7472537 100644 --- a/content/browser/quota/storage_monitor_unittest.cc +++ b/content/browser/quota/storage_monitor_unittest.cc @@ -5,8 +5,9 @@ #include #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" @@ -62,15 +63,17 @@ class MockObserver : public StorageObserver { class UsageMockQuotaManager : public QuotaManager { public: UsageMockQuotaManager(SpecialStoragePolicy* special_storage_policy) - : QuotaManager(false, - base::FilePath(), - base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), - special_storage_policy), + : QuotaManager( + false, + base::FilePath(), + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().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; @@ -646,8 +649,11 @@ class StorageMonitorIntegrationTest : public testing::Test { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); storage_policy_ = new MockSpecialStoragePolicy(); quota_manager_ = new QuotaManager( - false, data_dir_.path(), base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), storage_policy_.get()); + false, + data_dir_.path(), + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().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 3cfdf2cb1031e4..786146ab7d5715 100644 --- a/content/browser/quota/usage_tracker_unittest.cc +++ b/content/browser/quota/usage_tracker_unittest.cc @@ -3,10 +3,7 @@ // 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" @@ -59,8 +56,8 @@ class MockQuotaClient : public QuotaClient { const GetUsageCallback& callback) override { EXPECT_EQ(kStorageTypeTemporary, type); int64 usage = GetUsage(origin); - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(callback, usage)); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(callback, usage)); } void GetOriginsForType(StorageType type, @@ -71,8 +68,8 @@ class MockQuotaClient : public QuotaClient { itr != usage_map_.end(); ++itr) { origins.insert(itr->first); } - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(callback, origins)); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(callback, origins)); } void GetOriginsForHost(StorageType type, @@ -85,8 +82,8 @@ class MockQuotaClient : public QuotaClient { if (net::GetHostOrSpecFromURL(itr->first) == host) origins.insert(itr->first); } - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(callback, origins)); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(callback, origins)); } void DeleteOriginData(const GURL& origin, @@ -94,7 +91,7 @@ class MockQuotaClient : public QuotaClient { const DeletionCallback& callback) override { EXPECT_EQ(kStorageTypeTemporary, type); usage_map_.erase(origin); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 4a120522049c0c..ce153f53386b2f 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::ThreadTaskRunnerHandle::Get(); + main_thread_ = base::MessageLoopProxy::current(); } void SwapBuffers(cc::CompositorFrame* frame) override { @@ -130,7 +130,7 @@ class OutputSurfaceWithoutParent : public cc::OutputSurface { gfx::SwapResult)> swap_buffers_completion_callback_; - scoped_refptr main_thread_; + scoped_refptr main_thread_; base::WeakPtr 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::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + base::MessageLoop::current()->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::ThreadTaskRunnerHandle::Get())); + base::MessageLoopProxy::current())); scoped_ptr 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 7e7a6ead4988a6..3e57cd0353108d 100644 --- a/content/browser/renderer_host/input/gesture_event_queue_unittest.cc +++ b/content/browser/renderer_host/input/gesture_event_queue_unittest.cc @@ -5,12 +5,9 @@ #include #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" @@ -1086,8 +1083,9 @@ TEST_F(GestureEventQueueTest, DebounceDefersFollowingGestureEvents) { EXPECT_EQ(2U, GestureEventQueueSize()); EXPECT_EQ(3U, GestureEventDebouncingQueueSize()); - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::MessageLoop::QuitClosure(), + base::MessageLoop::current()->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 4f2e6bbe81edf7..918c260b57e8d2 100644 --- a/content/browser/renderer_host/input/input_router_impl_unittest.cc +++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc @@ -6,11 +6,8 @@ #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" @@ -329,7 +326,7 @@ class InputRouterImplTest : public testing::Test { } static void RunTasksAndWait(base::TimeDelta delay) { - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + base::MessageLoop::current()->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 f46fe507207fbd..2467cde3fb9116 100644 --- a/content/browser/renderer_host/input/touch_event_queue_unittest.cc +++ b/content/browser/renderer_host/input/touch_event_queue_unittest.cc @@ -3,12 +3,9 @@ // 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" @@ -285,7 +282,7 @@ class TouchEventQueueTest : public testing::Test, } static void RunTasksAndWait(base::TimeDelta delay) { - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + base::MessageLoop::current()->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 9c9bcefdb44a91..b6d5f991b3a998 100644 --- a/content/browser/renderer_host/input/touch_input_browsertest.cc +++ b/content/browser/renderer_host/input/touch_input_browsertest.cc @@ -4,10 +4,7 @@ #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" @@ -30,8 +27,10 @@ namespace { void GiveItSomeTime() { base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromMilliseconds(10)); + base::MessageLoop::current()->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 498806b7d8bc11..f6a5fb2fadefdd 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,10 +5,9 @@ #include #include "base/bind.h" -#include "base/location.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.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" @@ -72,7 +71,7 @@ class MAYBE_AudioInputDeviceManagerTest : public testing::Test { manager_->UseFakeDevice(); audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); manager_->Register(audio_input_listener_.get(), - message_loop_->task_runner().get()); + message_loop_->message_loop_proxy().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 19fb35ebfb49d2..848f78c49c8c76 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,16 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include #include +#include #include "base/bind.h" #include "base/callback_helpers.h" #include "base/command_line.h" -#include "base/location.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/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" @@ -57,10 +55,10 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, public: MockMediaStreamDispatcherHost( const ResourceContext::SaltCallback salt_callback, - const scoped_refptr& task_runner, + const scoped_refptr& message_loop, MediaStreamManager* manager) : MediaStreamDispatcherHost(kProcessId, salt_callback, manager), - task_runner_(task_runner), + message_loop_(message_loop), current_ipc_(NULL) {} // A list of mock methods. @@ -157,7 +155,7 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, // Notify that the event have occurred. base::Closure quit_closure = quit_closures_.front(); quit_closures_.pop(); - task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); + message_loop_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); label_ = label; audio_devices_ = audio_device_list; @@ -171,7 +169,7 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, if (!quit_closures_.empty()) { base::Closure quit_closure = quit_closures_.front(); quit_closures_.pop(); - task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); + message_loop_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); } label_= ""; @@ -192,7 +190,7 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, const StreamDeviceInfo& device) { base::Closure quit_closure = quit_closures_.front(); quit_closures_.pop(); - task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); + message_loop_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); label_ = label; opened_device_ = device; } @@ -201,11 +199,11 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost, const StreamDeviceInfoArray& devices) { base::Closure quit_closure = quit_closures_.front(); quit_closures_.pop(); - task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); + message_loop_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); enumerated_devices_ = devices; } - scoped_refptr task_runner_; + scoped_refptr message_loop_; IPC::Message* current_ipc_; std::queue quit_closures_; }; @@ -225,7 +223,7 @@ class MediaStreamDispatcherHostTest : public testing::Test { thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), origin_("https://test.com") { audio_manager_.reset( - new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())); + new media::MockAudioManager(base::MessageLoopProxy::current())); // Make sure we use fake devices to avoid long delays. base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kUseFakeDeviceForMediaStream); @@ -239,7 +237,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::ThreadTaskRunnerHandle::Get()); + base::MessageLoopProxy::current()); #endif MockResourceContext* mock_resource_context = @@ -248,7 +246,8 @@ class MediaStreamDispatcherHostTest : public testing::Test { host_ = new MockMediaStreamDispatcherHost( mock_resource_context->GetMediaDeviceIDSalt(), - base::ThreadTaskRunnerHandle::Get(), media_stream_manager_.get()); + base::MessageLoopProxy::current(), + 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 9c7ac2b45cfabe..1ae9fe52e5ea6f 100644 --- a/content/browser/renderer_host/media/media_stream_manager.cc +++ b/content/browser/renderer_host/media/media_stream_manager.cc @@ -1670,7 +1670,8 @@ 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_.task_runner()); + video_capture_manager_->Register(this, + video_capture_thread_.message_loop_proxy()); #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 fc0028c0a7669f..51ab0a52bfb12a 100644 --- a/content/browser/renderer_host/media/media_stream_manager_unittest.cc +++ b/content/browser/renderer_host/media/media_stream_manager_unittest.cc @@ -6,10 +6,8 @@ #include "base/bind.h" #include "base/command_line.h" -#include "base/location.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/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" @@ -79,7 +77,7 @@ class MediaStreamManagerTest : public ::testing::Test { public: MediaStreamManagerTest() : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), - task_runner_(base::ThreadTaskRunnerHandle::Get()) { + message_loop_(base::MessageLoopProxy::current()) { // Create our own MediaStreamManager. Use fake devices to run on the bots. base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kUseFakeDeviceForMediaStream); @@ -95,7 +93,7 @@ class MediaStreamManagerTest : public ::testing::Test { const MediaStreamDevices& devices, scoped_ptr ui_proxy) { Response(index); - task_runner_->PostTask(FROM_HERE, run_loop_.QuitClosure()); + message_loop_->PostTask(FROM_HERE, run_loop_.QuitClosure()); } protected: @@ -119,7 +117,7 @@ class MediaStreamManagerTest : public ::testing::Test { scoped_ptr audio_manager_; scoped_ptr media_stream_manager_; content::TestBrowserThreadBundle thread_bundle_; - scoped_refptr task_runner_; + scoped_refptr message_loop_; 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 d27fac393e88fd..70cef133f393e8 100644 --- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc +++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc @@ -8,11 +8,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/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" @@ -74,10 +73,14 @@ class MockVideoCaptureControllerEventHandler const base::TimeTicks& timestamp, scoped_ptr metadata) override { DoBufferReady(id, coded_size); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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, @@ -87,16 +90,19 @@ class MockVideoCaptureControllerEventHandler const base::TimeTicks& timestamp, scoped_ptr metadata) override { DoMailboxBufferReady(id); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&VideoCaptureController::ReturnBuffer, - base::Unretained(controller_), id, this, - buffer_id, mailbox_holder.sync_point)); + base::MessageLoop::current()->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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, + base::MessageLoop::current()->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 878ea584276743..763ed1f9ca83ed 100644 --- a/content/browser/renderer_host/media/video_capture_host_unittest.cc +++ b/content/browser/renderer_host/media/video_capture_host_unittest.cc @@ -9,13 +9,11 @@ #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" @@ -274,8 +272,8 @@ class MockVideoCaptureHost : public VideoCaptureHost { DumpVideo dumper_; }; -ACTION_P2(ExitMessageLoop, task_runner, quit_closure) { - task_runner->PostTask(FROM_HERE, quit_closure); +ACTION_P2(ExitMessageLoop, message_loop, quit_closure) { + message_loop->PostTask(FROM_HERE, quit_closure); } // This is an integration test of VideoCaptureHost in conjunction with @@ -285,7 +283,7 @@ class VideoCaptureHostTest : public testing::Test { public: VideoCaptureHostTest() : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), - task_runner_(base::ThreadTaskRunnerHandle::Get()), + message_loop_(base::MessageLoopProxy::current()), opened_session_id_(kInvalidMediaCaptureSessionId) {} void SetUp() override { @@ -351,11 +349,13 @@ 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(task_runner_, run_loop.QuitClosure()), - SaveArg<3>(&devices))); + 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))); run_loop.Run(); Mock::VerifyAndClearExpectations(&stream_requester_); media_stream_manager_->CancelRequest(label); @@ -376,12 +376,14 @@ 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(task_runner_, 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(message_loop_, 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); @@ -406,7 +408,7 @@ class VideoCaptureHostTest : public testing::Test { base::RunLoop run_loop; EXPECT_CALL(*host_.get(), OnBufferFilled(kDeviceId, _, _, _, _, _)) .Times(AnyNumber()) - .WillOnce(ExitMessageLoop(task_runner_, run_loop.QuitClosure())); + .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure())); media::VideoCaptureParams params; params.requested_format = media::VideoCaptureFormat( @@ -455,7 +457,7 @@ class VideoCaptureHostTest : public testing::Test { base::RunLoop run_loop; EXPECT_CALL(*host_.get(), OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)) - .WillOnce(ExitMessageLoop(task_runner_, run_loop.QuitClosure())); + .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure())); host_->OnStopCapture(kDeviceId); host_->SetReturnReceivedDibs(true); @@ -472,7 +474,7 @@ class VideoCaptureHostTest : public testing::Test { base::RunLoop run_loop; EXPECT_CALL(*host_.get(), OnBufferFilled(kDeviceId, _, _, _, _, _)) .Times(AnyNumber()) - .WillOnce(ExitMessageLoop(task_runner_, run_loop.QuitClosure())) + .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure())) .RetiresOnSaturation(); run_loop.Run(); } @@ -510,7 +512,7 @@ class VideoCaptureHostTest : public testing::Test { content::TestBrowserThreadBundle thread_bundle_; content::TestBrowserContext browser_context_; content::TestContentBrowserClient browser_client_; - scoped_refptr task_runner_; + scoped_refptr message_loop_; 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 2ee839604dab9d..a213a564babffd 100644 --- a/content/browser/renderer_host/media/video_capture_manager.cc +++ b/content/browser/renderer_host/media/video_capture_manager.cc @@ -9,13 +9,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/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" @@ -226,9 +224,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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&VideoCaptureManager::OnOpened, this, - device_info.device.type, capture_session_id)); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(&VideoCaptureManager::OnOpened, this, + device_info.device.type, capture_session_id)); return capture_session_id; } @@ -257,9 +255,9 @@ void VideoCaptureManager::Close(int capture_session_id) { } // Notify listeners asynchronously, and forget the session. - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&VideoCaptureManager::OnClosed, this, - session_it->second.type, capture_session_id)); + base::MessageLoop::current()->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 832b0dc7b52001..a8e45add526ad8 100644 --- a/content/browser/renderer_host/media/video_capture_manager_unittest.cc +++ b/content/browser/renderer_host/media/video_capture_manager_unittest.cc @@ -9,6 +9,7 @@ #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" @@ -87,7 +88,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_->task_runner().get()); + vcm_->Register(listener_.get(), message_loop_->message_loop_proxy().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 dd49bff7b86e9c..a92e3e52df8a7c 100644 --- a/content/browser/renderer_host/p2p/socket_host_tcp.cc +++ b/content/browser/renderer_host/p2p/socket_host_tcp.cc @@ -4,8 +4,6 @@ #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" @@ -119,9 +117,10 @@ 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->task_runner()->PostTask( - FROM_HERE, base::Bind(&P2PSocketHostTcpBase::OnConnected, - base::Unretained(this), status)); + message_loop->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 5d7445b4fded43..6eb6f13b4d1e11 100644 --- a/content/browser/renderer_host/pepper/quota_reservation_unittest.cc +++ b/content/browser/renderer_host/pepper/quota_reservation_unittest.cc @@ -9,10 +9,8 @@ #include "base/files/file.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/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" @@ -42,7 +40,7 @@ class FakeBackend : public QuotaReservationManager::QuotaBackend { storage::FileSystemType type, int64 delta, const QuotaReservationManager::ReserveQuotaCallback& callback) override { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoopProxy::current()->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 d4da1d4bb63765..f32d2bbe518edb 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -19,14 +19,12 @@ #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 74f7ff429f0981..b987fbf3d1d97e 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -14,10 +14,9 @@ #include "base/containers/hash_tables.h" #include "base/i18n/rtl.h" #include "base/lazy_instance.h" -#include "base/location.h" +#include "base/message_loop/message_loop.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" @@ -1535,9 +1534,10 @@ void RenderWidgetHostImpl::OnUpdateRect( bool post_callback = new_auto_size_.IsEmpty(); new_auto_size_ = params.view_size; if (post_callback) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&RenderWidgetHostImpl::DelayedAutoResized, - weak_factory_.GetWeakPtr())); + base::MessageLoop::current()->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 1787f66be29850..fc691c720b85f8 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc @@ -5,11 +5,8 @@ #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" @@ -982,8 +979,9 @@ TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) { host_->StartHangMonitorTimeout(TimeDelta::FromSeconds(30)); // Wait long enough for first timeout and see if it fired. - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::MessageLoop::QuitClosure(), + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); base::MessageLoop::current()->Run(); EXPECT_TRUE(host_->unresponsive_timer_fired()); @@ -1001,8 +999,9 @@ TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) { host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); // Wait long enough for first timeout and see if it fired. - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::MessageLoop::QuitClosure(), + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); base::MessageLoop::current()->Run(); EXPECT_TRUE(host_->unresponsive_timer_fired()); @@ -1019,8 +1018,9 @@ TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) { host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(20)); // Wait long enough for the second timeout and see if it fired. - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::MessageLoop::QuitClosure(), + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(25)); base::MessageLoop::current()->Run(); EXPECT_TRUE(host_->unresponsive_timer_fired()); @@ -1037,16 +1037,18 @@ TEST_F(RenderWidgetHostTest, HangMonitorTimeoutDisabledForInputWhenHidden) { // The timeout should not fire. EXPECT_FALSE(host_->unresponsive_timer_fired()); - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::MessageLoop::QuitClosure(), + base::MessageLoop::current()->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::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::MessageLoop::QuitClosure(), + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::MessageLoop::QuitClosure(), TimeDelta::FromMicroseconds(2)); base::MessageLoop::current()->Run(); EXPECT_FALSE(host_->unresponsive_timer_fired()); @@ -1054,8 +1056,9 @@ 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::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::MessageLoop::QuitClosure(), + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::MessageLoop::QuitClosure(), TimeDelta::FromMicroseconds(2)); base::MessageLoop::current()->Run(); EXPECT_TRUE(host_->unresponsive_timer_fired()); @@ -1076,8 +1079,9 @@ TEST_F(RenderWidgetHostTest, MultipleInputEvents) { INPUT_EVENT_ACK_STATE_CONSUMED); // Wait long enough for first timeout and see if it fired. - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::MessageLoop::QuitClosure(), + base::MessageLoop::current()->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 464b9157e3c350..7e6794a2a83373 100644 --- a/content/browser/renderer_host/render_widget_host_view_browsertest.cc +++ b/content/browser/renderer_host/render_widget_host_view_browsertest.cc @@ -4,11 +4,9 @@ #include "base/barrier_closure.h" #include "base/command_line.h" -#include "base/location.h" +#include "base/message_loop/message_loop_proxy.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" @@ -131,16 +129,15 @@ class RenderWidgetHostViewBrowserTest : public ContentBrowserTest { } // Callback when using frame subscriber API. - void FrameDelivered( - const scoped_refptr& task_runner, - base::Closure quit_closure, - base::TimeTicks timestamp, - bool frame_captured) { + void FrameDelivered(const scoped_refptr& loop, + base::Closure quit_closure, + base::TimeTicks timestamp, + bool frame_captured) { ++callback_invoke_count_; if (frame_captured) ++frames_captured_; if (!quit_closure.is_null()) - task_runner->PostTask(FROM_HERE, quit_closure); + loop->PostTask(FROM_HERE, quit_closure); } // Copy one frame using the CopyFromBackingStore API. @@ -185,8 +182,9 @@ class RenderWidgetHostViewBrowserTest : public ContentBrowserTest { // call stack. static void GiveItSomeTime() { base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, run_loop.QuitClosure(), + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + run_loop.QuitClosure(), base::TimeDelta::FromMilliseconds(10)); run_loop.Run(); } @@ -341,10 +339,11 @@ IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTest, base::RunLoop run_loop; scoped_ptr subscriber( - new FakeFrameSubscriber(base::Bind( - &RenderWidgetHostViewBrowserTest::FrameDelivered, - base::Unretained(this), base::ThreadTaskRunnerHandle::Get(), - run_loop.QuitClosure()))); + new FakeFrameSubscriber( + base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, + base::Unretained(this), + base::MessageLoopProxy::current(), + run_loop.QuitClosure()))); view->BeginFrameSubscription(subscriber.Pass()); run_loop.Run(); view->EndFrameSubscription(); @@ -374,12 +373,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::ThreadTaskRunnerHandle::Get(), + base::Unretained(this), base::MessageLoopProxy::current(), closure, base::TimeTicks::Now())); view->CopyFromCompositingSurfaceToVideoFrame( gfx::Rect(view->GetViewBounds().size()), second_output, base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, - base::Unretained(this), base::ThreadTaskRunnerHandle::Get(), + base::Unretained(this), base::MessageLoopProxy::current(), 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 801cee06e975a8..cd8dd25a9978ad 100644 --- a/content/browser/renderer_host/websocket_host.cc +++ b/content/browser/renderer_host/websocket_host.cc @@ -5,11 +5,8 @@ #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" @@ -358,10 +355,14 @@ void WebSocketHost::OnAddChannelRequest( DCHECK(!channel_); if (delay_ > base::TimeDelta()) { - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + base::MessageLoop::current()->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); @@ -393,10 +394,11 @@ 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::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&WebSocketHost::OnFlowControl, - weak_ptr_factory_.GetWeakPtr(), - pending_flow_control_quota_)); + base::MessageLoop::current()->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 fef7bcdc0faefc..a76f774486aa24 100644 --- a/content/browser/service_worker/service_worker_context_core.cc +++ b/content/browser/service_worker/service_worker_context_core.cc @@ -8,10 +8,8 @@ #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" @@ -448,7 +446,7 @@ int ServiceWorkerContextCore::GetNewRegistrationHandleId() { void ServiceWorkerContextCore::ScheduleDeleteAndStartOver() const { storage_->Disable(); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 264c9ce5a91c00..d4a189ce21fe01 100644 --- a/content/browser/service_worker/service_worker_context_wrapper.cc +++ b/content/browser/service_worker/service_worker_context_wrapper.cc @@ -13,11 +13,8 @@ #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" @@ -44,7 +41,7 @@ base::LazyInstance g_excluded_header_name_set = LAZY_INSTANCE_INITIALIZER; void RunSoon(const base::Closure& closure) { - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); + base::MessageLoop::current()->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 c4f7754fcfa406..6ab1db63c53c4e 100644 --- a/content/browser/service_worker/service_worker_register_job.cc +++ b/content/browser/service_worker/service_worker_register_job.cc @@ -6,9 +6,7 @@ #include -#include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.h" #include "content/browser/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" @@ -23,7 +21,7 @@ namespace content { namespace { void RunSoon(const base::Closure& closure) { - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); + base::MessageLoop::current()->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 0123a2e05ac26d..2db0cfb6ccc4ac 100644 --- a/content/browser/service_worker/service_worker_url_request_job.cc +++ b/content/browser/service_worker/service_worker_url_request_job.cc @@ -10,11 +10,8 @@ #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" @@ -323,9 +320,10 @@ ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() { void ServiceWorkerURLRequestJob::MaybeStartRequest() { if (is_started_ && response_type_ != NOT_DETERMINED) { // Start asynchronously. - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ServiceWorkerURLRequestJob::StartRequest, - weak_factory_.GetWeakPtr())); + base::MessageLoop::current()->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 2d709d04f91ee4..9e8462ae726009 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 task runner are not actually used but a - // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. + // The FileSystemContext and MessageLoopProxy are not actually used but a + // MessageLoopProxy 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 9bca8eed56b807..9964b8a46697cf 100644 --- a/content/browser/service_worker/service_worker_version.cc +++ b/content/browser/service_worker/service_worker_version.cc @@ -5,14 +5,11 @@ #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" @@ -75,7 +72,7 @@ const char kClaimClientsShutdownErrorMesage[] = void RunSoon(const base::Closure& callback) { if (!callback.is_null()) - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); + base::MessageLoop::current()->PostTask(FROM_HERE, callback); } template 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 7f6aabc69edbfd..5fc56c4c48fbfd 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,10 +2,7 @@ // 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" @@ -98,9 +95,10 @@ class SSLCertificateErrorJob : public net::URLRequestTestJob { auto_advance), weak_factory_(this) {} void Start() override { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&SSLCertificateErrorJob::NotifyError, - weak_factory_.GetWeakPtr())); + base::MessageLoop::current()->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 c2dae30fdfcd55..84d035fd43ddd2 100644 --- a/content/browser/shareable_file_reference_unittest.cc +++ b/content/browser/shareable_file_reference_unittest.cc @@ -6,9 +6,8 @@ #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; @@ -17,8 +16,8 @@ namespace content { TEST(ShareableFileReferenceTest, TestReferences) { base::MessageLoop message_loop; - scoped_refptr task_runner = - base::ThreadTaskRunnerHandle::Get(); + scoped_refptr loop_proxy = + base::MessageLoopProxy::current(); base::ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); @@ -32,7 +31,7 @@ TEST(ShareableFileReferenceTest, TestReferences) { reference1 = ShareableFileReference::Get(file); EXPECT_FALSE(reference1.get()); reference1 = ShareableFileReference::GetOrCreate( - file, ShareableFileReference::DELETE_ON_FINAL_RELEASE, task_runner.get()); + file, ShareableFileReference::DELETE_ON_FINAL_RELEASE, loop_proxy.get()); EXPECT_TRUE(reference1.get()); EXPECT_TRUE(file == reference1->path()); @@ -41,7 +40,7 @@ TEST(ShareableFileReferenceTest, TestReferences) { reference2 = ShareableFileReference::Get(file); EXPECT_EQ(reference1.get(), reference2.get()); reference2 = ShareableFileReference::GetOrCreate( - file, ShareableFileReference::DELETE_ON_FINAL_RELEASE, task_runner.get()); + file, ShareableFileReference::DELETE_ON_FINAL_RELEASE, loop_proxy.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 d266e7b04998ea..282141a49c65f7 100644 --- a/content/browser/site_per_process_browsertest.cc +++ b/content/browser/site_per_process_browsertest.cc @@ -8,11 +8,8 @@ #include #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" @@ -434,7 +431,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::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + base::MessageLoop::current()->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 ee5e28e83ffa6b..8bc0749f40e0cb 100644 --- a/content/browser/speech/speech_recognition_browsertest.cc +++ b/content/browser/speech/speech_recognition_browsertest.cc @@ -5,12 +5,9 @@ #include #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" @@ -169,11 +166,11 @@ class SpeechRecognitionBrowserTest : const int n_buffers = duration_ms / ms_per_buffer; for (int i = 0; i < n_buffers; ++i) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::Bind(&FeedSingleBufferToAudioController, - scoped_refptr(controller), - buffer_size, feed_with_noise)); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( + &FeedSingleBufferToAudioController, + scoped_refptr(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 019abe1a8d33d3..f02c29f1dd41ee 100644 --- a/content/browser/speech/speech_recognition_manager_impl.cc +++ b/content/browser/speech/speech_recognition_manager_impl.cc @@ -5,9 +5,6 @@ #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" @@ -213,17 +210,21 @@ void SpeechRecognitionManagerImpl::RecognitionAllowedCallback(int session_id, } if (is_allowed) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, - weak_factory_.GetWeakPtr(), session_id, EVENT_ABORT)); + weak_factory_.GetWeakPtr(), + session_id, + EVENT_ABORT)); } } @@ -266,10 +267,12 @@ void SpeechRecognitionManagerImpl::AbortSession(int session_id) { iter->second->abort_requested = true; - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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) { @@ -280,10 +283,12 @@ void SpeechRecognitionManagerImpl::StopAudioCaptureForSession(int session_id) { SessionsTable::iterator iter = sessions_.find(session_id); iter->second->ui.reset(); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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, @@ -367,10 +372,12 @@ void SpeechRecognitionManagerImpl::OnAudioEnd(int session_id) { delegate_listener->OnAudioEnd(session_id); if (SpeechRecognitionEventListener* listener = GetListener(session_id)) listener->OnAudioEnd(session_id); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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( @@ -418,10 +425,12 @@ void SpeechRecognitionManagerImpl::OnRecognitionEnd(int session_id) { delegate_listener->OnRecognitionEnd(session_id); if (SpeechRecognitionEventListener* listener = GetListener(session_id)) listener->OnRecognitionEnd(session_id); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent, - weak_factory_.GetWeakPtr(), session_id, - EVENT_RECOGNITION_ENDED)); + base::MessageLoop::current()->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 320ca8130ac99e..ba6b06ab50f4d6 100644 --- a/content/browser/speech/speech_recognizer_impl_unittest.cc +++ b/content/browser/speech/speech_recognizer_impl_unittest.cc @@ -19,6 +19,7 @@ #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; @@ -57,7 +58,7 @@ class SpeechRecognizerImplTest : public SpeechRecognitionEventListener, recognizer_ = new SpeechRecognizerImpl( this, kTestingSessionId, false, false, sr_engine); audio_manager_.reset(new media::MockAudioManager( - base::MessageLoop::current()->task_runner().get())); + base::MessageLoop::current()->message_loop_proxy().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 ceb2d235992dfa..0545c3ab29acfd 100644 --- a/content/browser/storage_partition_impl.cc +++ b/content/browser/storage_partition_impl.cc @@ -7,9 +7,7 @@ #include #include -#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" @@ -486,10 +484,8 @@ StoragePartitionImpl* StoragePartitionImpl::Create( base::SequencedTaskRunner* idb_task_runner = BrowserThread::CurrentlyOn(BrowserThread::UI) && BrowserMainLoop::GetInstance() - ? BrowserMainLoop::GetInstance() - ->indexed_db_thread() - ->task_runner() - .get() + ? BrowserMainLoop::GetInstance()->indexed_db_thread() + ->message_loop_proxy().get() : NULL; scoped_refptr 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 8b99d0428c766d..7ba28d7c664ec4 100644 --- a/content/browser/storage_partition_impl_map.cc +++ b/content/browser/storage_partition_impl_map.cc @@ -9,13 +9,10 @@ #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" @@ -524,7 +521,7 @@ void StoragePartitionImplMap::AsyncObliterate( FROM_HERE, base::Bind(&BlockingObliteratePath, browser_context_->GetPath(), domain_root, paths_to_keep, - base::ThreadTaskRunnerHandle::Get(), on_gc_required)); + base::MessageLoopProxy::current(), 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 79e33beb2500a0..a2950c850aaf2d 100644 --- a/content/browser/storage_partition_impl_unittest.cc +++ b/content/browser/storage_partition_impl_unittest.cc @@ -3,10 +3,8 @@ // found in the LICENSE file. #include "base/files/file_util.h" -#include "base/location.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 "base/threading/thread.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/gpu/shader_disk_cache.h" @@ -405,11 +403,11 @@ TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) { EXPECT_EQ(1u, Size()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::Bind(&ClearData, - BrowserContext::GetDefaultStoragePartition(browser_context()), - &run_loop)); + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind( + &ClearData, + BrowserContext::GetDefaultStoragePartition(browser_context()), + &run_loop)); run_loop.Run(); EXPECT_EQ(0u, Size()); } @@ -477,7 +475,7 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverBoth) { GetMockManager()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); run_loop.Run(); @@ -504,7 +502,7 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyTemporary) { GetMockManager()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); run_loop.Run(); @@ -531,7 +529,7 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyPersistent) { GetMockManager()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); run_loop.Run(); @@ -556,7 +554,7 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverNeither) { GetMockManager()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); run_loop.Run(); @@ -583,9 +581,10 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverSpecificOrigin) { GetMockManager()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ClearQuotaDataForOrigin, partition, kOrigin1, - base::Time(), &run_loop)); + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&ClearQuotaDataForOrigin, + partition, kOrigin1, base::Time(), + &run_loop)); run_loop.Run(); EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, @@ -611,10 +610,11 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastHour) { GetMockManager()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::Bind(&ClearQuotaDataForOrigin, partition, GURL(), - base::Time::Now() - base::TimeDelta::FromHours(1), &run_loop)); + base::MessageLoop::current()->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,10 +639,11 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastWeek) { BrowserContext::GetDefaultStoragePartition(browser_context())); partition->OverrideQuotaManagerForTesting( GetMockManager()); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::Bind(&ClearQuotaDataForNonPersistent, partition, - base::Time::Now() - base::TimeDelta::FromDays(7), &run_loop)); + base::MessageLoop::current()->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, @@ -674,8 +675,9 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedUnprotectedOrigins) { partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, partition, GURL(), + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, + partition, GURL(), base::Bind(&DoesOriginMatchForUnprotectedWeb), base::Time(), &run_loop)); run_loop.Run(); @@ -710,11 +712,11 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedProtectedSpecificOrigin) { // Try to remove kOrigin1. Expect failure. base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::Bind(&ClearQuotaDataWithOriginMatcher, partition, kOrigin1, - base::Bind(&DoesOriginMatchForUnprotectedWeb), base::Time(), - &run_loop)); + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, + partition, kOrigin1, + base::Bind(&DoesOriginMatchForUnprotectedWeb), + base::Time(), &run_loop)); run_loop.Run(); EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, @@ -746,9 +748,10 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedProtectedOrigins) { partition->OverrideQuotaManagerForTesting( GetMockManager()); partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, - base::Bind(&ClearQuotaDataWithOriginMatcher, partition, GURL(), + base::Bind(&ClearQuotaDataWithOriginMatcher, + partition, GURL(), base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), base::Time(), &run_loop)); run_loop.Run(); @@ -775,8 +778,9 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedIgnoreDevTools) { BrowserContext::GetDefaultStoragePartition(browser_context())); partition->OverrideQuotaManagerForTesting( GetMockManager()); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, partition, GURL(), + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, + partition, GURL(), base::Bind(&DoesOriginMatchUnprotected), base::Time(), &run_loop)); run_loop.Run(); @@ -799,9 +803,10 @@ TEST_F(StoragePartitionImplTest, RemoveCookieForever) { partition->SetURLRequestContext(browser_context()->GetRequestContext()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ClearCookies, partition, base::Time(), - base::Time::Max(), &run_loop)); + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&ClearCookies, + partition, base::Time(), base::Time::Max(), + &run_loop)); run_loop.Run(); EXPECT_FALSE(tester.ContainsCookie()); @@ -819,9 +824,10 @@ TEST_F(StoragePartitionImplTest, RemoveCookieLastHour) { partition->SetURLRequestContext(browser_context()->GetRequestContext()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ClearCookies, partition, an_hour_ago, - base::Time::Max(), &run_loop)); + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&ClearCookies, + partition, an_hour_ago, base::Time::Max(), + &run_loop)); run_loop.Run(); EXPECT_FALSE(tester.ContainsCookie()); @@ -845,12 +851,13 @@ TEST_F(StoragePartitionImplTest, RemoveUnprotectedLocalStorageForever) { partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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)); @@ -876,7 +883,7 @@ TEST_F(StoragePartitionImplTest, RemoveProtectedLocalStorageForever) { partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ClearStuff, StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, @@ -905,7 +912,7 @@ TEST_F(StoragePartitionImplTest, RemoveLocalStorageForLastWeek) { base::Time a_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7); base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 3f4ae68083eb34..fb36ad9057a2e0 100644 --- a/content/browser/streams/stream.cc +++ b/content/browser/streams/stream.cc @@ -6,8 +6,7 @@ #include "base/bind.h" #include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop_proxy.h" #include "base/values.h" #include "content/browser/streams/stream_handle_impl.h" #include "content/browser/streams/stream_read_observer.h" @@ -36,9 +35,11 @@ Stream::Stream(StreamRegistry* registry, write_observer_(write_observer), stream_handle_(NULL), weak_ptr_factory_(this) { - CreateByteStream(base::ThreadTaskRunnerHandle::Get(), - base::ThreadTaskRunnerHandle::Get(), kDeferSizeThreshold, - &writer_, &reader_); + CreateByteStream(base::MessageLoopProxy::current(), + base::MessageLoopProxy::current(), + kDeferSizeThreshold, + &writer_, + &reader_); // Setup callback for writing. writer_->RegisterCallback(base::Bind(&Stream::OnSpaceAvailable, @@ -121,7 +122,7 @@ void Stream::Finalize() { writer_.reset(); // Continue asynchronously. - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoopProxy::current()->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 ba4dee2a490094..5bc2acbf4fa8f9 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/thread_task_runner_handle.h" +#include "base/message_loop/message_loop_proxy.h" #include "content/browser/streams/stream.h" namespace content { @@ -23,12 +23,11 @@ void RunCloseListeners(const std::vector& close_listeners) { StreamHandleImpl::StreamHandleImpl(const base::WeakPtr& stream) : stream_(stream), url_(stream->url()), - stream_task_runner_(base::ThreadTaskRunnerHandle::Get().get()) { -} + stream_message_loop_(base::MessageLoopProxy::current().get()) {} StreamHandleImpl::~StreamHandleImpl() { - stream_task_runner_->PostTaskAndReply( - FROM_HERE, base::Bind(&Stream::CloseHandle, stream_), + stream_message_loop_->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 15e8e20e42ac49..d2bd94def8e993 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 SingleThreadTaskRunner; +class MessageLoopProxy; } namespace content { @@ -30,7 +30,7 @@ class StreamHandleImpl : public StreamHandle { base::WeakPtr stream_; GURL url_; - base::SingleThreadTaskRunner* stream_task_runner_; + base::MessageLoopProxy* stream_message_loop_; std::vector close_listeners_; }; diff --git a/content/browser/streams/stream_url_request_job.cc b/content/browser/streams/stream_url_request_job.cc index d2bce89aca6834..3d4ac7f77f0476 100644 --- a/content/browser/streams/stream_url_request_job.cc +++ b/content/browser/streams/stream_url_request_job.cc @@ -4,10 +4,7 @@ #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" @@ -83,7 +80,7 @@ void StreamURLRequestJob::OnDataAvailable(Stream* stream) { // net::URLRequestJob methods. void StreamURLRequestJob::Start() { // Continue asynchronously. - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->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 76004b4269f49a..4ab69e9dc33c58 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -8,17 +8,14 @@ #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" @@ -3807,9 +3804,10 @@ void WebContentsImpl::DidChangeLoadProgress() { if (loading_weak_factory_.HasWeakPtrs()) return; - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::Bind(&WebContentsImpl::SendChangeLoadProgress, - loading_weak_factory_.GetWeakPtr()), + base::MessageLoop::current()->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 e9ba331d3c4162..ccd1689d3a57dc 100644 --- a/content/browser/web_contents/web_contents_view_aura_browsertest.cc +++ b/content/browser/web_contents/web_contents_view_aura_browsertest.cc @@ -5,12 +5,9 @@ #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" @@ -49,8 +46,9 @@ namespace { // for details. void GiveItSomeTime() { base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, run_loop.QuitClosure(), + base::MessageLoop::current()->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 ba1f5d4646e05e..1c171c2645e555 100644 --- a/content/browser/webui/url_data_manager_backend.cc +++ b/content/browser/webui/url_data_manager_backend.cc @@ -12,12 +12,11 @@ #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" @@ -640,17 +639,19 @@ 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->task_runner()->PostTask( + target_message_loop->PostTask( FROM_HERE, - base::Bind(&GetMimeTypeOnUI, scoped_refptr(source), + base::Bind(&GetMimeTypeOnUI, + scoped_refptr(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->task_runner()->PostTask( - FROM_HERE, base::Bind(&URLDataManagerBackend::CallStartRequest, - make_scoped_refptr(source), path, - render_process_id, render_frame_id, request_id)); + target_message_loop->PostTask( + FROM_HERE, + base::Bind(&URLDataManagerBackend::CallStartRequest, + make_scoped_refptr(source), path, render_process_id, + render_frame_id, request_id)); } return true; } diff --git a/content/gpu/gpu_watchdog_thread.cc b/content/gpu/gpu_watchdog_thread.cc index e6da1a4497d59f..6052d41647dd38 100644 --- a/content/gpu/gpu_watchdog_thread.cc +++ b/content/gpu/gpu_watchdog_thread.cc @@ -13,10 +13,8 @@ #include "base/command_line.h" #include "base/compiler_specific.h" #include "base/files/file_util.h" -#include "base/location.h" #include "base/power_monitor/power_monitor.h" #include "base/process/process.h" -#include "base/single_thread_task_runner.h" #include "build/build_config.h" #include "content/public/common/content_switches.h" #include "content/public/common/result_codes.h" @@ -77,8 +75,9 @@ GpuWatchdogThread::GpuWatchdogThread(int timeout) void GpuWatchdogThread::PostAcknowledge() { // Called on the monitored thread. Responds with OnAcknowledge. Cannot use // the method factory. Rely on reference counting instead. - task_runner()->PostTask(FROM_HERE, - base::Bind(&GpuWatchdogThread::OnAcknowledge, this)); + message_loop()->PostTask( + FROM_HERE, + base::Bind(&GpuWatchdogThread::OnAcknowledge, this)); } void GpuWatchdogThread::CheckArmed() { @@ -163,9 +162,10 @@ void GpuWatchdogThread::OnAcknowledge() { bool was_suspended = (base::Time::Now() > suspension_timeout_); // The monitored thread has responded. Post a task to check it again. - task_runner()->PostDelayedTask( - FROM_HERE, base::Bind(&GpuWatchdogThread::OnCheck, - weak_factory_.GetWeakPtr(), was_suspended), + message_loop()->PostDelayedTask( + FROM_HERE, + base::Bind(&GpuWatchdogThread::OnCheck, weak_factory_.GetWeakPtr(), + was_suspended), 0.5 * timeout_); } @@ -194,12 +194,13 @@ void GpuWatchdogThread::OnCheck(bool after_suspend) { // Post a task to the monitored thread that does nothing but wake up the // TaskObserver. Any other tasks that are pending on the watched thread will // also wake up the observer. This simply ensures there is at least one. - watched_message_loop_->task_runner()->PostTask(FROM_HERE, - base::Bind(&base::DoNothing)); + watched_message_loop_->PostTask( + FROM_HERE, + base::Bind(&base::DoNothing)); // Post a task to the watchdog thread to exit if the monitored thread does // not respond in time. - task_runner()->PostDelayedTask( + message_loop()->PostDelayedTask( FROM_HERE, base::Bind(&GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang, weak_factory_.GetWeakPtr()), @@ -340,8 +341,9 @@ bool GpuWatchdogThread::MatchXEventAtom(XEvent* event) { #endif void GpuWatchdogThread::AddPowerObserver() { - task_runner()->PostTask( - FROM_HERE, base::Bind(&GpuWatchdogThread::OnAddPowerObserver, this)); + message_loop()->PostTask( + FROM_HERE, + base::Bind(&GpuWatchdogThread::OnAddPowerObserver, this)); } void GpuWatchdogThread::OnAddPowerObserver() { diff --git a/content/public/browser/browser_thread.h b/content/public/browser/browser_thread.h index a68903dab9a59f..9473c2cd386c78 100644 --- a/content/public/browser/browser_thread.h +++ b/content/public/browser/browser_thread.h @@ -11,7 +11,7 @@ #include "base/callback.h" #include "base/location.h" #include "base/logging.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop_proxy.h" #include "base/task_runner_util.h" #include "base/time/time.h" #include "content/common/content_export.h" @@ -88,7 +88,7 @@ class CONTENT_EXPORT BrowserThread { // NOTE: do not add new threads here that are only used by a small number of // files. Instead you should just use a Thread class and pass its - // task runner around. Named threads there are only for threads that + // MessageLoopProxy around. Named threads there are only for threads that // are used in many places. // This identifier does not represent a thread. Instead it counts the @@ -130,10 +130,10 @@ class CONTENT_EXPORT BrowserThread { const tracked_objects::Location& from_here, const base::Callback& task, const base::Callback& reply) { - scoped_refptr task_runner = + scoped_refptr message_loop_proxy = GetMessageLoopProxyForThread(identifier); - return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, task, - reply); + return base::PostTaskAndReplyWithResult( + message_loop_proxy.get(), from_here, task, reply); } template @@ -216,10 +216,10 @@ class CONTENT_EXPORT BrowserThread { // sets identifier to its ID. Otherwise returns false. static bool GetCurrentThreadIdentifier(ID* identifier) WARN_UNUSED_RESULT; - // Callers can hold on to a refcounted task runner beyond the lifetime + // Callers can hold on to a refcounted MessageLoopProxy beyond the lifetime // of the thread. - static scoped_refptr - GetMessageLoopProxyForThread(ID identifier); + static scoped_refptr GetMessageLoopProxyForThread( + ID identifier); // Returns a pointer to the thread's message loop, which will become // invalid during shutdown, so you probably shouldn't hold onto it. diff --git a/content/public/browser/devtools_agent_host.h b/content/public/browser/devtools_agent_host.h index 419bbd31f089db..fd27ea1fafb218 100644 --- a/content/public/browser/devtools_agent_host.h +++ b/content/public/browser/devtools_agent_host.h @@ -12,14 +12,11 @@ #include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/message_loop/message_loop_proxy.h" #include "content/common/content_export.h" #include "content/public/browser/devtools_agent_host_client.h" #include "url/gurl.h" -namespace base { -class SingleThreadTaskRunner; -} - namespace net { class ServerSocket; } diff --git a/content/public/renderer/render_thread.h b/content/public/renderer/render_thread.h index 3a2f9b087741ad..d22126c82adde6 100644 --- a/content/public/renderer/render_thread.h +++ b/content/public/renderer/render_thread.h @@ -17,6 +17,7 @@ class GURL; namespace base { class MessageLoop; +class MessageLoopProxy; class WaitableEvent; } diff --git a/content/public/test/browser_test_base.cc b/content/public/test/browser_test_base.cc index c5078fc19b525c..9892f2e3d68b82 100644 --- a/content/public/test/browser_test_base.cc +++ b/content/public/test/browser_test_base.cc @@ -8,8 +8,7 @@ #include "base/command_line.h" #include "base/debug/stack_trace.h" #include "base/i18n/icu_util.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" #include "base/strings/string_number_conversions.h" #include "base/sys_info.h" #include "base/test/test_timeouts.h" @@ -336,7 +335,7 @@ void BrowserTestBase::PostTaskToInProcessRendererAndWait( RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); CHECK(renderer_loop); - renderer_loop->task_runner()->PostTask( + renderer_loop->PostTask( FROM_HERE, base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); runner->Run(); diff --git a/content/public/test/fake_speech_recognition_manager.cc b/content/public/test/fake_speech_recognition_manager.cc index dbaf365c7fb74b..e728ee287106d7 100644 --- a/content/public/test/fake_speech_recognition_manager.cc +++ b/content/public/test/fake_speech_recognition_manager.cc @@ -5,10 +5,8 @@ #include "content/public/test/fake_speech_recognition_manager.h" #include "base/bind.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" #include "base/strings/utf_string_conversions.h" -#include "base/thread_task_runner_handle.h" #include "content/public/browser/speech_recognition_event_listener.h" #include "content/public/browser/speech_recognition_manager_delegate.h" #include "content/public/common/speech_recognition_result.h" @@ -81,7 +79,7 @@ void FakeSpeechRecognitionManager::StartSession(int session_id) { if (should_send_fake_response_) { // Give the fake result in a short while. - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind( &FakeSpeechRecognitionManager::SetFakeRecognitionResult, diff --git a/content/public/test/frame_load_waiter.cc b/content/public/test/frame_load_waiter.cc index c9cee107d590af..6da69afb8ca7ff 100644 --- a/content/public/test/frame_load_waiter.cc +++ b/content/public/test/frame_load_waiter.cc @@ -5,8 +5,7 @@ #include "content/public/test/frame_load_waiter.h" #include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop.h" namespace content { @@ -22,8 +21,7 @@ void FrameLoadWaiter::Wait() { void FrameLoadWaiter::DidFinishLoad() { // Post a task to quit instead of quitting directly, since the load completion // may trigger other IPCs that tests are expecting. - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - run_loop_.QuitClosure()); + base::MessageLoop::current()->PostTask(FROM_HERE, run_loop_.QuitClosure()); } } // namespace content diff --git a/content/public/test/mock_blob_url_request_context.cc b/content/public/test/mock_blob_url_request_context.cc index e2c6fa33912e41..f0cd5461991097 100644 --- a/content/public/test/mock_blob_url_request_context.cc +++ b/content/public/test/mock_blob_url_request_context.cc @@ -4,7 +4,6 @@ #include "content/public/test/mock_blob_url_request_context.h" -#include "base/thread_task_runner_handle.h" #include "storage/browser/blob/blob_data_builder.h" #include "storage/browser/blob/blob_storage_context.h" #include "storage/browser/blob/blob_url_request_job.h" @@ -17,9 +16,10 @@ MockBlobURLRequestContext::MockBlobURLRequestContext( : blob_storage_context_(new storage::BlobStorageContext) { // Job factory owns the protocol handler. job_factory_.SetProtocolHandler( - "blob", new storage::BlobProtocolHandler( - blob_storage_context_.get(), file_system_context, - base::ThreadTaskRunnerHandle::Get())); + "blob", + new storage::BlobProtocolHandler(blob_storage_context_.get(), + file_system_context, + base::MessageLoopProxy::current())); set_job_factory(&job_factory_); } diff --git a/content/public/test/mock_render_thread.cc b/content/public/test/mock_render_thread.cc index 60f19f0599ca4c..9d3c51bb290cd5 100644 --- a/content/public/test/mock_render_thread.cc +++ b/content/public/test/mock_render_thread.cc @@ -4,8 +4,7 @@ #include "content/public/test/mock_render_thread.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop_proxy.h" #include "content/common/frame_messages.h" #include "content/common/view_messages.h" #include "content/public/renderer/render_process_observer.h" @@ -64,7 +63,7 @@ bool MockRenderThread::Send(IPC::Message* msg) { } scoped_refptr MockRenderThread::GetTaskRunner() { - return base::ThreadTaskRunnerHandle::Get(); + return base::MessageLoopProxy::current(); } IPC::SyncChannel* MockRenderThread::GetChannel() { diff --git a/content/public/test/mock_storage_client.cc b/content/public/test/mock_storage_client.cc index 8370e6c217920b..734285525839d5 100644 --- a/content/public/test/mock_storage_client.cc +++ b/content/public/test/mock_storage_client.cc @@ -6,12 +6,10 @@ #include "base/basictypes.h" #include "base/bind.h" -#include "base/location.h" #include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop_proxy.h" #include "base/stl_util.h" -#include "base/thread_task_runner_handle.h" #include "net/base/net_util.h" #include "storage/browser/quota/quota_manager_proxy.h" @@ -94,7 +92,7 @@ void MockStorageClient::OnQuotaManagerDestroyed() { void MockStorageClient::GetOriginUsage(const GURL& origin_url, StorageType type, const GetUsageCallback& callback) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoopProxy::current()->PostTask( FROM_HERE, base::Bind(&MockStorageClient::RunGetOriginUsage, weak_factory_.GetWeakPtr(), origin_url, type, callback)); @@ -102,23 +100,25 @@ void MockStorageClient::GetOriginUsage(const GURL& origin_url, void MockStorageClient::GetOriginsForType( StorageType type, const GetOriginsCallback& callback) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&MockStorageClient::RunGetOriginsForType, - weak_factory_.GetWeakPtr(), type, callback)); + base::MessageLoopProxy::current()->PostTask( + FROM_HERE, + base::Bind(&MockStorageClient::RunGetOriginsForType, + weak_factory_.GetWeakPtr(), type, callback)); } void MockStorageClient::GetOriginsForHost( StorageType type, const std::string& host, const GetOriginsCallback& callback) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&MockStorageClient::RunGetOriginsForHost, - weak_factory_.GetWeakPtr(), type, host, callback)); + base::MessageLoopProxy::current()->PostTask( + FROM_HERE, + base::Bind(&MockStorageClient::RunGetOriginsForHost, + weak_factory_.GetWeakPtr(), type, host, callback)); } void MockStorageClient::DeleteOriginData( const GURL& origin, StorageType type, const DeletionCallback& callback) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoopProxy::current()->PostTask( FROM_HERE, base::Bind(&MockStorageClient::RunDeleteOriginData, weak_factory_.GetWeakPtr(), origin, type, callback)); diff --git a/content/public/test/render_view_test.cc b/content/public/test/render_view_test.cc index 26262408d20963..e6925e26a1a65f 100644 --- a/content/public/test/render_view_test.cc +++ b/content/public/test/render_view_test.cc @@ -6,9 +6,7 @@ #include -#include "base/location.h" #include "base/run_loop.h" -#include "base/single_thread_task_runner.h" #include "components/scheduler/renderer/renderer_scheduler.h" #include "content/common/dom_storage/dom_storage_types.h" #include "content/common/frame_messages.h" @@ -135,8 +133,7 @@ RenderViewTest::~RenderViewTest() { } void RenderViewTest::ProcessPendingMessages() { - msg_loop_.task_runner()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); + msg_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); msg_loop_.Run(); } diff --git a/content/public/test/sandbox_file_system_test_helper.cc b/content/public/test/sandbox_file_system_test_helper.cc index 9e52ee8693bba9..38af9dfb644e05 100644 --- a/content/public/test/sandbox_file_system_test_helper.cc +++ b/content/public/test/sandbox_file_system_test_helper.cc @@ -5,6 +5,7 @@ #include "content/public/test/sandbox_file_system_test_helper.h" #include "base/files/file_util.h" +#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" #include "content/public/test/mock_special_storage_policy.h" #include "content/public/test/test_file_system_context.h" diff --git a/content/public/test/test_file_system_context.cc b/content/public/test/test_file_system_context.cc index 7f602507ddd173..d44765be1f6868 100644 --- a/content/public/test/test_file_system_context.cc +++ b/content/public/test/test_file_system_context.cc @@ -5,7 +5,6 @@ #include "content/public/test/test_file_system_context.h" #include "base/memory/scoped_vector.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_options.h" @@ -20,7 +19,7 @@ storage::FileSystemContext* CreateFileSystemContextForTesting( const base::FilePath& base_path) { ScopedVector additional_providers; additional_providers.push_back(new TestFileSystemBackend( - base::ThreadTaskRunnerHandle::Get().get(), base_path)); + base::MessageLoopProxy::current().get(), base_path)); return CreateFileSystemContextWithAdditionalProvidersForTesting( quota_manager_proxy, additional_providers.Pass(), base_path); } @@ -31,12 +30,14 @@ CreateFileSystemContextWithAdditionalProvidersForTesting( ScopedVector additional_providers, const base::FilePath& base_path) { return new storage::FileSystemContext( - base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().get(), storage::ExternalMountPoints::CreateRefCounted().get(), make_scoped_refptr(new MockSpecialStoragePolicy()).get(), - quota_manager_proxy, additional_providers.Pass(), - std::vector(), base_path, + quota_manager_proxy, + additional_providers.Pass(), + std::vector(), + base_path, CreateAllowFileAccessOptions()); } @@ -46,12 +47,15 @@ storage::FileSystemContext* CreateFileSystemContextWithAutoMountersForTesting( const std::vector& auto_mounters, const base::FilePath& base_path) { return new storage::FileSystemContext( - base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().get(), storage::ExternalMountPoints::CreateRefCounted().get(), make_scoped_refptr(new MockSpecialStoragePolicy()).get(), - quota_manager_proxy, additional_providers.Pass(), auto_mounters, - base_path, CreateAllowFileAccessOptions()); + quota_manager_proxy, + additional_providers.Pass(), + auto_mounters, + base_path, + CreateAllowFileAccessOptions()); } storage::FileSystemContext* CreateIncognitoFileSystemContextForTesting( @@ -59,12 +63,14 @@ storage::FileSystemContext* CreateIncognitoFileSystemContextForTesting( const base::FilePath& base_path) { ScopedVector additional_providers; return new storage::FileSystemContext( - base::ThreadTaskRunnerHandle::Get().get(), - base::ThreadTaskRunnerHandle::Get().get(), + base::MessageLoopProxy::current().get(), + base::MessageLoopProxy::current().get(), storage::ExternalMountPoints::CreateRefCounted().get(), make_scoped_refptr(new MockSpecialStoragePolicy()).get(), - quota_manager_proxy, additional_providers.Pass(), - std::vector(), base_path, + quota_manager_proxy, + additional_providers.Pass(), + std::vector(), + base_path, CreateIncognitoFileSystemOptions()); } diff --git a/content/public/test/test_utils.cc b/content/public/test/test_utils.cc index 4293f399d97612..2fa45c0b10744d 100644 --- a/content/public/test/test_utils.cc +++ b/content/public/test/test_utils.cc @@ -5,11 +5,9 @@ #include "content/public/test/test_utils.h" #include "base/bind.h" -#include "base/location.h" +#include "base/message_loop/message_loop.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 "base/values.h" #include "content/public/browser/browser_child_process_host_iterator.h" #include "content/public/browser/notification_service.h" @@ -39,7 +37,7 @@ static void DeferredQuitRunLoop(const base::Closure& quit_task, if (num_quit_deferrals <= 0) { quit_task.Run(); } else { - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&DeferredQuitRunLoop, quit_task, num_quit_deferrals - 1)); } @@ -129,8 +127,8 @@ void RunThisRunLoop(base::RunLoop* run_loop) { void RunAllPendingInMessageLoop() { base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, GetQuitTaskForRunLoop(&run_loop)); + base::MessageLoop::current()->PostTask( + FROM_HERE, GetQuitTaskForRunLoop(&run_loop)); RunThisRunLoop(&run_loop); } diff --git a/content/shell/browser/blink_test_controller.cc b/content/shell/browser/blink_test_controller.cc index bdfcd1de23cb89..ef3eeb9d8f7551 100644 --- a/content/shell/browser/blink_test_controller.cc +++ b/content/shell/browser/blink_test_controller.cc @@ -8,12 +8,10 @@ #include "base/base64.h" #include "base/command_line.h" -#include "base/location.h" +#include "base/message_loop/message_loop.h" #include "base/run_loop.h" -#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" -#include "base/thread_task_runner_handle.h" #include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/dom_storage_context.h" #include "content/public/browser/gpu_data_manager.h" @@ -402,7 +400,7 @@ void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path, DCHECK(CalledOnValidThread()); printer_->AddErrorMessage( base::StringPrintf("#CRASHED - plugin (pid %d)", plugin_pid)); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(base::IgnoreResult(&BlinkTestController::DiscardMainWindow), base::Unretained(this))); @@ -483,8 +481,8 @@ void BlinkTestController::DiscardMainWindow() { WebContentsObserver::Observe(NULL); if (test_phase_ != BETWEEN_TESTS) { Shell::CloseAllWindows(); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::MessageLoop::QuitClosure()); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); test_phase_ = CLEAN_UP; } else if (main_window_) { main_window_->Close(); @@ -517,7 +515,7 @@ void BlinkTestController::OnTestFinished() { RenderViewHost* render_view_host = main_window_->web_contents()->GetRenderViewHost(); main_window_->web_contents()->ExitFullscreen(); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(base::IgnoreResult(&BlinkTestController::Send), base::Unretained(this), @@ -682,15 +680,15 @@ void BlinkTestController::OnResetDone() { return; } - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::MessageLoop::QuitClosure()); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); } void BlinkTestController::OnLeakDetectionDone( const LeakDetectionResult& result) { if (!result.leaked) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::MessageLoop::QuitClosure()); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); return; } diff --git a/content/shell/browser/layout_test/layout_test_browser_main.cc b/content/shell/browser/layout_test/layout_test_browser_main.cc index ec347517324c26..44f05495a63856 100644 --- a/content/shell/browser/layout_test/layout_test_browser_main.cc +++ b/content/shell/browser/layout_test/layout_test_browser_main.cc @@ -10,13 +10,11 @@ #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/logging.h" #include "base/memory/scoped_ptr.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" #include "base/strings/sys_string_conversions.h" #include "base/strings/utf_string_conversions.h" -#include "base/thread_task_runner_handle.h" #include "base/threading/thread_restrictions.h" #include "content/public/browser/browser_main_runner.h" #include "content/public/common/url_constants.h" @@ -172,8 +170,8 @@ int RunTests(const scoped_ptr& main_runner) { break; } if (!ran_at_least_once) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::MessageLoop::QuitClosure()); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); main_runner->Run(); } @@ -214,8 +212,8 @@ int LayoutTestBrowserMain( if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kCheckLayoutTestSysDeps)) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::MessageLoop::QuitClosure()); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); main_runner->Run(); content::Shell::CloseAllWindows(); main_runner->Shutdown(); diff --git a/content/shell/browser/shell.cc b/content/shell/browser/shell.cc index c1a445f98efc7e..67552c80c2f4b2 100644 --- a/content/shell/browser/shell.cc +++ b/content/shell/browser/shell.cc @@ -6,13 +6,11 @@ #include "base/auto_reset.h" #include "base/command_line.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" -#include "base/thread_task_runner_handle.h" #include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" @@ -91,8 +89,8 @@ Shell::~Shell() { if (windows_.empty() && quit_message_loop_) { if (headless_) PlatformExit(); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::MessageLoop::QuitClosure()); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); } } diff --git a/content/shell/browser/shell_url_request_context_getter.cc b/content/shell/browser/shell_url_request_context_getter.cc index cafda2de06448a..b6218aba6601ab 100644 --- a/content/shell/browser/shell_url_request_context_getter.cc +++ b/content/shell/browser/shell_url_request_context_getter.cc @@ -6,7 +6,6 @@ #include "base/command_line.h" #include "base/logging.h" -#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" @@ -94,7 +93,7 @@ net::NetworkDelegate* ShellURLRequestContextGetter::CreateNetworkDelegate() { net::ProxyConfigService* ShellURLRequestContextGetter::GetProxyConfigService() { return net::ProxyService::CreateSystemProxyConfigService( - io_loop_->task_runner(), file_loop_->task_runner()); + io_loop_->message_loop_proxy(), file_loop_->message_loop_proxy()); } net::ProxyService* ShellURLRequestContextGetter::GetProxyService() { diff --git a/content/shell/renderer/layout_test/blink_test_runner.cc b/content/shell/renderer/layout_test/blink_test_runner.cc index 9c2cbbfd5652bc..b17da212d91dc7 100644 --- a/content/shell/renderer/layout_test/blink_test_runner.cc +++ b/content/shell/renderer/layout_test/blink_test_runner.cc @@ -13,15 +13,13 @@ #include "base/compiler_specific.h" #include "base/debug/debugger.h" #include "base/files/file_path.h" -#include "base/location.h" #include "base/md5.h" #include "base/memory/scoped_ptr.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/sys_string_conversions.h" #include "base/strings/utf_string_conversions.h" -#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "components/test_runner/app_banner_client.h" #include "components/test_runner/gamepad_controller.h" @@ -833,7 +831,7 @@ void BlinkTestRunner::CaptureDumpPixels(const SkBitmap& snapshot) { void BlinkTestRunner::CaptureDumpComplete() { render_view()->GetWebView()->mainFrame()->stopLoading(); - base::ThreadTaskRunnerHandle::Get()->PostTask( + base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(base::IgnoreResult(&BlinkTestRunner::Send), base::Unretained(this), new ShellViewHostMsg_TestFinished(routing_id()))); diff --git a/content/shell/renderer/layout_test/test_video_frame_provider.cc b/content/shell/renderer/layout_test/test_video_frame_provider.cc index 97ecb02e361ec8..09895728942343 100644 --- a/content/shell/renderer/layout_test/test_video_frame_provider.cc +++ b/content/shell/renderer/layout_test/test_video_frame_provider.cc @@ -6,8 +6,7 @@ #include "base/bind.h" #include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop_proxy.h" #include "media/base/video_frame.h" namespace content { @@ -17,7 +16,7 @@ TestVideoFrameProvider::TestVideoFrameProvider( const base::TimeDelta& frame_duration, const base::Closure& error_cb, const VideoFrameProvider::RepaintCB& repaint_cb) - : task_runner_(base::ThreadTaskRunnerHandle::Get()), + : message_loop_proxy_(base::MessageLoopProxy::current()), size_(size), state_(kStopped), frame_duration_(frame_duration), @@ -29,35 +28,36 @@ TestVideoFrameProvider::~TestVideoFrameProvider() {} void TestVideoFrameProvider::Start() { DVLOG(1) << "TestVideoFrameProvider::Start"; - DCHECK(task_runner_->BelongsToCurrentThread()); + DCHECK(message_loop_proxy_->BelongsToCurrentThread()); state_ = kStarted; - task_runner_->PostTask( - FROM_HERE, base::Bind(&TestVideoFrameProvider::GenerateFrame, this)); + message_loop_proxy_->PostTask( + FROM_HERE, + base::Bind(&TestVideoFrameProvider::GenerateFrame, this)); } void TestVideoFrameProvider::Stop() { DVLOG(1) << "TestVideoFrameProvider::Stop"; - DCHECK(task_runner_->BelongsToCurrentThread()); + DCHECK(message_loop_proxy_->BelongsToCurrentThread()); state_ = kStopped; } void TestVideoFrameProvider::Play() { DVLOG(1) << "TestVideoFrameProvider::Play"; - DCHECK(task_runner_->BelongsToCurrentThread()); + DCHECK(message_loop_proxy_->BelongsToCurrentThread()); if (state_ == kPaused) state_ = kStarted; } void TestVideoFrameProvider::Pause() { DVLOG(1) << "TestVideoFrameProvider::Pause"; - DCHECK(task_runner_->BelongsToCurrentThread()); + DCHECK(message_loop_proxy_->BelongsToCurrentThread()); if (state_ == kStarted) state_ = kPaused; } void TestVideoFrameProvider::GenerateFrame() { DVLOG(1) << "TestVideoFrameProvider::GenerateFrame"; - DCHECK(task_runner_->BelongsToCurrentThread()); + DCHECK(message_loop_proxy_->BelongsToCurrentThread()); if (state_ == kStopped) return; @@ -74,8 +74,9 @@ void TestVideoFrameProvider::GenerateFrame() { } current_time_ += frame_duration_; - task_runner_->PostDelayedTask( - FROM_HERE, base::Bind(&TestVideoFrameProvider::GenerateFrame, this), + message_loop_proxy_->PostDelayedTask( + FROM_HERE, + base::Bind(&TestVideoFrameProvider::GenerateFrame, this), frame_duration_); } diff --git a/content/shell/renderer/layout_test/test_video_frame_provider.h b/content/shell/renderer/layout_test/test_video_frame_provider.h index ca09e3e19b137e..00ee3c8e85e61f 100644 --- a/content/shell/renderer/layout_test/test_video_frame_provider.h +++ b/content/shell/renderer/layout_test/test_video_frame_provider.h @@ -10,7 +10,7 @@ #include "ui/gfx/geometry/size.h" namespace base { -class SingleThreadTaskRunner; +class MessageLoopProxy; } namespace content { @@ -46,7 +46,7 @@ class TestVideoFrameProvider : public VideoFrameProvider { void GenerateFrame(); - scoped_refptr task_runner_; + scoped_refptr message_loop_proxy_; gfx::Size size_; State state_; diff --git a/content/test/content_browser_test_test.cc b/content/test/content_browser_test_test.cc index f574f0ce351340..7b43385aa46b91 100644 --- a/content/test/content_browser_test_test.cc +++ b/content/test/content_browser_test_test.cc @@ -5,10 +5,7 @@ #include "content/public/test/content_browser_test.h" #include "base/command_line.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 "content/public/common/content_switches.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/content_browser_test_utils.h" @@ -61,7 +58,7 @@ void CallbackChecker(bool* non_nested_task_ran) { IN_PROC_BROWSER_TEST_F(ContentBrowserTestSanityTest, NonNestableTask) { bool non_nested_task_ran = false; - base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( + base::MessageLoop::current()->PostNonNestableTask( FROM_HERE, base::Bind(&CallbackChecker, &non_nested_task_ran)); content::RunAllPendingInMessageLoop(); ASSERT_TRUE(non_nested_task_ran); diff --git a/content/test/fake_compositor_dependencies.cc b/content/test/fake_compositor_dependencies.cc index 37ef965dc6364f..a29312fa8a5f6d 100644 --- a/content/test/fake_compositor_dependencies.cc +++ b/content/test/fake_compositor_dependencies.cc @@ -4,8 +4,7 @@ #include "content/test/fake_compositor_dependencies.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" +#include "base/message_loop/message_loop_proxy.h" #include "cc/test/fake_external_begin_frame_source.h" #include "third_party/khronos/GLES2/gl2.h" @@ -59,7 +58,7 @@ uint32 FakeCompositorDependencies::GetImageTextureTarget() { scoped_refptr FakeCompositorDependencies::GetCompositorMainThreadTaskRunner() { - return base::ThreadTaskRunnerHandle::Get(); + return base::MessageLoopProxy::current(); } scoped_refptr diff --git a/content/test/net/url_request_abort_on_end_job.cc b/content/test/net/url_request_abort_on_end_job.cc index 8bfd7f9ce506fb..cdaca32966daba 100644 --- a/content/test/net/url_request_abort_on_end_job.cc +++ b/content/test/net/url_request_abort_on_end_job.cc @@ -7,10 +7,7 @@ #include #include "base/compiler_specific.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/public/browser/browser_thread.h" #include "content/test/net/url_request_abort_on_end_job.h" #include "net/base/io_buffer.h" @@ -105,9 +102,10 @@ void URLRequestAbortOnEndJob::StartAsync() { } void URLRequestAbortOnEndJob::Start() { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&URLRequestAbortOnEndJob::StartAsync, - weak_factory_.GetWeakPtr())); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&URLRequestAbortOnEndJob::StartAsync, + weak_factory_.GetWeakPtr())); } bool URLRequestAbortOnEndJob::ReadRawData(net::IOBuffer* buf, diff --git a/content/test/test_blink_web_unit_test_support.cc b/content/test/test_blink_web_unit_test_support.cc index 444272ea88dccb..05a6b9bcce2fec 100644 --- a/content/test/test_blink_web_unit_test_support.cc +++ b/content/test/test_blink_web_unit_test_support.cc @@ -95,7 +95,7 @@ TestBlinkWebUnitTestSupport::TestBlinkWebUnitTestSupport() { scoped_refptr dummy_task_runner; scoped_ptr dummy_task_runner_handle; - if (!base::ThreadTaskRunnerHandle::IsSet()) { + if (!base::MessageLoopProxy::current()) { // Dummy task runner is initialized here because the blink::initialize // creates IsolateHolder which needs the current task runner handle. There // should be no task posted to this task runner. The message loop is not diff --git a/content/utility/in_process_utility_thread.cc b/content/utility/in_process_utility_thread.cc index 444b81df5c3531..ab5a229ac07b21 100644 --- a/content/utility/in_process_utility_thread.cc +++ b/content/utility/in_process_utility_thread.cc @@ -4,9 +4,6 @@ #include "content/utility/in_process_utility_thread.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" #include "content/child/child_process.h" #include "content/utility/utility_thread_impl.h" @@ -31,9 +28,10 @@ InProcessUtilityThread::~InProcessUtilityThread() { void InProcessUtilityThread::Init() { // We need to return right away or else the main thread that started us will // hang. - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&InProcessUtilityThread::InitInternal, - base::Unretained(this))); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&InProcessUtilityThread::InitInternal, + base::Unretained(this))); } void InProcessUtilityThread::CleanUp() { diff --git a/content/utility/webthread_impl_for_utility_thread.cc b/content/utility/webthread_impl_for_utility_thread.cc index f72456d77126ae..12c4caa66073e7 100644 --- a/content/utility/webthread_impl_for_utility_thread.cc +++ b/content/utility/webthread_impl_for_utility_thread.cc @@ -4,12 +4,10 @@ #include "content/utility/webthread_impl_for_utility_thread.h" -#include "base/thread_task_runner_handle.h" - namespace content { WebThreadImplForUtilityThread::WebThreadImplForUtilityThread() - : task_runner_(base::ThreadTaskRunnerHandle::Get()), + : task_runner_(base::MessageLoopProxy::current()), thread_id_(base::PlatformThread::CurrentId()) { }