diff options
author | skyostil <skyostil@chromium.org> | 2015-06-10 09:44:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-10 16:45:48 +0000 |
commit | 140473b16767c66fc00fd7b0e6f6cc034a6712a8 (patch) | |
tree | 5ddeba7b60262d6f86b88adfc596dba8b5eae7a4 /chrome | |
parent | c1162b1fc5090f8561c7650aecbdc6c61032115b (diff) | |
download | chromium_src-140473b16767c66fc00fd7b0e6f6cc034a6712a8.zip chromium_src-140473b16767c66fc00fd7b0e6f6cc034a6712a8.tar.gz chromium_src-140473b16767c66fc00fd7b0e6f6cc034a6712a8.tar.bz2 |
chrome: Remove use of MessageLoopProxy and deprecated MessageLoop APIs
This patch was mostly autogenerated with https://codereview.chromium.org/1010073002/.
BUG=465354
Review URL: https://codereview.chromium.org/1167163002
Cr-Commit-Position: refs/heads/master@{#333745}
Diffstat (limited to 'chrome')
71 files changed, 462 insertions, 458 deletions
diff --git a/chrome/app_shim/chrome_main_app_mode_mac.mm b/chrome/app_shim/chrome_main_app_mode_mac.mm index ca3d271..98630a6 100644 --- a/chrome/app_shim/chrome_main_app_mode_mac.mm +++ b/chrome/app_shim/chrome_main_app_mode_mac.mm @@ -211,10 +211,8 @@ void AppShimController::Init() { void AppShimController::CreateChannelAndSendLaunchApp( const base::FilePath& socket_path) { IPC::ChannelHandle handle(socket_path.value()); - channel_ = IPC::ChannelProxy::Create(handle, - IPC::Channel::MODE_NAMED_CLIENT, - this, - g_io_thread->message_loop_proxy().get()); + channel_ = IPC::ChannelProxy::Create(handle, IPC::Channel::MODE_NAMED_CLIENT, + this, g_io_thread->task_runner().get()); bool launched_by_chrome = base::CommandLine::ForCurrentProcess()->HasSwitch( app_mode::kLaunchedByChromeProcessId); diff --git a/chrome/common/local_discovery/local_domain_resolver_unittest.cc b/chrome/common/local_discovery/local_domain_resolver_unittest.cc index 2a61283..f55783e 100644 --- a/chrome/common/local_discovery/local_domain_resolver_unittest.cc +++ b/chrome/common/local_discovery/local_domain_resolver_unittest.cc @@ -2,6 +2,9 @@ // 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/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "chrome/common/local_discovery/service_discovery_client_impl.h" #include "net/dns/mdns_client_impl.h" #include "net/dns/mock_mdns_socket_factory.h" @@ -81,7 +84,7 @@ class LocalDomainResolverTest : public testing::Test { base::CancelableCallback<void()> callback(base::Bind( &base::MessageLoop::Quit, base::Unretained(base::MessageLoop::current()))); - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, callback.callback(), time_period); base::MessageLoop::current()->Run(); diff --git a/chrome/common/local_discovery/service_discovery_client_impl.cc b/chrome/common/local_discovery/service_discovery_client_impl.cc index c86f726..733e166 100644 --- a/chrome/common/local_discovery/service_discovery_client_impl.cc +++ b/chrome/common/local_discovery/service_discovery_client_impl.cc @@ -4,10 +4,12 @@ #include <utility> +#include "base/location.h" #include "base/logging.h" #include "base/memory/singleton.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" +#include "base/thread_task_runner_handle.h" #include "chrome/common/local_discovery/service_discovery_client_impl.h" #include "net/dns/dns_protocol.h" #include "net/dns/record_rdata.h" @@ -270,10 +272,9 @@ void ServiceWatcherImpl::DeferUpdate(ServiceWatcher::UpdateType update_type, if (found != services_.end() && !found->second->update_pending()) { found->second->set_update_pending(true); - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&ServiceWatcherImpl::DeliverDeferredUpdate, AsWeakPtr(), - update_type, service_name)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ServiceWatcherImpl::DeliverDeferredUpdate, + AsWeakPtr(), update_type, service_name)); } } @@ -326,12 +327,10 @@ void ServiceWatcherImpl::OnNsecRecord(const std::string& name, void ServiceWatcherImpl::ScheduleQuery(int timeout_seconds) { if (timeout_seconds <= kMaxRequeryTimeSeconds) { - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&ServiceWatcherImpl::SendQuery, - AsWeakPtr(), - timeout_seconds * 2 /*next_timeout_seconds*/, - false /*force_update*/), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&ServiceWatcherImpl::SendQuery, AsWeakPtr(), + timeout_seconds * 2 /*next_timeout_seconds*/, + false /*force_update*/), base::TimeDelta::FromSeconds(timeout_seconds)); } } @@ -560,9 +559,8 @@ void LocalDomainResolverImpl::OnTransactionComplete( &LocalDomainResolverImpl::SendResolvedAddresses, base::Unretained(this))); - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - timeout_callback_.callback(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, timeout_callback_.callback(), base::TimeDelta::FromMilliseconds(kLocalDomainSecondAddressTimeoutMs)); } else if (transactions_finished_ == 2 || address_family_ != net::ADDRESS_FAMILY_UNSPECIFIED) { diff --git a/chrome/common/local_discovery/service_discovery_client_unittest.cc b/chrome/common/local_discovery/service_discovery_client_unittest.cc index 878bca1..ed6db5c 100644 --- a/chrome/common/local_discovery/service_discovery_client_unittest.cc +++ b/chrome/common/local_discovery/service_discovery_client_unittest.cc @@ -2,8 +2,11 @@ // 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/weak_ptr.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "chrome/common/local_discovery/service_discovery_client_impl.h" #include "net/base/net_errors.h" #include "net/dns/dns_protocol.h" @@ -213,7 +216,7 @@ class ServiceDiscoveryTest : public ::testing::Test { void RunFor(base::TimeDelta time_period) { base::CancelableCallback<void()> callback(base::Bind( &ServiceDiscoveryTest::Stop, base::Unretained(this))); - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, callback.callback(), time_period); base::MessageLoop::current()->Run(); diff --git a/chrome/common/profiling.cc b/chrome/common/profiling.cc index 07cc8de..6dc28c6 100644 --- a/chrome/common/profiling.cc +++ b/chrome/common/profiling.cc @@ -9,7 +9,8 @@ #include "base/command_line.h" #include "base/debug/profiler.h" #include "base/lazy_instance.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/threading/thread.h" #include "chrome/common/chrome_switches.h" @@ -82,9 +83,8 @@ void FlushProfilingData(base::Thread* thread) { flush_seconds = kProfilingFlushSeconds; } } - thread->message_loop()->PostDelayedTask( - FROM_HERE, - base::Bind(&FlushProfilingData, thread), + thread->task_runner()->PostDelayedTask( + FROM_HERE, base::Bind(&FlushProfilingData, thread), base::TimeDelta::FromSeconds(flush_seconds)); } @@ -99,8 +99,8 @@ class ProfilingThreadControl { return; thread_ = new base::Thread("Profiling_Flush"); thread_->Start(); - thread_->message_loop()->PostTask( - FROM_HERE, base::Bind(&FlushProfilingData, thread_)); + thread_->task_runner()->PostTask(FROM_HERE, + base::Bind(&FlushProfilingData, thread_)); } void Stop() { diff --git a/chrome/common/service_process_util.h b/chrome/common/service_process_util.h index 9067623..7783e76 100644 --- a/chrome/common/service_process_util.h +++ b/chrome/common/service_process_util.h @@ -26,7 +26,7 @@ class NSString; namespace base { class CommandLine; -class MessageLoopProxy; +class SingleThreadTaskRunner; } // Return the IPC channel to connect to the service process. @@ -88,11 +88,10 @@ class ServiceProcessState { // This method is called when the service process is running and initialized. // |terminate_task| is invoked when we get a terminate request from another // process (in the same thread that called SignalReady). It can be NULL. - // |message_loop_proxy| must be of type IO and is the loop that POSIX uses + // |task_runner| must be of type IO and is the loop that POSIX uses // to monitor the service process. - bool SignalReady( - base::MessageLoopProxy* message_loop_proxy, - const base::Closure& terminate_task); + bool SignalReady(base::SingleThreadTaskRunner* task_runner, + const base::Closure& terminate_task); // Signal that the service process is stopped. void SignalStopped(); diff --git a/chrome/common/service_process_util_posix.cc b/chrome/common/service_process_util_posix.cc index 6a655ca..9ec327c 100644 --- a/chrome/common/service_process_util_posix.cc +++ b/chrome/common/service_process_util_posix.cc @@ -6,8 +6,9 @@ #include "base/basictypes.h" #include "base/bind.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" #include "base/posix/eintr_wrapper.h" +#include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" #include "chrome/common/multi_process_lock.h" @@ -161,9 +162,8 @@ void ServiceProcessState::CreateState() { state_->AddRef(); } -bool ServiceProcessState::SignalReady( - base::MessageLoopProxy* message_loop_proxy, - const base::Closure& terminate_task) { +bool ServiceProcessState::SignalReady(base::SingleThreadTaskRunner* task_runner, + const base::Closure& terminate_task) { DCHECK(state_); #if defined(OS_POSIX) && !defined(OS_MACOSX) @@ -181,11 +181,9 @@ bool ServiceProcessState::SignalReady( base::WaitableEvent signal_ready(true, false); bool success = false; - message_loop_proxy->PostTask(FROM_HERE, - base::Bind(&ServiceProcessState::StateData::SignalReady, - state_, - &signal_ready, - &success)); + task_runner->PostTask(FROM_HERE, + base::Bind(&ServiceProcessState::StateData::SignalReady, + state_, &signal_ready, &success)); signal_ready.Wait(); return success; } diff --git a/chrome/common/service_process_util_unittest.cc b/chrome/common/service_process_util_unittest.cc index 9e4ba36..1881924 100644 --- a/chrome/common/service_process_util_unittest.cc +++ b/chrome/common/service_process_util_unittest.cc @@ -8,8 +8,10 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/files/file_path.h" +#include "base/location.h" #include "base/process/kill.h" #include "base/process/launch.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_split.h" #if !defined(OS_MACOSX) @@ -52,7 +54,7 @@ void ShutdownTask(base::MessageLoop* loop) { // Quit the main message loop. ASSERT_FALSE(g_good_shutdown); g_good_shutdown = true; - loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); + loop->task_runner()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); } } // namespace @@ -70,8 +72,8 @@ class ServiceProcessStateTest : public base::MultiProcessTest { ServiceProcessStateTest(); ~ServiceProcessStateTest() override; void SetUp() override; - base::MessageLoopProxy* IOMessageLoopProxy() { - return io_thread_.message_loop_proxy().get(); + base::SingleThreadTaskRunner* IOMessageLoopProxy() { + return io_thread_.task_runner().get(); } void LaunchAndWait(const std::string& name); @@ -228,11 +230,11 @@ MULTIPROCESS_TEST_MAIN(ServiceProcessStateTestShutdown) { ServiceProcessState state; EXPECT_TRUE(state.Initialize()); EXPECT_TRUE(state.SignalReady( - io_thread_.message_loop_proxy().get(), + io_thread_.task_runner().get(), base::Bind(&ShutdownTask, base::MessageLoop::current()))); - message_loop.PostDelayedTask(FROM_HERE, - base::MessageLoop::QuitClosure(), - TestTimeouts::action_max_timeout()); + message_loop.task_runner()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), + TestTimeouts::action_max_timeout()); EXPECT_FALSE(g_good_shutdown); message_loop.Run(); EXPECT_TRUE(g_good_shutdown); @@ -274,7 +276,7 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test { new Launchd::ScopedInstance(mock_launchd_.get())); ASSERT_TRUE(service_process_state_.Initialize()); ASSERT_TRUE(service_process_state_.SignalReady( - io_thread_.message_loop_proxy().get(), base::Closure())); + io_thread_.task_runner().get(), base::Closure())); loop_.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(), TestTimeouts::action_max_timeout()); @@ -285,8 +287,8 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test { const base::FilePath& bundle_path() const { return bundle_path_; } const base::FilePath& GetTempDirPath() const { return temp_dir_.path(); } - base::MessageLoopProxy* GetIOMessageLoopProxy() { - return io_thread_.message_loop_proxy().get(); + base::SingleThreadTaskRunner* GetIOMessageLoopProxy() { + return io_thread_.task_runner().get(); } void Run() { loop_.Run(); } diff --git a/chrome/common/service_process_util_win.cc b/chrome/common/service_process_util_win.cc index 6aac388..df7c039 100644 --- a/chrome/common/service_process_util_win.cc +++ b/chrome/common/service_process_util_win.cc @@ -132,9 +132,8 @@ bool ServiceProcessState::TakeSingletonLock() { return true; } -bool ServiceProcessState::SignalReady( - base::MessageLoopProxy* message_loop_proxy, - const base::Closure& terminate_task) { +bool ServiceProcessState::SignalReady(base::SingleThreadTaskRunner* task_runner, + const base::Closure& terminate_task) { DCHECK(state_); DCHECK(state_->ready_event.IsValid()); if (!SetEvent(state_->ready_event.Get())) { diff --git a/chrome/common/worker_thread_ticker.cc b/chrome/common/worker_thread_ticker.cc index 1fa75e9..8b78d97 100644 --- a/chrome/common/worker_thread_ticker.cc +++ b/chrome/common/worker_thread_ticker.cc @@ -8,8 +8,9 @@ #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/threading/thread.h" WorkerThreadTicker::WorkerThreadTicker(int tick_interval) @@ -76,7 +77,7 @@ bool WorkerThreadTicker::Stop() { } void WorkerThreadTicker::ScheduleTimerTask() { - timer_thread_.message_loop()->PostDelayedTask( + timer_thread_.task_runner()->PostDelayedTask( FROM_HERE, base::Bind(&WorkerThreadTicker::TimerTask, base::Unretained(this)), tick_interval_); diff --git a/chrome/common/worker_thread_ticker_unittest.cc b/chrome/common/worker_thread_ticker_unittest.cc index 4f7dc0d..dbb2e01 100644 --- a/chrome/common/worker_thread_ticker_unittest.cc +++ b/chrome/common/worker_thread_ticker_unittest.cc @@ -4,7 +4,10 @@ #include "chrome/common/worker_thread_ticker.h" +#include "base/location.h" #include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/platform_thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -18,7 +21,8 @@ class TestCallback : public WorkerThreadTicker::Callback { counter_++; // Finish the test faster. - message_loop_->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); + message_loop_->task_runner()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); } int counter() const { return counter_; } @@ -36,9 +40,8 @@ class LongCallback : public WorkerThreadTicker::Callback { }; void RunMessageLoopForAWhile() { - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::MessageLoop::QuitClosure(), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitClosure(), base::TimeDelta::FromMilliseconds(500)); base::MessageLoop::current()->Run(); } diff --git a/chrome/renderer/chrome_content_renderer_client_browsertest.cc b/chrome/renderer/chrome_content_renderer_client_browsertest.cc index 14b2526..f373539 100644 --- a/chrome/renderer/chrome_content_renderer_client_browsertest.cc +++ b/chrome/renderer/chrome_content_renderer_client_browsertest.cc @@ -9,6 +9,7 @@ #include "base/command_line.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/render_messages.h" #include "chrome/grit/generated_resources.h" @@ -53,7 +54,7 @@ TEST_F(InstantProcessNavigationTest, ForkForNavigationsToSearchURLs) { ChromeContentRendererClient* client = static_cast<ChromeContentRendererClient*>(content_renderer_client_.get()); chrome_render_thread_->set_io_message_loop_proxy( - base::MessageLoopProxy::current()); + base::ThreadTaskRunnerHandle::Get()); client->RenderThreadStarted(); std::vector<GURL> search_urls; search_urls.push_back(GURL("http://example.com/search")); diff --git a/chrome/renderer/chrome_mock_render_thread.cc b/chrome/renderer/chrome_mock_render_thread.cc index e197222..64d809e 100644 --- a/chrome/renderer/chrome_mock_render_thread.cc +++ b/chrome/renderer/chrome_mock_render_thread.cc @@ -4,6 +4,7 @@ #include "chrome/renderer/chrome_mock_render_thread.h" +#include "base/single_thread_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" #if defined(ENABLE_EXTENSIONS) @@ -18,12 +19,12 @@ ChromeMockRenderThread::~ChromeMockRenderThread() { scoped_refptr<base::SingleThreadTaskRunner> ChromeMockRenderThread::GetIOMessageLoopProxy() { - return io_message_loop_proxy_; + return io_task_runner_; } void ChromeMockRenderThread::set_io_message_loop_proxy( - const scoped_refptr<base::MessageLoopProxy>& proxy) { - io_message_loop_proxy_ = proxy; + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { + io_task_runner_ = task_runner; } bool ChromeMockRenderThread::OnMessageReceived(const IPC::Message& msg) { diff --git a/chrome/renderer/chrome_mock_render_thread.h b/chrome/renderer/chrome_mock_render_thread.h index f6e460f..f15d584 100644 --- a/chrome/renderer/chrome_mock_render_thread.h +++ b/chrome/renderer/chrome_mock_render_thread.h @@ -25,7 +25,7 @@ class ChromeMockRenderThread : public content::MockRenderThread { // Set IO message loop proxy. void set_io_message_loop_proxy( - const scoped_refptr<base::MessageLoopProxy>& proxy); + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); private: // Overrides base class implementation to add custom handling for @@ -41,7 +41,7 @@ class ChromeMockRenderThread : public content::MockRenderThread { int* port_id); #endif - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; DISALLOW_COPY_AND_ASSIGN(ChromeMockRenderThread); }; diff --git a/chrome/renderer/chrome_render_process_observer.cc b/chrome/renderer/chrome_render_process_observer.cc index 3fcc1c4c..2d2edce 100644 --- a/chrome/renderer/chrome_render_process_observer.cc +++ b/chrome/renderer/chrome_render_process_observer.cc @@ -11,14 +11,16 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/files/file_util.h" +#include "base/location.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/metrics/statistics_recorder.h" #include "base/native_library.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/threading/platform_thread.h" #include "chrome/common/child_process_logging.h" #include "chrome/common/chrome_paths.h" @@ -38,13 +40,13 @@ #include "crypto/nss_util.h" #include "net/base/net_errors.h" #include "net/base/net_module.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" #include "third_party/WebKit/public/web/WebCache.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" #include "third_party/WebKit/public/web/WebSecurityPolicy.h" #include "third_party/WebKit/public/web/WebView.h" +#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" #if defined(ENABLE_EXTENSIONS) #include "chrome/renderer/extensions/extension_localization_peer.h" @@ -72,7 +74,7 @@ class RendererResourceDelegate : public content::ResourceDispatcherDelegate { // Update the browser about our cache. // Rate limit informing the host of our cache stats. if (!weak_factory_.HasWeakPtrs()) { - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&RendererResourceDelegate::InformHostOfCacheStats, weak_factory_.GetWeakPtr()), @@ -168,12 +170,12 @@ class ResourceUsageReporterImpl : public ResourceUsageReporter { usage_data_->v8_bytes_used = heap_stats.used_heap_size(); base::Closure collect = base::Bind( &ResourceUsageReporterImpl::CollectOnWorkerThread, - base::MessageLoopProxy::current(), weak_factory_.GetWeakPtr()); + base::ThreadTaskRunnerHandle::Get(), weak_factory_.GetWeakPtr()); workers_to_go_ = RenderThread::Get()->PostTaskToAllWebWorkers(collect); if (workers_to_go_) { // The guard task to send out partial stats // in case some workers are not responsive. - base::MessageLoopProxy::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&ResourceUsageReporterImpl::SendResults, weak_factory_.GetWeakPtr()), base::TimeDelta::FromMilliseconds(kWaitForWorkersStatsTimeoutMS)); diff --git a/chrome/renderer/extensions/cast_streaming_native_handler.cc b/chrome/renderer/extensions/cast_streaming_native_handler.cc index 5275f2d..66fb8a7 100644 --- a/chrome/renderer/extensions/cast_streaming_native_handler.cc +++ b/chrome/renderer/extensions/cast_streaming_native_handler.cc @@ -7,9 +7,11 @@ #include <functional> #include <iterator> +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" +#include "base/thread_task_runner_handle.h" #include "chrome/common/extensions/api/cast_streaming_receiver_session.h" #include "chrome/common/extensions/api/cast_streaming_rtp_stream.h" #include "chrome/common/extensions/api/cast_streaming_udp_transport.h" @@ -259,14 +261,11 @@ void CastStreamingNativeHandler::CreateCastSession( // invalid context when the callback is invoked. create_callback_.Reset(isolate, args[2].As<v8::Function>()); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, - base::Bind( - &CastStreamingNativeHandler::CallCreateCallback, - weak_factory_.GetWeakPtr(), - base::Passed(&stream1), - base::Passed(&stream2), - base::Passed(&udp_transport))); + base::Bind(&CastStreamingNativeHandler::CallCreateCallback, + weak_factory_.GetWeakPtr(), base::Passed(&stream1), + base::Passed(&stream2), base::Passed(&udp_transport))); } void CastStreamingNativeHandler::CallCreateCallback( diff --git a/chrome/renderer/media/cast_receiver_session.cc b/chrome/renderer/media/cast_receiver_session.cc index f374549..404fb03 100644 --- a/chrome/renderer/media/cast_receiver_session.cc +++ b/chrome/renderer/media/cast_receiver_session.cc @@ -4,7 +4,9 @@ #include "chrome/renderer/media/cast_receiver_session.h" +#include "base/location.h" #include "base/synchronization/waitable_event.h" +#include "base/thread_task_runner_handle.h" #include "chrome/renderer/media/cast_receiver_audio_valve.h" #include "content/public/renderer/render_thread.h" #include "media/base/audio_capturer_source.h" @@ -92,9 +94,8 @@ void CastReceiverSession::Start( new CastReceiverSession::AudioCapturerSource(this)); scoped_ptr<media::VideoCapturerSource> video( new CastReceiverSession::VideoCapturerSource(this)); - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(start_callback, audio, base::Passed(&video))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(start_callback, audio, base::Passed(&video))); } void CastReceiverSession::StartAudio( diff --git a/chrome/renderer/media/cast_session_browsertest.cc b/chrome/renderer/media/cast_session_browsertest.cc index c9b0c43..f5db9b7 100644 --- a/chrome/renderer/media/cast_session_browsertest.cc +++ b/chrome/renderer/media/cast_session_browsertest.cc @@ -4,8 +4,8 @@ #include "chrome/renderer/media/cast_session.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/run_loop.h" +#include "base/thread_task_runner_handle.h" #include "chrome/renderer/chrome_content_renderer_client.h" #include "chrome/test/base/chrome_render_view_test.h" @@ -17,7 +17,7 @@ typedef ChromeRenderViewTest CastSessionBrowserTest; // chrome renderer. TEST_F(CastSessionBrowserTest, CreateAndDestroy) { chrome_render_thread_->set_io_message_loop_proxy( - base::MessageLoopProxy::current()); + base::ThreadTaskRunnerHandle::Get()); ChromeContentRendererClient* client = static_cast<ChromeContentRendererClient*>(content_renderer_client_.get()); client->RenderThreadStarted(); diff --git a/chrome/renderer/media/cast_threads.cc b/chrome/renderer/media/cast_threads.cc index 9162ff2..b6c808c 100644 --- a/chrome/renderer/media/cast_threads.cc +++ b/chrome/renderer/media/cast_threads.cc @@ -5,6 +5,7 @@ #include "chrome/renderer/media/cast_threads.h" #include "base/logging.h" +#include "base/single_thread_task_runner.h" CastThreads::CastThreads() : audio_encode_thread_("CastAudioEncodeThread"), @@ -15,10 +16,10 @@ CastThreads::CastThreads() scoped_refptr<base::SingleThreadTaskRunner> CastThreads::GetAudioEncodeMessageLoopProxy() { - return audio_encode_thread_.message_loop_proxy(); + return audio_encode_thread_.task_runner(); } scoped_refptr<base::SingleThreadTaskRunner> CastThreads::GetVideoEncodeMessageLoopProxy() { - return video_encode_thread_.message_loop_proxy(); + return video_encode_thread_.task_runner(); } diff --git a/chrome/renderer/media/cast_transport_sender_ipc.h b/chrome/renderer/media/cast_transport_sender_ipc.h index 21f87bd..ce18964 100644 --- a/chrome/renderer/media/cast_transport_sender_ipc.h +++ b/chrome/renderer/media/cast_transport_sender_ipc.h @@ -7,7 +7,7 @@ #include <map> -#include "base/message_loop/message_loop_proxy.h" +#include "base/thread_task_runner_handle.h" #include "ipc/ipc_channel_proxy.h" #include "media/cast/logging/logging_defines.h" #include "media/cast/net/cast_transport_sender.h" diff --git a/chrome/renderer/media/chrome_webrtc_log_message_delegate_unittest.cc b/chrome/renderer/media/chrome_webrtc_log_message_delegate_unittest.cc index 3760347..6680c7e 100644 --- a/chrome/renderer/media/chrome_webrtc_log_message_delegate_unittest.cc +++ b/chrome/renderer/media/chrome_webrtc_log_message_delegate_unittest.cc @@ -5,7 +5,9 @@ #include <string> #include "base/bind.h" +#include "base/location.h" #include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "chrome/renderer/media/chrome_webrtc_log_message_delegate.h" #include "chrome/renderer/media/mock_webrtc_logging_message_filter.h" #include "testing/gtest/include/gtest/gtest.h" @@ -14,7 +16,7 @@ TEST(ChromeWebRtcLogMessageDelegateTest, Basic) { const char kTestString[] = "abcdefghijklmnopqrstuvwxyz"; base::MessageLoopForIO message_loop; scoped_refptr<MockWebRtcLoggingMessageFilter> log_message_filter( - new MockWebRtcLoggingMessageFilter(message_loop.message_loop_proxy())); + new MockWebRtcLoggingMessageFilter(message_loop.task_runner())); // Run message loop to initialize delegate. // TODO(vrk): Fix this so that we can construct a delegate without needing to // construct a message filter. @@ -24,10 +26,9 @@ TEST(ChromeWebRtcLogMessageDelegateTest, Basic) { log_message_filter->log_message_delegate(); // Start logging on the IO loop. - message_loop.message_loop_proxy()->PostTask( - FROM_HERE, base::Bind( - &ChromeWebRtcLogMessageDelegate::OnStartLogging, - base::Unretained(log_message_delegate))); + message_loop.task_runner()->PostTask( + FROM_HERE, base::Bind(&ChromeWebRtcLogMessageDelegate::OnStartLogging, + base::Unretained(log_message_delegate))); // These log messages should be added to the log buffer outside of the IO // loop. @@ -35,10 +36,9 @@ TEST(ChromeWebRtcLogMessageDelegateTest, Basic) { log_message_delegate->LogMessage(kTestString); // Stop logging on IO loop. - message_loop.message_loop_proxy()->PostTask( - FROM_HERE, base::Bind( - &ChromeWebRtcLogMessageDelegate::OnStopLogging, - base::Unretained(log_message_delegate))); + message_loop.task_runner()->PostTask( + FROM_HERE, base::Bind(&ChromeWebRtcLogMessageDelegate::OnStopLogging, + base::Unretained(log_message_delegate))); // This log message should not be added to the log buffer. log_message_delegate->LogMessage(kTestString); diff --git a/chrome/renderer/safe_browsing/phishing_classifier.cc b/chrome/renderer/safe_browsing/phishing_classifier.cc index d731a76..e1d1926 100644 --- a/chrome/renderer/safe_browsing/phishing_classifier.cc +++ b/chrome/renderer/safe_browsing/phishing_classifier.cc @@ -9,10 +9,12 @@ #include "base/bind.h" #include "base/callback.h" #include "base/compiler_specific.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop.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 "chrome/common/safe_browsing/csd.pb.h" #include "chrome/common/url_constants.h" #include "chrome/renderer/safe_browsing/feature_extractor_clock.h" @@ -98,10 +100,9 @@ void PhishingClassifier::BeginClassification( // asynchronously, rather than directly from this method. To ensure that // this is the case, post a task to begin feature extraction on the next // iteration of the message loop. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&PhishingClassifier::BeginFeatureExtraction, - weak_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&PhishingClassifier::BeginFeatureExtraction, + weak_factory_.GetWeakPtr())); } void PhishingClassifier::BeginFeatureExtraction() { diff --git a/chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc b/chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc index 50141be..fc973cd 100644 --- a/chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc +++ b/chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc @@ -5,8 +5,10 @@ #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" #include "base/command_line.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/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ui/browser.h" @@ -118,7 +120,7 @@ class InterceptingMessageFilter : public content::BrowserMessageFilter { verdict->IsInitialized()) { verdict_.swap(verdict); } - waiting_message_loop_->PostTask(FROM_HERE, quit_closure_); + waiting_message_loop_->task_runner()->PostTask(FROM_HERE, quit_closure_); } private: diff --git a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc index 9c92c9a..f47a186 100644 --- a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc +++ b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor.cc @@ -7,10 +7,12 @@ #include "base/bind.h" #include "base/compiler_specific.h" #include "base/containers/hash_tables.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop.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 "base/time/time.h" #include "chrome/renderer/safe_browsing/feature_extractor_clock.h" #include "chrome/renderer/safe_browsing/features.h" @@ -133,7 +135,7 @@ void PhishingDOMFeatureExtractor::ExtractFeatures( cur_document_ = web_view->mainFrame()->document(); } - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PhishingDOMFeatureExtractor::ExtractFeaturesWithTimeout, weak_factory_.GetWeakPtr())); @@ -213,7 +215,7 @@ void PhishingDOMFeatureExtractor::ExtractFeaturesWithTimeout() { // clock granularity. UMA_HISTOGRAM_TIMES("SBClientPhishing.DOMFeatureChunkTime", chunk_elapsed); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind( &PhishingDOMFeatureExtractor::ExtractFeaturesWithTimeout, diff --git a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc index 83746a0..c15219f 100644 --- a/chrome/renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc +++ b/chrome/renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc @@ -13,9 +13,11 @@ #include "base/callback.h" #include "base/command_line.h" #include "base/compiler_specific.h" +#include "base/location.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -62,10 +64,9 @@ class PhishingDOMFeatureExtractorTest : public InProcessBrowserTest { // Helper for the SubframeRemoval test that posts a message to remove // the iframe "frame1" from the document. void ScheduleRemoveIframe() { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&PhishingDOMFeatureExtractorTest::RemoveIframe, - weak_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&PhishingDOMFeatureExtractorTest::RemoveIframe, + weak_factory_.GetWeakPtr())); } protected: diff --git a/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc b/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc index de488f4..31caf0b 100644 --- a/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc +++ b/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc @@ -11,11 +11,13 @@ #include "base/compiler_specific.h" #include "base/i18n/break_iterator.h" #include "base/i18n/case_conversion.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/metrics/histogram.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 "chrome/renderer/safe_browsing/feature_extractor_clock.h" #include "chrome/renderer/safe_browsing/features.h" @@ -123,7 +125,7 @@ void PhishingTermFeatureExtractor::ExtractFeatures( done_callback_ = done_callback; state_.reset(new ExtractionState(*page_text_, clock_->Now())); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PhishingTermFeatureExtractor::ExtractFeaturesWithTimeout, weak_factory_.GetWeakPtr())); @@ -178,7 +180,7 @@ void PhishingTermFeatureExtractor::ExtractFeaturesWithTimeout() { // clock granularity. UMA_HISTOGRAM_TIMES("SBClientPhishing.TermFeatureChunkTime", chunk_elapsed); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind( &PhishingTermFeatureExtractor::ExtractFeaturesWithTimeout, diff --git a/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc b/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc index 4c15605..7896758 100644 --- a/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc +++ b/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc @@ -9,8 +9,10 @@ #include "base/bind.h" #include "base/callback.h" #include "base/containers/hash_tables.h" +#include "base/location.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string16.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -110,10 +112,9 @@ class PhishingTermFeatureExtractorTest : public ::testing::Test { shingle_hashes, base::Bind(&PhishingTermFeatureExtractorTest::ExtractionDone, base::Unretained(this))); - msg_loop_.PostTask( - FROM_HERE, - base::Bind(&PhishingTermFeatureExtractorTest::QuitExtraction, - base::Unretained(this))); + msg_loop_.task_runner()->PostTask( + FROM_HERE, base::Bind(&PhishingTermFeatureExtractorTest::QuitExtraction, + base::Unretained(this))); msg_loop_.RunUntilIdle(); } diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc index 4a0312a..a43c727 100644 --- a/chrome/renderer/spellchecker/spellcheck.cc +++ b/chrome/renderer/spellchecker/spellcheck.cc @@ -10,6 +10,8 @@ #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 "chrome/common/spellcheck_common.h" #include "chrome/common/spellcheck_messages.h" #include "chrome/common/spellcheck_result.h" @@ -355,10 +357,9 @@ void SpellCheck::PostDelayedSpellCheckTask(SpellcheckRequest* request) { if (!request) return; - base::MessageLoopProxy::current()->PostTask(FROM_HERE, - base::Bind(&SpellCheck::PerformSpellCheck, - AsWeakPtr(), - base::Owned(request))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&SpellCheck::PerformSpellCheck, AsWeakPtr(), + base::Owned(request))); } #endif diff --git a/chrome/service/cloud_print/cloud_print_auth.cc b/chrome/service/cloud_print/cloud_print_auth.cc index b52ba0c..663aca7 100644 --- a/chrome/service/cloud_print/cloud_print_auth.cc +++ b/chrome/service/cloud_print/cloud_print_auth.cc @@ -5,8 +5,11 @@ #include "chrome/service/cloud_print/cloud_print_auth.h" #include "base/bind.h" +#include "base/location.h" #include "base/metrics/histogram.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" +#include "base/thread_task_runner_handle.h" #include "chrome/common/cloud_print/cloud_print_constants.h" #include "chrome/common/cloud_print/cloud_print_helpers.h" #include "chrome/service/cloud_print/cloud_print_token_store.h" @@ -134,9 +137,8 @@ void CloudPrintAuth::OnRefreshTokenResponse(const std::string& access_token, DCHECK(expires_in_seconds > kTokenRefreshGracePeriodSecs); base::TimeDelta refresh_delay = base::TimeDelta::FromSeconds( expires_in_seconds - kTokenRefreshGracePeriodSecs); - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&CloudPrintAuth::RefreshAccessToken, this), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&CloudPrintAuth::RefreshAccessToken, this), refresh_delay); } diff --git a/chrome/service/cloud_print/cloud_print_connector.cc b/chrome/service/cloud_print/cloud_print_connector.cc index 4abc4b4..fa78392 100644 --- a/chrome/service/cloud_print/cloud_print_connector.cc +++ b/chrome/service/cloud_print/cloud_print_connector.cc @@ -6,13 +6,16 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/location.h" #include "base/md5.h" #include "base/rand_util.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" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/common/cloud_print/cloud_print_constants.h" #include "chrome/common/cloud_print/cloud_print_helpers.h" @@ -51,10 +54,9 @@ bool CloudPrintConnector::InitPrintSystem() { } void CloudPrintConnector::ScheduleStatsReport() { - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&CloudPrintConnector::ReportStats, - stats_ptr_factory_.GetWeakPtr()), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&CloudPrintConnector::ReportStats, + stats_ptr_factory_.GetWeakPtr()), base::TimeDelta::FromHours(1)); } @@ -492,7 +494,7 @@ void CloudPrintConnector::AddPendingTask(const PendingTask& task) { pending_tasks_.push_back(task); // If this is the only pending task, we need to start the process. if (pending_tasks_.size() == 1) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&CloudPrintConnector::ProcessPendingTask, this)); } } @@ -527,7 +529,7 @@ void CloudPrintConnector::ContinuePendingTaskProcessing() { // Delete current task and repost if we have more task available. pending_tasks_.pop_front(); if (pending_tasks_.size() != 0) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&CloudPrintConnector::ProcessPendingTask, this)); } } diff --git a/chrome/service/cloud_print/cloud_print_proxy_backend.cc b/chrome/service/cloud_print/cloud_print_proxy_backend.cc index 233ff2e..f93215d 100644 --- a/chrome/service/cloud_print/cloud_print_proxy_backend.cc +++ b/chrome/service/cloud_print/cloud_print_proxy_backend.cc @@ -10,9 +10,12 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/compiler_specific.h" +#include "base/location.h" #include "base/metrics/histogram.h" #include "base/rand_util.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/common/cloud_print/cloud_print_constants.h" #include "chrome/service/cloud_print/cloud_print_auth.h" @@ -172,7 +175,7 @@ bool CloudPrintProxyBackend::InitializeWithToken( const std::string& cloud_print_token) { if (!core_thread_.Start()) return false; - core_thread_.message_loop()->PostTask( + core_thread_.task_runner()->PostTask( FROM_HERE, base::Bind(&CloudPrintProxyBackend::Core::DoInitializeWithToken, core_.get(), cloud_print_token)); @@ -184,7 +187,7 @@ bool CloudPrintProxyBackend::InitializeWithRobotToken( const std::string& robot_email) { if (!core_thread_.Start()) return false; - core_thread_.message_loop()->PostTask( + core_thread_.task_runner()->PostTask( FROM_HERE, base::Bind(&CloudPrintProxyBackend::Core::DoInitializeWithRobotToken, core_.get(), robot_oauth_refresh_token, robot_email)); @@ -196,7 +199,7 @@ bool CloudPrintProxyBackend::InitializeWithRobotAuthCode( const std::string& robot_email) { if (!core_thread_.Start()) return false; - core_thread_.message_loop()->PostTask( + core_thread_.task_runner()->PostTask( FROM_HERE, base::Bind(&CloudPrintProxyBackend::Core::DoInitializeWithRobotAuthCode, core_.get(), robot_oauth_auth_code, robot_email)); @@ -204,7 +207,7 @@ bool CloudPrintProxyBackend::InitializeWithRobotAuthCode( } void CloudPrintProxyBackend::Shutdown() { - core_thread_.message_loop()->PostTask( + core_thread_.task_runner()->PostTask( FROM_HERE, base::Bind(&CloudPrintProxyBackend::Core::DoShutdown, core_.get())); core_thread_.Stop(); @@ -212,10 +215,9 @@ void CloudPrintProxyBackend::Shutdown() { } void CloudPrintProxyBackend::UnregisterPrinters() { - core_thread_.message_loop()->PostTask( - FROM_HERE, - base::Bind(&CloudPrintProxyBackend::Core::DoUnregisterPrinters, - core_.get())); + core_thread_.task_runner()->PostTask( + FROM_HERE, base::Bind(&CloudPrintProxyBackend::Core::DoUnregisterPrinters, + core_.get())); } CloudPrintProxyBackend::Core::Core( @@ -282,7 +284,7 @@ void CloudPrintProxyBackend::Core::OnAuthenticationComplete( token_store->SetToken(access_token); robot_email_ = robot_email; // Let the frontend know that we have authenticated. - backend_->frontend_loop_->PostTask( + backend_->frontend_loop_->task_runner()->PostTask( FROM_HERE, base::Bind(&Core::NotifyAuthenticated, this, robot_oauth_refresh_token, robot_email, user_email)); @@ -297,7 +299,7 @@ void CloudPrintProxyBackend::Core::OnAuthenticationComplete( if (!connector_->IsRunning()) { if (!connector_->Start()) { // Let the frontend know that we do not have a print system. - backend_->frontend_loop_->PostTask( + backend_->frontend_loop_->task_runner()->PostTask( FROM_HERE, base::Bind(&Core::NotifyPrintSystemUnavailable, this)); } } @@ -306,7 +308,7 @@ void CloudPrintProxyBackend::Core::OnAuthenticationComplete( void CloudPrintProxyBackend::Core::OnInvalidCredentials() { DCHECK(base::MessageLoop::current() == backend_->core_thread_.message_loop()); VLOG(1) << "CP_CONNECTOR: Auth Error"; - backend_->frontend_loop_->PostTask( + backend_->frontend_loop_->task_runner()->PostTask( FROM_HERE, base::Bind(&Core::NotifyAuthenticationFailed, this)); } @@ -323,9 +325,8 @@ void CloudPrintProxyBackend::Core::OnAuthFailed() { void CloudPrintProxyBackend::Core::OnXmppPingUpdated(int ping_timeout) { settings_.SetXmppPingTimeoutSec(ping_timeout); - backend_->frontend_loop_->PostTask( - FROM_HERE, - base::Bind(&Core::NotifyXmppPingUpdated, this, ping_timeout)); + backend_->frontend_loop_->task_runner()->PostTask( + FROM_HERE, base::Bind(&Core::NotifyXmppPingUpdated, this, ping_timeout)); } void CloudPrintProxyBackend::Core::InitNotifications( @@ -379,10 +380,9 @@ void CloudPrintProxyBackend::Core::DoUnregisterPrinters() { std::list<std::string> printer_ids; connector_->GetPrinterIds(&printer_ids); - backend_->frontend_loop_->PostTask( - FROM_HERE, - base::Bind(&Core::NotifyUnregisterPrinters, - this, access_token, printer_ids)); + backend_->frontend_loop_->task_runner()->PostTask( + FROM_HERE, base::Bind(&Core::NotifyUnregisterPrinters, this, access_token, + printer_ids)); } void CloudPrintProxyBackend::Core::HandlePrinterNotification( @@ -419,9 +419,8 @@ void CloudPrintProxyBackend::Core::ScheduleJobPoll() { if (!job_poll_scheduled_) { base::TimeDelta interval = base::TimeDelta::FromSeconds( base::RandInt(kMinJobPollIntervalSecs, kMaxJobPollIntervalSecs)); - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&CloudPrintProxyBackend::Core::PollForJobs, this), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&CloudPrintProxyBackend::Core::PollForJobs, this), interval); job_poll_scheduled_ = true; } @@ -438,7 +437,7 @@ void CloudPrintProxyBackend::Core::PingXmppServer() { pending_xmpp_pings_++; if (pending_xmpp_pings_ >= kMaxFailedXmppPings) { // Check ping status when we close to the limit. - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&CloudPrintProxyBackend::Core::CheckXmppPingStatus, this), base::TimeDelta::FromSeconds(kXmppPingCheckIntervalSecs)); @@ -456,7 +455,7 @@ void CloudPrintProxyBackend::Core::ScheduleXmppPing() { base::TimeDelta interval = base::TimeDelta::FromSeconds( base::RandInt(settings_.xmpp_ping_timeout_sec() * 0.9, settings_.xmpp_ping_timeout_sec() * 1.1)); - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&CloudPrintProxyBackend::Core::PingXmppServer, this), interval); diff --git a/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc b/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc index 60e0378..7d7c657 100644 --- a/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc +++ b/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc @@ -3,9 +3,11 @@ // found in the LICENSE file. #include "base/command_line.h" +#include "base/location.h" #include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop_proxy.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 "base/values.h" #include "chrome/service/cloud_print/cloud_print_url_fetcher.h" @@ -31,9 +33,9 @@ class TrackingTestURLRequestContextGetter : public net::TestURLRequestContextGetter { public: explicit TrackingTestURLRequestContextGetter( - base::MessageLoopProxy* io_message_loop_proxy, + base::SingleThreadTaskRunner* io_task_runner, net::URLRequestThrottlerManager* throttler_manager) - : TestURLRequestContextGetter(io_message_loop_proxy), + : TestURLRequestContextGetter(io_task_runner), throttler_manager_(throttler_manager) { g_request_context_getter_instances++; } @@ -61,13 +63,12 @@ class TrackingTestURLRequestContextGetter class TestCloudPrintURLFetcher : public CloudPrintURLFetcher { public: explicit TestCloudPrintURLFetcher( - base::MessageLoopProxy* io_message_loop_proxy) - : io_message_loop_proxy_(io_message_loop_proxy) { - } + base::SingleThreadTaskRunner* io_task_runner) + : io_task_runner_(io_task_runner) {} net::URLRequestContextGetter* GetRequestContextGetter() override { - return new TrackingTestURLRequestContextGetter( - io_message_loop_proxy_.get(), throttler_manager()); + return new TrackingTestURLRequestContextGetter(io_task_runner_.get(), + throttler_manager()); } net::URLRequestThrottlerManager* throttler_manager() { @@ -77,7 +78,7 @@ class TestCloudPrintURLFetcher : public CloudPrintURLFetcher { private: ~TestCloudPrintURLFetcher() override {} - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; // We set this as the throttler manager for the // TestURLRequestContext we create. @@ -108,15 +109,15 @@ class CloudPrintURLFetcherTest : public testing::Test, std::string GetAuthHeader() override { return std::string(); } - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy() { - return io_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner() { + return io_task_runner_; } protected: void SetUp() override { testing::Test::SetUp(); - io_message_loop_proxy_ = base::MessageLoopProxy::current(); + io_task_runner_ = base::ThreadTaskRunnerHandle::Get(); } void TearDown() override { @@ -133,7 +134,7 @@ class CloudPrintURLFetcherTest : public testing::Test, // dispatches its requests to. When we wish to simulate being used from // a UI thread, we dispatch a worker thread to do so. base::MessageLoopForIO io_loop_; - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; int max_retries_; Time start_time_; scoped_refptr<TestCloudPrintURLFetcher> fetcher_; @@ -210,7 +211,7 @@ class CloudPrintURLFetcherRetryBackoffTest : public CloudPrintURLFetcherTest { void CloudPrintURLFetcherTest::CreateFetcher(const GURL& url, int max_retries) { - fetcher_ = new TestCloudPrintURLFetcher(io_message_loop_proxy().get()); + fetcher_ = new TestCloudPrintURLFetcher(io_task_runner().get()); // Registers an entry for test url. It only allows 3 requests to be sent // in 200 milliseconds. @@ -254,8 +255,7 @@ CloudPrintURLFetcherBasicTest::HandleRawResponse( if (handle_raw_response_) { // If the current message loop is not the IO loop, it will be shut down when // the main loop returns and this thread subsequently goes out of scope. - io_message_loop_proxy()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); + io_task_runner()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); return CloudPrintURLFetcher::STOP_PROCESSING; } return CloudPrintURLFetcher::CONTINUE_PROCESSING; @@ -269,8 +269,7 @@ CloudPrintURLFetcherBasicTest::HandleRawData( // We should never get here if we returned true in HandleRawResponse EXPECT_FALSE(handle_raw_response_); if (handle_raw_data_) { - io_message_loop_proxy()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); + io_task_runner()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); return CloudPrintURLFetcher::STOP_PROCESSING; } return CloudPrintURLFetcher::CONTINUE_PROCESSING; @@ -285,8 +284,7 @@ CloudPrintURLFetcherBasicTest::HandleJSONData( // We should never get here if we returned true in one of the above methods. EXPECT_FALSE(handle_raw_response_); EXPECT_FALSE(handle_raw_data_); - io_message_loop_proxy()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); + io_task_runner()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); return CloudPrintURLFetcher::STOP_PROCESSING; } @@ -304,8 +302,7 @@ CloudPrintURLFetcherOverloadTest::HandleRawData( // We have already sent 20 requests continuously. And we expect that // it takes more than 1 second due to the overload protection settings. EXPECT_TRUE(Time::Now() - start_time_ >= one_second); - io_message_loop_proxy()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); + io_task_runner()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); } return CloudPrintURLFetcher::STOP_PROCESSING; } @@ -324,8 +321,7 @@ CloudPrintURLFetcherRetryBackoffTest::HandleRawData( void CloudPrintURLFetcherRetryBackoffTest::OnRequestGiveUp() { // It takes more than 200 ms to finish all 11 requests. EXPECT_TRUE(Time::Now() - start_time_ >= TimeDelta::FromMilliseconds(200)); - io_message_loop_proxy()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); + io_task_runner()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); } TEST_F(CloudPrintURLFetcherBasicTest, HandleRawResponse) { diff --git a/chrome/service/cloud_print/connector_settings_unittest.cc b/chrome/service/cloud_print/connector_settings_unittest.cc index 5239fd2..b8475fb 100644 --- a/chrome/service/cloud_print/connector_settings_unittest.cc +++ b/chrome/service/cloud_print/connector_settings_unittest.cc @@ -9,7 +9,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/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/common/cloud_print/cloud_print_constants.h" #include "chrome/service/service_process_prefs.h" @@ -50,7 +51,7 @@ class ConnectorSettingsTest : public testing::Test { protected: void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); - message_loop_proxy_ = base::MessageLoopProxy::current(); + task_runner_ = base::ThreadTaskRunnerHandle::Get(); } ServiceProcessPrefs* CreateTestFile(const char* json) { @@ -62,14 +63,14 @@ class ConnectorSettingsTest : public testing::Test { base::WriteFile(file_name, content.c_str(), content.size()); } ServiceProcessPrefs* prefs = - new ServiceProcessPrefs(file_name, message_loop_proxy_.get()); + new ServiceProcessPrefs(file_name, task_runner_.get()); prefs->ReadPrefs(); return prefs; } base::ScopedTempDir temp_dir_; base::MessageLoop message_loop_; - scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; }; TEST_F(ConnectorSettingsTest, InitFromEmpty) { diff --git a/chrome/service/cloud_print/job_status_updater.cc b/chrome/service/cloud_print/job_status_updater.cc index dcdca08..840bfc0 100644 --- a/chrome/service/cloud_print/job_status_updater.cc +++ b/chrome/service/cloud_print/job_status_updater.cc @@ -6,9 +6,12 @@ #include "base/bind.h" #include "base/json/json_reader.h" +#include "base/location.h" #include "base/metrics/histogram.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/common/cloud_print/cloud_print_constants.h" #include "chrome/service/cloud_print/cloud_print_service_helpers.h" @@ -100,7 +103,7 @@ CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData( base::DictionaryValue* json_data, bool succeeded) { if (IsTerminalJobState(last_job_details_.status)) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&JobStatusUpdater::Stop, this)); } return CloudPrintURLFetcher::STOP_PROCESSING; diff --git a/chrome/service/cloud_print/print_system_cups.cc b/chrome/service/cloud_print/print_system_cups.cc index 132a252..86b453a 100644 --- a/chrome/service/cloud_print/print_system_cups.cc +++ b/chrome/service/cloud_print/print_system_cups.cc @@ -16,14 +16,16 @@ #include "base/bind.h" #include "base/files/file_path.h" #include "base/json/json_reader.h" +#include "base/location.h" #include "base/logging.h" #include "base/md5.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/rand_util.h" +#include "base/single_thread_task_runner.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/values.h" #include "chrome/common/cloud_print/cloud_print_constants.h" #include "chrome/common/crash_keys.h" @@ -183,9 +185,8 @@ class PrintServerWatcherCUPS PrintSystem::PrintServerWatcher::Delegate* delegate) override { delegate_ = delegate; printers_hash_ = GetPrintersHash(); - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&PrintServerWatcherCUPS::CheckForUpdates, this), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&PrintServerWatcherCUPS::CheckForUpdates, this), print_system_->GetUpdateTimeout()); return true; } @@ -204,9 +205,8 @@ class PrintServerWatcherCUPS printers_hash_ = new_hash; delegate_->OnPrinterAdded(); } - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&PrintServerWatcherCUPS::CheckForUpdates, this), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&PrintServerWatcherCUPS::CheckForUpdates, this), print_system_->GetUpdateTimeout()); } @@ -260,15 +260,13 @@ class PrinterWatcherCUPS delegate_ = delegate; settings_hash_ = GetSettingsHash(); // Schedule next job status update. - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&PrinterWatcherCUPS::JobStatusUpdate, this), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&PrinterWatcherCUPS::JobStatusUpdate, this), base::TimeDelta::FromSeconds(kJobUpdateTimeoutSeconds)); // Schedule next printer check. // TODO(gene): Randomize time for the next printer update. - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&PrinterWatcherCUPS::PrinterUpdate, this), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&PrinterWatcherCUPS::PrinterUpdate, this), print_system_->GetUpdateTimeout()); return true; } @@ -292,9 +290,8 @@ class PrinterWatcherCUPS // jobs for this printer and check their status. If printer has no // outstanding jobs, OnJobChanged() will do nothing. delegate_->OnJobChanged(); - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&PrinterWatcherCUPS::JobStatusUpdate, this), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&PrinterWatcherCUPS::JobStatusUpdate, this), base::TimeDelta::FromSeconds(kJobUpdateTimeoutSeconds)); } @@ -317,9 +314,8 @@ class PrinterWatcherCUPS << ", printer name: " << printer_name_; } } - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&PrinterWatcherCUPS::PrinterUpdate, this), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&PrinterWatcherCUPS::PrinterUpdate, this), print_system_->GetUpdateTimeout()); } @@ -380,7 +376,7 @@ class JobSpoolerCUPS : public PrintSystem::JobSpooler { int job_id = print_system_->SpoolPrintJob( print_ticket, print_data_file_path, print_data_mime_type, printer_name, job_title, tags, &dry_run); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&JobSpoolerCUPS::NotifyDelegate, delegate, job_id, dry_run)); return true; @@ -498,9 +494,8 @@ void PrintSystemCUPS::UpdatePrinters() { } // Schedule next update. - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&PrintSystemCUPS::UpdatePrinters, this), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&PrintSystemCUPS::UpdatePrinters, this), GetUpdateTimeout()); } @@ -524,13 +519,9 @@ void PrintSystemCUPS::GetPrinterCapsAndDefaults( const PrinterCapsAndDefaultsCallback& callback) { printing::PrinterCapsAndDefaults printer_info; bool succeeded = GetPrinterCapsAndDefaults(printer_name, &printer_info); - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&PrintSystemCUPS::RunCapsCallback, - callback, - succeeded, - printer_name, - printer_info)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&PrintSystemCUPS::RunCapsCallback, callback, + succeeded, printer_name, printer_info)); } bool PrintSystemCUPS::IsValidPrinter(const std::string& printer_name) { diff --git a/chrome/service/cloud_print/print_system_win.cc b/chrome/service/cloud_print/print_system_win.cc index 550a5633..58b5231 100644 --- a/chrome/service/cloud_print/print_system_win.cc +++ b/chrome/service/cloud_print/print_system_win.cc @@ -9,6 +9,7 @@ #include "base/json/json_writer.h" #include "base/memory/scoped_ptr.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/win/object_watcher.h" #include "base/win/scoped_bstr.h" #include "base/win/scoped_comptr.h" @@ -410,26 +411,24 @@ class JobSpoolerWin : public PrintSystem::JobSpooler { int dc_width = GetDeviceCaps(printer_dc_.Get(), PHYSICALWIDTH); int dc_height = GetDeviceCaps(printer_dc_.Get(), PHYSICALHEIGHT); gfx::Rect render_area(0, 0, dc_width, dc_height); - g_service_process->io_thread()->message_loop_proxy()->PostTask( + g_service_process->io_thread()->task_runner()->PostTask( FROM_HERE, - base::Bind(&JobSpoolerWin::Core::RenderPDFPagesInSandbox, - this, - print_data_file_path_, - render_area, - printer_dpi, - base::MessageLoopProxy::current())); + base::Bind(&JobSpoolerWin::Core::RenderPDFPagesInSandbox, this, + print_data_file_path_, render_area, printer_dpi, + base::ThreadTaskRunnerHandle::Get())); } // Called on the service process IO thread. - void RenderPDFPagesInSandbox(const base::FilePath& pdf_path, - const gfx::Rect& render_area, - int render_dpi, - const scoped_refptr<base::MessageLoopProxy>& - client_message_loop_proxy) { - DCHECK(g_service_process->io_thread()->message_loop_proxy()-> - BelongsToCurrentThread()); + void RenderPDFPagesInSandbox( + const base::FilePath& pdf_path, + const gfx::Rect& render_area, + int render_dpi, + const scoped_refptr<base::SingleThreadTaskRunner>& client_task_runner) { + DCHECK(g_service_process->io_thread() + ->task_runner() + ->BelongsToCurrentThread()); scoped_ptr<ServiceUtilityProcessHost> utility_host( - new ServiceUtilityProcessHost(this, client_message_loop_proxy.get())); + new ServiceUtilityProcessHost(this, client_task_runner.get())); // TODO(gene): For now we disabling autorotation for CloudPrinting. // Landscape/Portrait setting is passed in the print ticket and // server is generating portrait PDF always. @@ -441,7 +440,7 @@ class JobSpoolerWin : public PrintSystem::JobSpooler { // The object will self-destruct when the child process dies. utility_host.release(); } else { - client_message_loop_proxy->PostTask( + client_task_runner->PostTask( FROM_HERE, base::Bind(&Core::PrintJobDone, this, false)); } } @@ -555,53 +554,51 @@ class PrinterCapsHandler : public ServiceUtilityProcessHost::Client { } void StartGetPrinterCapsAndDefaults() { - g_service_process->io_thread()->message_loop_proxy()->PostTask( + g_service_process->io_thread()->task_runner()->PostTask( FROM_HERE, base::Bind(&PrinterCapsHandler::GetPrinterCapsAndDefaultsImpl, this, - base::MessageLoopProxy::current())); + base::ThreadTaskRunnerHandle::Get())); } void StartGetPrinterSemanticCapsAndDefaults() { - g_service_process->io_thread()->message_loop_proxy()->PostTask( + g_service_process->io_thread()->task_runner()->PostTask( FROM_HERE, base::Bind(&PrinterCapsHandler::GetPrinterSemanticCapsAndDefaultsImpl, - this, base::MessageLoopProxy::current())); + this, base::ThreadTaskRunnerHandle::Get())); } private: ~PrinterCapsHandler() override {} void GetPrinterCapsAndDefaultsImpl( - const scoped_refptr<base::MessageLoopProxy>& - client_message_loop_proxy) { - DCHECK(g_service_process->io_thread()->message_loop_proxy()-> - BelongsToCurrentThread()); + const scoped_refptr<base::SingleThreadTaskRunner>& client_task_runner) { + DCHECK(g_service_process->io_thread() + ->task_runner() + ->BelongsToCurrentThread()); scoped_ptr<ServiceUtilityProcessHost> utility_host( - new ServiceUtilityProcessHost(this, client_message_loop_proxy.get())); + new ServiceUtilityProcessHost(this, client_task_runner.get())); if (utility_host->StartGetPrinterCapsAndDefaults(printer_name_)) { // The object will self-destruct when the child process dies. utility_host.release(); } else { - client_message_loop_proxy->PostTask( - FROM_HERE, - base::Bind(&PrinterCapsHandler::OnChildDied, this)); + client_task_runner->PostTask( + FROM_HERE, base::Bind(&PrinterCapsHandler::OnChildDied, this)); } } void GetPrinterSemanticCapsAndDefaultsImpl( - const scoped_refptr<base::MessageLoopProxy>& - client_message_loop_proxy) { - DCHECK(g_service_process->io_thread()->message_loop_proxy()-> - BelongsToCurrentThread()); + const scoped_refptr<base::SingleThreadTaskRunner>& client_task_runner) { + DCHECK(g_service_process->io_thread() + ->task_runner() + ->BelongsToCurrentThread()); scoped_ptr<ServiceUtilityProcessHost> utility_host( - new ServiceUtilityProcessHost(this, client_message_loop_proxy.get())); + new ServiceUtilityProcessHost(this, client_task_runner.get())); if (utility_host->StartGetPrinterSemanticCapsAndDefaults(printer_name_)) { // The object will self-destruct when the child process dies. utility_host.release(); } else { - client_message_loop_proxy->PostTask( - FROM_HERE, - base::Bind(&PrinterCapsHandler::OnChildDied, this)); + client_task_runner->PostTask( + FROM_HERE, base::Bind(&PrinterCapsHandler::OnChildDied, this)); } } diff --git a/chrome/service/cloud_print/printer_job_handler.cc b/chrome/service/cloud_print/printer_job_handler.cc index 95dfb55..f57ceb6 100644 --- a/chrome/service/cloud_print/printer_job_handler.cc +++ b/chrome/service/cloud_print/printer_job_handler.cc @@ -8,10 +8,12 @@ #include "base/bind_helpers.h" #include "base/files/file_util.h" #include "base/json/json_reader.h" +#include "base/location.h" #include "base/md5.h" #include "base/metrics/histogram.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/common/cloud_print/cloud_print_constants.h" #include "chrome/common/cloud_print/cloud_print_helpers.h" @@ -72,8 +74,7 @@ PrinterJobHandler::PrinterJobHandler( next_json_data_handler_(NULL), next_data_handler_(NULL), print_thread_("Chrome_CloudPrintJobPrintThread"), - job_handler_message_loop_proxy_( - base::MessageLoopProxy::current()), + job_handler_task_runner_(base::ThreadTaskRunnerHandle::Get()), shutting_down_(false), job_check_pending_(false), printer_update_pending_(true), @@ -106,7 +107,7 @@ void PrinterJobHandler::CheckForJobs(const std::string& reason) { job_fetch_reason_ = reason; job_check_pending_ = true; if (!task_in_progress_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::Start, this)); } } @@ -136,7 +137,7 @@ CloudPrintURLFetcher::ResponseAction PrinterJobHandler::HandleRawResponse( if (next_data_handler_ == (&PrinterJobHandler::HandlePrintDataResponse) && response_code == net::HTTP_UNSUPPORTED_MEDIA_TYPE) { VLOG(1) << "CP_CONNECTOR: Job failed (unsupported media type)"; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::JobFailed, this, JOB_DOWNLOAD_FAILED)); return CloudPrintURLFetcher::STOP_PROCESSING; @@ -167,12 +168,12 @@ void PrinterJobHandler::OnRequestGiveUp() { if (job_queue_handler_.JobFetchFailed(job_details_.job_id_)) { VLOG(1) << "CP_CONNECTOR: Job failed to load (scheduling retry)"; CheckForJobs(kJobFetchReasonFailure); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); } else { VLOG(1) << "CP_CONNECTOR: Job failed (giving up after " << kNumRetriesBeforeAbandonJob << " retries)"; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::JobFailed, this, JOB_DOWNLOAD_FAILED)); } @@ -213,7 +214,7 @@ bool PrinterJobHandler::OnJobCompleted(JobStatusUpdater* updater) { } void PrinterJobHandler::OnAuthError() { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); if (delegate_) delegate_->OnAuthError(); @@ -227,7 +228,7 @@ void PrinterJobHandler::OnPrinterDeleted() { void PrinterJobHandler::OnPrinterChanged() { printer_update_pending_ = true; if (!task_in_progress_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::Start, this)); } } @@ -237,7 +238,7 @@ void PrinterJobHandler::OnJobChanged() { // and have them check for updates. for (JobStatusUpdaterList::iterator index = job_status_updater_list_.begin(); index != job_status_updater_list_.end(); index++) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&JobStatusUpdater::UpdateStatus, index->get())); } } @@ -247,7 +248,7 @@ void PrinterJobHandler::OnJobSpoolSucceeded(const PlatformJobId& job_id) { job_spooler_->AddRef(); print_thread_.message_loop()->ReleaseSoon(FROM_HERE, job_spooler_.get()); job_spooler_ = NULL; - job_handler_message_loop_proxy_->PostTask( + job_handler_task_runner_->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::JobSpooled, this, job_id)); } @@ -257,7 +258,7 @@ void PrinterJobHandler::OnJobSpoolFailed() { print_thread_.message_loop()->ReleaseSoon(FROM_HERE, job_spooler_.get()); job_spooler_ = NULL; VLOG(1) << "CP_CONNECTOR: Job failed (spool failed)"; - job_handler_message_loop_proxy_->PostTask( + job_handler_task_runner_->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::JobFailed, this, JOB_FAILED)); } @@ -288,7 +289,7 @@ PrinterJobHandler::HandlePrinterUpdateResponse( // We are done here. Go to the Stop state VLOG(1) << "CP_CONNECTOR: Stopping printer job handler" << ", printer id: " << printer_info_cloud_.printer_id; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); return CloudPrintURLFetcher::STOP_PROCESSING; } @@ -329,7 +330,7 @@ PrinterJobHandler::HandleJobMetadataResponse( } } else { job_available = false; - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&PrinterJobHandler::RunScheduledJobCheck, this), jobs[0].time_remaining_); @@ -341,7 +342,7 @@ PrinterJobHandler::HandleJobMetadataResponse( // If no jobs are available, go to the Stop state. VLOG(1) << "CP_CONNECTOR: Stopping printer job handler" << ", printer id: " << printer_info_cloud_.printer_id; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); } return CloudPrintURLFetcher::STOP_PROCESSING; @@ -403,9 +404,9 @@ PrinterJobHandler::HandlePrintDataResponse(const net::URLFetcher* source, // here. VLOG(1) << "CP_CONNECTOR: Error saving print data" << ", printer id: " << printer_info_cloud_.printer_id; - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&PrinterJobHandler::JobFailed, this, - JOB_DOWNLOAD_FAILED)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::Bind(&PrinterJobHandler::JobFailed, this, JOB_DOWNLOAD_FAILED)); return CloudPrintURLFetcher::STOP_PROCESSING; } @@ -417,7 +418,7 @@ PrinterJobHandler::HandleInProgressStatusUpdateResponse( bool succeeded) { VLOG(1) << "CP_CONNECTOR: Handling success status update response" << ", printer id: " << printer_info_cloud_.printer_id; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::StartPrinting, this)); return CloudPrintURLFetcher::STOP_PROCESSING; } @@ -430,7 +431,7 @@ PrinterJobHandler::HandleFailureStatusUpdateResponse( bool succeeded) { VLOG(1) << "CP_CONNECTOR: Handling failure status update response" << ", printer id: " << printer_info_cloud_.printer_id; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); return CloudPrintURLFetcher::STOP_PROCESSING; } @@ -499,7 +500,7 @@ void PrinterJobHandler::Stop() { << ", task in progress: " << task_in_progress_; Reset(); if (HavePendingTasks()) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::Start, this)); } } @@ -520,7 +521,7 @@ void PrinterJobHandler::StartPrinting() { << ", printer id: " << printer_info_cloud_.printer_id; JobFailed(JOB_FAILED); } else { - print_thread_.message_loop()->PostTask( + print_thread_.task_runner()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::DoPrint, this, job_details_, printer_info_.printer_name)); } @@ -619,7 +620,7 @@ void PrinterJobHandler::JobSpooled(PlatformJobId local_job_id) { local_job_id_, cloud_print_server_url_, print_system_.get(), this)); job_status_updater_list_.push_back(job_status_updater); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&JobStatusUpdater::UpdateStatus, job_status_updater.get())); @@ -627,7 +628,7 @@ void PrinterJobHandler::JobSpooled(PlatformJobId local_job_id) { VLOG(1) << "CP_CONNECTOR: Stopping printer job handler" << ", printer id: " << printer_info_cloud_.printer_id; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); } @@ -774,13 +775,13 @@ void PrinterJobHandler::OnReceivePrinterCaps( // We are done here. Go to the Stop state VLOG(1) << "CP_CONNECTOR: Stopping printer job handler" << ", printer name: " << printer_name; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::Stop, this)); } } // The following methods are called on |print_thread_|. It is not safe to -// access any members other than |job_handler_message_loop_proxy_|, +// access any members other than |job_handler_task_runner_|, // |job_spooler_| and |print_system_|. void PrinterJobHandler::DoPrint(const JobDetails& job_details, const std::string& printer_name) { diff --git a/chrome/service/cloud_print/printer_job_handler.h b/chrome/service/cloud_print/printer_job_handler.h index 304e2bc..c49ee45 100644 --- a/chrome/service/cloud_print/printer_job_handler.h +++ b/chrome/service/cloud_print/printer_job_handler.h @@ -12,7 +12,7 @@ #include "base/files/file_path.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "base/threading/thread.h" #include "base/time/time.h" #include "chrome/service/cloud_print/cloud_print_url_fetcher.h" @@ -275,7 +275,7 @@ class PrinterJobHandler : public base::RefCountedThreadSafe<PrinterJobHandler>, scoped_refptr<PrintSystem::JobSpooler> job_spooler_; // The message loop proxy representing the thread on which this object // was created. Used by the print thread. - scoped_refptr<base::MessageLoopProxy> job_handler_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> job_handler_task_runner_; // There may be pending tasks in the message queue when Shutdown is called. // We set this flag so as to do nothing in those tasks. diff --git a/chrome/service/cloud_print/printer_job_handler_unittest.cc b/chrome/service/cloud_print/printer_job_handler_unittest.cc index a7147ef..da396dd 100644 --- a/chrome/service/cloud_print/printer_job_handler_unittest.cc +++ b/chrome/service/cloud_print/printer_job_handler_unittest.cc @@ -3,12 +3,14 @@ // found in the LICENSE file. #include "base/files/file_path.h" +#include "base/location.h" #include "base/md5.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" +#include "base/thread_task_runner_handle.h" #include "chrome/common/cloud_print/cloud_print_constants.h" #include "chrome/service/cloud_print/cloud_print_service_helpers.h" #include "chrome/service/cloud_print/cloud_print_token_store.h" @@ -247,9 +249,10 @@ std::string StatusResponse(int job_num, const char* status_string) { class CloudPrintURLFetcherNoServiceProcess : public CloudPrintURLFetcher { public: - CloudPrintURLFetcherNoServiceProcess() : - context_getter_(new net::TestURLRequestContextGetter( - base::MessageLoopProxy::current())) {} + CloudPrintURLFetcherNoServiceProcess() + : context_getter_(new net::TestURLRequestContextGetter( + base::ThreadTaskRunnerHandle::Get())) {} + protected: net::URLRequestContextGetter* GetRequestContextGetter() override { return context_getter_.get(); @@ -522,7 +525,7 @@ void PrinterJobHandlerTest::MessageLoopQuitNowHelper( void PrinterJobHandlerTest::MessageLoopQuitSoonHelper( base::MessageLoop* message_loop) { - message_loop->message_loop_proxy()->PostTask( + message_loop->task_runner()->PostTask( FROM_HERE, base::Bind(&MessageLoopQuitNowHelper, message_loop)); } @@ -532,14 +535,14 @@ PrinterJobHandlerTest::PrinterJobHandlerTest() } bool PrinterJobHandlerTest::PostSpoolSuccess() { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PrinterJobHandler::OnJobSpoolSucceeded, job_handler_, 0)); // Everything that would be posted on the printer thread queue // has been posted, we can tell the main message loop to quit when idle // and not worry about it idling while the print thread does work - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&MessageLoopQuitSoonHelper, &loop_)); return true; } @@ -769,15 +772,12 @@ TEST_F(PrinterJobHandlerTest, DISABLED_ManyFailureTest) { net::HTTP_INTERNAL_SERVER_ERROR, net::URLRequestStatus::FAILED); - loop_.PostDelayedTask(FROM_HERE, - base::Bind(&net::FakeURLFetcherFactory::SetFakeResponse, - base::Unretained(&factory_), - TicketURI(1), - kExamplePrintTicket, - net::HTTP_OK, - net::URLRequestStatus::SUCCESS), - base::TimeDelta::FromSeconds(1)); - + loop_.task_runner()->PostDelayedTask( + FROM_HERE, + base::Bind(&net::FakeURLFetcherFactory::SetFakeResponse, + base::Unretained(&factory_), TicketURI(1), kExamplePrintTicket, + net::HTTP_OK, net::URLRequestStatus::SUCCESS), + base::TimeDelta::FromSeconds(1)); BeginTest(5); } diff --git a/chrome/service/net/service_url_request_context_getter.cc b/chrome/service/net/service_url_request_context_getter.cc index cd75264..3dfbd2b 100644 --- a/chrome/service/net/service_url_request_context_getter.cc +++ b/chrome/service/net/service_url_request_context_getter.cc @@ -9,7 +9,7 @@ #endif #include "base/compiler_specific.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/sys_info.h" #include "chrome/common/chrome_version_info.h" @@ -96,14 +96,13 @@ std::string MakeUserAgentForServiceProcess() { ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() : user_agent_(MakeUserAgentForServiceProcess()), - network_task_runner_( - g_service_process->io_thread()->message_loop_proxy()) { + network_task_runner_(g_service_process->io_thread()->task_runner()) { // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a - // MessageLoopProxy* instead of MessageLoop*. + // SingleThreadTaskRunner* instead of MessageLoop*. DCHECK(g_service_process); proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService( - g_service_process->io_thread()->message_loop_proxy(), - g_service_process->file_thread()->message_loop_proxy())); + g_service_process->io_thread()->task_runner(), + g_service_process->file_thread()->task_runner())); } net::URLRequestContext* diff --git a/chrome/service/net/service_url_request_context_getter.h b/chrome/service/net/service_url_request_context_getter.h index cd50265..caf439c 100644 --- a/chrome/service/net/service_url_request_context_getter.h +++ b/chrome/service/net/service_url_request_context_getter.h @@ -21,7 +21,7 @@ #include "net/url_request/url_request_context_storage.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } namespace net { diff --git a/chrome/service/service_ipc_server.cc b/chrome/service/service_ipc_server.cc index 3265b9e..4558242 100644 --- a/chrome/service/service_ipc_server.cc +++ b/chrome/service/service_ipc_server.cc @@ -27,11 +27,8 @@ bool ServiceIPCServer::Init() { void ServiceIPCServer::CreateChannel() { channel_.reset(NULL); // Tear down the existing channel, if any. channel_ = IPC::SyncChannel::Create( - channel_handle_, - IPC::Channel::MODE_NAMED_SERVER, - this, - g_service_process->io_thread()->message_loop_proxy().get(), - true, + channel_handle_, IPC::Channel::MODE_NAMED_SERVER, this, + g_service_process->io_thread()->task_runner().get(), true, g_service_process->shutdown_event()); DCHECK(sync_message_filter_.get()); channel_->AddFilter(sync_message_filter_.get()); diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc index 3bed9fe..79d3ba0 100644 --- a/chrome/service/service_process.cc +++ b/chrome/service/service_process.cc @@ -11,11 +11,14 @@ #include "base/command_line.h" #include "base/environment.h" #include "base/i18n/rtl.h" +#include "base/location.h" #include "base/memory/singleton.h" #include "base/path_service.h" #include "base/prefs/json_pref_store.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/values.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" @@ -193,7 +196,7 @@ bool ServiceProcess::Initialize(base::MessageLoopForUI* message_loop, // After the IPC server has started we signal that the service process is // ready. if (!service_process_state_->SignalReady( - io_thread_->message_loop_proxy().get(), + io_thread_->task_runner().get(), base::Bind(&ServiceProcess::Terminate, base::Unretained(this)))) { return false; } @@ -253,7 +256,8 @@ void ServiceProcess::Shutdown() { } void ServiceProcess::Terminate() { - main_message_loop_->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); + main_message_loop_->task_runner()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); } bool ServiceProcess::HandleClientDisconnect() { @@ -325,7 +329,7 @@ void ServiceProcess::OnServiceDisabled() { } void ServiceProcess::ScheduleShutdownCheck() { - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&ServiceProcess::ShutdownIfNeeded, base::Unretained(this)), base::TimeDelta::FromSeconds(kShutdownDelaySeconds)); diff --git a/chrome/service/service_process.h b/chrome/service/service_process.h index d5942d4..8f2aa4c 100644 --- a/chrome/service/service_process.h +++ b/chrome/service/service_process.h @@ -46,17 +46,17 @@ class ServiceProcess : public cloud_print::CloudPrintProxy::Client { bool Teardown(); // TODO(sanjeevr): Change various parts of the code such as // net::ProxyService::CreateSystemProxyConfigService to take in - // MessageLoopProxy* instead of MessageLoop*. When we have done that, we can - // remove the io_thread() and file_thread() accessors and replace them with - // io_message_loop_proxy() and file_message_loop_proxy() respectively. + // SingleThreadTaskRunner* instead of MessageLoop*. When we have done that, + // we can remove the io_thread() and file_thread() accessors and replace them + // with io_message_loop_proxy() and file_message_loop_proxy() respectively. // Returns the thread that we perform I/O coordination on (network requests, // communication with renderers, etc. // NOTE: You should ONLY use this to pass to IPC or other objects which must // need a MessageLoop*. If you just want to post a task, use the thread's - // message_loop_proxy() as it takes care of checking that a thread is still - // alive, race conditions, lifetime differences etc. - // If you still must use this, need to check the return value for NULL. + // task_runner() as it takes care of checking that a thread is still alive, + // race conditions, lifetime differences etc. If you still must use this, + // need to check the return value for NULL. base::Thread* io_thread() const { return io_thread_.get(); } diff --git a/chrome/service/service_process_prefs.cc b/chrome/service/service_process_prefs.cc index 7f43943..7c69470 100644 --- a/chrome/service/service_process_prefs.cc +++ b/chrome/service/service_process_prefs.cc @@ -4,8 +4,8 @@ #include "chrome/service/service_process_prefs.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/prefs/pref_filter.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" ServiceProcessPrefs::ServiceProcessPrefs( diff --git a/chrome/service/service_process_prefs_unittest.cc b/chrome/service/service_process_prefs_unittest.cc index 73284ca..ed5ad04 100644 --- a/chrome/service/service_process_prefs_unittest.cc +++ b/chrome/service/service_process_prefs_unittest.cc @@ -18,7 +18,7 @@ class ServiceProcessPrefsTest : public testing::Test { prefs_.reset(new ServiceProcessPrefs( temp_dir_.path().AppendASCII("service_process_prefs.txt"), - message_loop_.message_loop_proxy().get())); + message_loop_.task_runner().get())); } void TearDown() override { prefs_.reset(); } diff --git a/chrome/service/service_utility_process_host.cc b/chrome/service/service_utility_process_host.cc index 765a430..42a5a53 100644 --- a/chrome/service/service_utility_process_host.cc +++ b/chrome/service/service_utility_process_host.cc @@ -13,10 +13,10 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/histogram.h" #include "base/process/launch.h" #include "base/task_runner_util.h" +#include "base/thread_task_runner_handle.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_utility_printing_messages.h" #include "content/public/common/child_process_host.h" @@ -150,9 +150,9 @@ class ServiceUtilityProcessHost::PdfToEmfState { ServiceUtilityProcessHost::ServiceUtilityProcessHost( Client* client, - base::MessageLoopProxy* client_message_loop_proxy) + base::SingleThreadTaskRunner* client_task_runner) : client_(client), - client_message_loop_proxy_(client_message_loop_proxy), + client_task_runner_(client_task_runner), waiting_for_reply_(false), weak_ptr_factory_(this) { child_process_host_.reset(ChildProcessHost::Create(this)); @@ -258,7 +258,7 @@ void ServiceUtilityProcessHost::OnChildDisconnected() { if (waiting_for_reply_) { // If we are yet to receive a reply then notify the client that the // child died. - client_message_loop_proxy_->PostTask( + client_task_runner_->PostTask( FROM_HERE, base::Bind(&Client::OnChildDied, client_.get())); ReportUmaEvent(SERVICE_UTILITY_DISCONNECTED); UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityDisconnectTime", @@ -319,7 +319,7 @@ void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafilesPageDone( return OnPDFToEmfFinished(false); base::File emf_file = pdf_to_emf_state_->TakeNextFile(); base::PostTaskAndReplyWithResult( - client_message_loop_proxy_.get(), FROM_HERE, + client_task_runner_.get(), FROM_HERE, base::Bind(&Client::MetafileAvailable, client_.get(), scale_factor, base::Passed(&emf_file)), base::Bind(&ServiceUtilityProcessHost::OnMetafileSpooled, @@ -339,10 +339,9 @@ void ServiceUtilityProcessHost::OnPDFToEmfFinished(bool success) { UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileFailTime", base::Time::Now() - start_time_); } - client_message_loop_proxy_->PostTask( - FROM_HERE, - base::Bind( - &Client::OnRenderPDFPagesToMetafileDone, client_.get(), success)); + client_task_runner_->PostTask( + FROM_HERE, base::Bind(&Client::OnRenderPDFPagesToMetafileDone, + client_.get(), success)); pdf_to_emf_state_.reset(); } @@ -354,10 +353,9 @@ void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsSucceeded( UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsTime", base::Time::Now() - start_time_); waiting_for_reply_ = false; - client_message_loop_proxy_->PostTask( - FROM_HERE, - base::Bind(&Client::OnGetPrinterCapsAndDefaults, client_.get(), true, - printer_name, caps_and_defaults)); + client_task_runner_->PostTask( + FROM_HERE, base::Bind(&Client::OnGetPrinterCapsAndDefaults, client_.get(), + true, printer_name, caps_and_defaults)); } void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsSucceeded( @@ -368,7 +366,7 @@ void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsSucceeded( UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilitySemanticCapsTime", base::Time::Now() - start_time_); waiting_for_reply_ = false; - client_message_loop_proxy_->PostTask( + client_task_runner_->PostTask( FROM_HERE, base::Bind(&Client::OnGetPrinterSemanticCapsAndDefaults, client_.get(), true, printer_name, caps_and_defaults)); @@ -381,7 +379,7 @@ void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsFailed( UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsFailTime", base::Time::Now() - start_time_); waiting_for_reply_ = false; - client_message_loop_proxy_->PostTask( + client_task_runner_->PostTask( FROM_HERE, base::Bind(&Client::OnGetPrinterCapsAndDefaults, client_.get(), false, printer_name, printing::PrinterCapsAndDefaults())); @@ -394,11 +392,10 @@ void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsFailed( UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilitySemanticCapsFailTime", base::Time::Now() - start_time_); waiting_for_reply_ = false; - client_message_loop_proxy_->PostTask( - FROM_HERE, - base::Bind(&Client::OnGetPrinterSemanticCapsAndDefaults, - client_.get(), false, printer_name, - printing::PrinterSemanticCapsAndDefaults())); + client_task_runner_->PostTask( + FROM_HERE, base::Bind(&Client::OnGetPrinterSemanticCapsAndDefaults, + client_.get(), false, printer_name, + printing::PrinterSemanticCapsAndDefaults())); } bool ServiceUtilityProcessHost::Client::MetafileAvailable(float scale_factor, diff --git a/chrome/service/service_utility_process_host.h b/chrome/service/service_utility_process_host.h index a69c7ac..18b561e 100644 --- a/chrome/service/service_utility_process_host.h +++ b/chrome/service/service_utility_process_host.h @@ -17,7 +17,6 @@ namespace base { class CommandLine; class File; class FilePath; -class MessageLoopProxy; class ScopedTempDir; } // namespace base @@ -84,7 +83,7 @@ class ServiceUtilityProcessHost : public content::ChildProcessHostDelegate { }; ServiceUtilityProcessHost(Client* client, - base::MessageLoopProxy* client_message_loop_proxy); + base::SingleThreadTaskRunner* client_task_runner); ~ServiceUtilityProcessHost() override; // Starts a process to render the specified pages in the given PDF file into @@ -146,7 +145,7 @@ class ServiceUtilityProcessHost : public content::ChildProcessHostDelegate { base::Process process_; // A pointer to our client interface, who will be informed of progress. scoped_refptr<Client> client_; - scoped_refptr<base::MessageLoopProxy> client_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_; bool waiting_for_reply_; // Start time of operation. diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc index 245c9b9..b9e4203 100644 --- a/chrome/test/base/browser_with_test_window_test.cc +++ b/chrome/test/base/browser_with_test_window_test.cc @@ -4,7 +4,10 @@ #include "chrome/test/base/browser_with_test_window_test.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 "chrome/browser/profiles/profile_destroyer.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_navigator.h" @@ -117,8 +120,8 @@ void BrowserWithTestWindowTest::TearDown() { // A Task is leaked if we don't destroy everything, then run the message // loop. - base::MessageLoop::current()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::MessageLoop::QuitClosure()); base::MessageLoop::current()->Run(); #if defined(TOOLKIT_VIEWS) diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc index 8c09bcc..cb63fb1 100644 --- a/chrome/test/base/in_process_browser_test.cc +++ b/chrome/test/base/in_process_browser_test.cc @@ -11,9 +11,12 @@ #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/lazy_instance.h" +#include "base/location.h" #include "base/path_service.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 "base/threading/non_thread_safe.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/lifetime/application_lifetime.h" @@ -576,8 +579,8 @@ void InProcessBrowserTest::QuitBrowsers() { // Invoke AttemptExit on a running message loop. // AttemptExit exits the message loop after everything has been // shut down properly. - base::MessageLoopForUI::current()->PostTask(FROM_HERE, - base::Bind(&chrome::AttemptExit)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&chrome::AttemptExit)); content::RunMessageLoop(); #if defined(OS_MACOSX) diff --git a/chrome/test/base/testing_io_thread_state.cc b/chrome/test/base/testing_io_thread_state.cc index 30b9069..8ebd202 100644 --- a/chrome/test/base/testing_io_thread_state.cc +++ b/chrome/test/base/testing_io_thread_state.cc @@ -4,8 +4,10 @@ #include "chrome/test/base/testing_io_thread_state.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/time/tick_clock.h" #include "chrome/browser/io_thread.h" #include "chrome/test/base/testing_browser_process.h" @@ -26,9 +28,8 @@ base::Closure ThreadSafeQuit(base::RunLoop* run_loop) { } else { using base::Bind; using base::IgnoreResult; - return Bind(IgnoreResult(&base::MessageLoopProxy::PostTask), - base::MessageLoopProxy::current(), - FROM_HERE, + return Bind(IgnoreResult(&base::SingleThreadTaskRunner::PostTask), + base::ThreadTaskRunnerHandle::Get(), FROM_HERE, run_loop->QuitClosure()); } } diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index 0497fbd..32da645 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -7,11 +7,13 @@ #include "base/base_paths.h" #include "base/command_line.h" #include "base/files/file_util.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" #include "base/path_service.h" #include "base/prefs/testing_pref_store.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" +#include "base/thread_task_runner_handle.h" #include "chrome/browser/autocomplete/autocomplete_classifier.h" #include "chrome/browser/autocomplete/in_memory_url_index.h" #include "chrome/browser/autocomplete/in_memory_url_index_factory.h" @@ -319,7 +321,7 @@ TestingProfile::TestingProfile(const base::FilePath& path, delegate_(delegate) { Init(); if (delegate_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&TestingProfile::FinishInit, base::Unretained(this))); } else { @@ -376,7 +378,7 @@ TestingProfile::TestingProfile( // TODO(atwilson): See if this is still required once we convert the current // users of the constructor that takes a Delegate* param. if (delegate_) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&TestingProfile::FinishInit, base::Unretained(this))); } else { @@ -596,8 +598,8 @@ void TestingProfile::DestroyHistoryService() { // Make sure we don't have any event pending that could disrupt the next // test. - base::MessageLoop::current()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::MessageLoop::QuitClosure()); base::MessageLoop::current()->Run(); } @@ -654,7 +656,7 @@ scoped_ptr<content::ZoomLevelDelegate> TestingProfile::CreateZoomLevelDelegate( } scoped_refptr<base::SequencedTaskRunner> TestingProfile::GetIOTaskRunner() { - return base::MessageLoop::current()->message_loop_proxy(); + return base::MessageLoop::current()->task_runner(); } TestingPrefServiceSyncable* TestingProfile::GetTestingPrefService() { diff --git a/chrome/test/base/tracing_browsertest.cc b/chrome/test/base/tracing_browsertest.cc index e6128a3..3ebc610 100644 --- a/chrome/test/base/tracing_browsertest.cc +++ b/chrome/test/base/tracing_browsertest.cc @@ -4,8 +4,10 @@ #include "chrome/test/base/tracing.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -56,7 +58,8 @@ IN_PROC_BROWSER_TEST_F(TracingBrowserTest, BeginTracingWithWatch) { // One event after wait. ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 1)); - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&AddEvents, 1)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(&AddEvents, 1)); EXPECT_TRUE(WaitForWatchEvent(no_timeout)); ASSERT_TRUE(EndTracing(&json_events)); @@ -74,7 +77,8 @@ IN_PROC_BROWSER_TEST_F(TracingBrowserTest, BeginTracingWithWatch) { // Multi event after wait. ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 5)); - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&AddEvents, 5)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(&AddEvents, 5)); EXPECT_TRUE(WaitForWatchEvent(no_timeout)); ASSERT_TRUE(EndTracing(&json_events)); diff --git a/chrome/test/base/view_event_test_base.cc b/chrome/test/base/view_event_test_base.cc index 34c6eda..1262582 100644 --- a/chrome/test/base/view_event_test_base.cc +++ b/chrome/test/base/view_event_test_base.cc @@ -5,7 +5,9 @@ #include "chrome/test/base/view_event_test_base.h" #include "base/bind.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "chrome/test/base/chrome_unit_test_suite.h" #include "chrome/test/base/interactive_test_utils.h" #include "chrome/test/base/testing_browser_process.h" @@ -135,7 +137,7 @@ void ViewEventTestBase::StartMessageLoopAndRunTest() { // Schedule a task that starts the test. Need to do this as we're going to // run the message loop. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&ViewEventTestBase::DoTestOnMessageLoop, this)); content::RunThisRunLoop(&run_loop_); @@ -150,7 +152,7 @@ void ViewEventTestBase::ScheduleMouseMoveInBackground(int x, int y) { dnd_thread_.reset(new base::Thread("mouse-move-thread")); dnd_thread_->Start(); } - dnd_thread_->message_loop()->PostDelayedTask( + dnd_thread_->task_runner()->PostDelayedTask( FROM_HERE, base::Bind(base::IgnoreResult(&ui_controls::SendMouseMove), x, y), base::TimeDelta::FromMilliseconds(kMouseMoveDelayMS)); diff --git a/chrome/test/chromedriver/chrome/adb_impl.h b/chrome/test/chromedriver/chrome/adb_impl.h index 895bd78..5f82dd3 100644 --- a/chrome/test/chromedriver/chrome/adb_impl.h +++ b/chrome/test/chromedriver/chrome/adb_impl.h @@ -21,7 +21,7 @@ class Status; class AdbImpl : public Adb { public: explicit AdbImpl( - const scoped_refptr<base::SingleThreadTaskRunner>& io_message_loop_proxy, + const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, int port); ~AdbImpl() override; diff --git a/chrome/test/chromedriver/commands.cc b/chrome/test/chromedriver/commands.cc index 2a9b794..667d5e9 100644 --- a/chrome/test/chromedriver/commands.cc +++ b/chrome/test/chromedriver/commands.cc @@ -10,13 +10,15 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/linked_ptr.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/strings/stringprintf.h" #include "base/sys_info.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/test/chromedriver/capabilities.h" #include "chrome/test/chromedriver/chrome/browser_info.h" @@ -65,7 +67,7 @@ void ExecuteCreateSession( return; } - thread->message_loop()->PostTask( + thread->task_runner()->PostTask( FROM_HERE, base::Bind(&SetThreadLocalSession, base::Passed(&session))); session_thread_map ->insert(std::make_pair(new_id, make_linked_ptr(thread.release()))); @@ -126,10 +128,8 @@ void ExecuteGetSessions(const Command& session_capabilities_command, run_loop.QuitClosure(), session_list.get())); } - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - run_loop.QuitClosure(), - base::TimeDelta::FromSeconds(10)); + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(10)); base::MessageLoop::current()->SetNestableTasksAllowed(true); run_loop.Run(); @@ -176,7 +176,7 @@ void ExecuteQuitAll( weak_ptr_factory.GetWeakPtr(), run_loop.QuitClosure())); } - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(10)); // Uses a nested run loop to block this thread until all the quit // commands have executed, or the timeout expires. @@ -303,18 +303,13 @@ void ExecuteSessionCommand( Status status(return_ok_without_session ? kOk : kNoSuchSession); callback.Run(status, scoped_ptr<base::Value>(), session_id); } else { - iter->second->message_loop() - ->PostTask(FROM_HERE, - base::Bind(&ExecuteSessionCommandOnSessionThread, - command_name, - command, - return_ok_without_session, + iter->second->task_runner()->PostTask( + FROM_HERE, base::Bind(&ExecuteSessionCommandOnSessionThread, + command_name, command, return_ok_without_session, base::Passed(make_scoped_ptr(params.DeepCopy())), - base::MessageLoopProxy::current(), - callback, + base::ThreadTaskRunnerHandle::Get(), callback, base::Bind(&TerminateSessionThreadOnCommandThread, - session_thread_map, - session_id))); + session_thread_map, session_id))); } } diff --git a/chrome/test/chromedriver/commands_unittest.cc b/chrome/test/chromedriver/commands_unittest.cc index b5320c2..a0e0a5e 100644 --- a/chrome/test/chromedriver/commands_unittest.cc +++ b/chrome/test/chromedriver/commands_unittest.cc @@ -8,9 +8,10 @@ #include "base/callback.h" #include "base/compiler_specific.h" #include "base/files/file_path.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/synchronization/lock.h" #include "base/threading/thread.h" #include "base/values.h" @@ -218,7 +219,7 @@ TEST(CommandsTest, ExecuteSessionCommand) { linked_ptr<base::Thread> thread(new base::Thread("1")); ASSERT_TRUE(thread->Start()); std::string id("id"); - thread->message_loop()->PostTask( + thread->task_runner()->PostTask( FROM_HERE, base::Bind(&internal::CreateSessionOnSessionThreadForTesting, id)); map[id] = thread; @@ -700,7 +701,7 @@ TEST(CommandsTest, SuccessNotifyingCommandListeners) { linked_ptr<base::Thread> thread(new base::Thread("1")); ASSERT_TRUE(thread->Start()); std::string id("id"); - thread->message_loop()->PostTask( + thread->task_runner()->PostTask( FROM_HERE, base::Bind(&internal::CreateSessionOnSessionThreadForTesting, id)); @@ -789,7 +790,7 @@ TEST(CommandsTest, ErrorNotifyingCommandListeners) { linked_ptr<base::Thread> thread(new base::Thread("1")); ASSERT_TRUE(thread->Start()); std::string id("id"); - thread->message_loop()->PostTask( + thread->task_runner()->PostTask( FROM_HERE, base::Bind(&internal::CreateSessionOnSessionThreadForTesting, id)); map[id] = thread; @@ -798,9 +799,8 @@ TEST(CommandsTest, ErrorNotifyingCommandListeners) { // was called before (as opposed to after) command execution. We don't need to // verify this again, so we can just add |listener| with PostTask. CommandListener* listener = new FailingCommandListener(); - thread->message_loop()->PostTask( - FROM_HERE, - base::Bind(&AddListenerToSessionIfSessionExists, listener)); + thread->task_runner()->PostTask( + FROM_HERE, base::Bind(&AddListenerToSessionIfSessionExists, listener)); base::DictionaryValue params; // The command should never be executed if BeforeCommand fails for a listener. @@ -818,7 +818,6 @@ TEST(CommandsTest, ErrorNotifyingCommandListeners) { base::Bind(&OnFailBecauseErrorNotifyingListeners, &run_loop)); run_loop.Run(); - thread->message_loop()->PostTask( - FROM_HERE, - base::Bind(&VerifySessionWasDeleted)); + thread->task_runner()->PostTask(FROM_HERE, + base::Bind(&VerifySessionWasDeleted)); } diff --git a/chrome/test/chromedriver/net/net_util_unittest.cc b/chrome/test/chromedriver/net/net_util_unittest.cc index f0c3534..b976373 100644 --- a/chrome/test/chromedriver/net/net_util_unittest.cc +++ b/chrome/test/chromedriver/net/net_util_unittest.cc @@ -9,7 +9,6 @@ #include "base/location.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/synchronization/waitable_event.h" @@ -34,22 +33,19 @@ class FetchUrlTest : public testing::Test, response_(kSendHello) { base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); CHECK(io_thread_.StartWithOptions(options)); - context_getter_ = new URLRequestContextGetter( - io_thread_.message_loop_proxy()); + context_getter_ = new URLRequestContextGetter(io_thread_.task_runner()); base::WaitableEvent event(false, false); - io_thread_.message_loop_proxy()->PostTask( + io_thread_.task_runner()->PostTask( FROM_HERE, - base::Bind(&FetchUrlTest::InitOnIO, - base::Unretained(this), &event)); + base::Bind(&FetchUrlTest::InitOnIO, base::Unretained(this), &event)); event.Wait(); } ~FetchUrlTest() override { base::WaitableEvent event(false, false); - io_thread_.message_loop_proxy()->PostTask( - FROM_HERE, - base::Bind(&FetchUrlTest::DestroyServerOnIO, - base::Unretained(this), &event)); + io_thread_.task_runner()->PostTask( + FROM_HERE, base::Bind(&FetchUrlTest::DestroyServerOnIO, + base::Unretained(this), &event)); event.Wait(); } diff --git a/chrome/test/chromedriver/net/port_server_unittest.cc b/chrome/test/chromedriver/net/port_server_unittest.cc index c9b88c8..d711710 100644 --- a/chrome/test/chromedriver/net/port_server_unittest.cc +++ b/chrome/test/chromedriver/net/port_server_unittest.cc @@ -7,7 +7,7 @@ #include "base/bind.h" #include "base/guid.h" #include "base/location.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/sync_socket.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" @@ -124,10 +124,9 @@ class PortServerTest : public testing::Test { const std::string& response, std::string* request) { base::WaitableEvent listen_event(false, false); - thread_.message_loop()->PostTask( + thread_.task_runner()->PostTask( FROM_HERE, - base::Bind( - &RunServerOnThread, path, response, &listen_event, request)); + base::Bind(&RunServerOnThread, path, response, &listen_event, request)); ASSERT_TRUE(listen_event.TimedWait(base::TimeDelta::FromSeconds(5))); } diff --git a/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc b/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc index 28b808a..b7d27b5 100644 --- a/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc +++ b/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc @@ -7,7 +7,6 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/single_thread_task_runner.h" #include "base/threading/platform_thread.h" #include "base/threading/thread.h" @@ -30,8 +29,7 @@ class SyncWebSocketImplTest : public testing::Test { void SetUp() override { base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); ASSERT_TRUE(client_thread_.StartWithOptions(options)); - context_getter_ = new URLRequestContextGetter( - client_thread_.message_loop_proxy()); + context_getter_ = new URLRequestContextGetter(client_thread_.task_runner()); ASSERT_TRUE(server_.Start()); } diff --git a/chrome/test/chromedriver/net/test_http_server.cc b/chrome/test/chromedriver/net/test_http_server.cc index 6b8a4bc..a3d8e38 100644 --- a/chrome/test/chromedriver/net/test_http_server.cc +++ b/chrome/test/chromedriver/net/test_http_server.cc @@ -7,7 +7,7 @@ #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/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/time/time.h" #include "net/base/ip_endpoint.h" @@ -36,10 +36,9 @@ bool TestHttpServer::Start() { return false; bool success; base::WaitableEvent event(false, false); - thread_.message_loop_proxy()->PostTask( - FROM_HERE, - base::Bind(&TestHttpServer::StartOnServerThread, - base::Unretained(this), &success, &event)); + thread_.task_runner()->PostTask( + FROM_HERE, base::Bind(&TestHttpServer::StartOnServerThread, + base::Unretained(this), &success, &event)); event.Wait(); return success; } @@ -48,10 +47,9 @@ void TestHttpServer::Stop() { if (!thread_.IsRunning()) return; base::WaitableEvent event(false, false); - thread_.message_loop_proxy()->PostTask( - FROM_HERE, - base::Bind(&TestHttpServer::StopOnServerThread, - base::Unretained(this), &event)); + thread_.task_runner()->PostTask( + FROM_HERE, base::Bind(&TestHttpServer::StopOnServerThread, + base::Unretained(this), &event)); event.Wait(); thread_.Stop(); } diff --git a/chrome/test/chromedriver/net/websocket_unittest.cc b/chrome/test/chromedriver/net/websocket_unittest.cc index 835b240..2922c7f 100644 --- a/chrome/test/chromedriver/net/websocket_unittest.cc +++ b/chrome/test/chromedriver/net/websocket_unittest.cc @@ -11,7 +11,6 @@ #include "base/memory/ref_counted.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 "base/single_thread_task_runner.h" #include "base/threading/thread.h" @@ -31,7 +30,7 @@ void OnConnectFinished(base::RunLoop* run_loop, int* save_error, int error) { void RunPending(base::MessageLoop* loop) { base::RunLoop run_loop; - loop->PostTask(FROM_HERE, run_loop.QuitClosure()); + loop->task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure()); run_loop.Run(); } @@ -92,9 +91,8 @@ class WebSocketTest : public testing::Test { scoped_ptr<WebSocket> sock(new WebSocket(url, listener)); base::RunLoop run_loop; sock->Connect(base::Bind(&OnConnectFinished, &run_loop, &error)); - loop_.PostDelayedTask( - FROM_HERE, run_loop.QuitClosure(), - base::TimeDelta::FromSeconds(10)); + loop_.task_runner()->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), + base::TimeDelta::FromSeconds(10)); run_loop.Run(); if (error == net::OK) return sock.Pass(); @@ -113,9 +111,8 @@ class WebSocketTest : public testing::Test { ASSERT_TRUE(sock->Send(messages[i])); } base::RunLoop run_loop; - loop_.PostDelayedTask( - FROM_HERE, run_loop.QuitClosure(), - base::TimeDelta::FromSeconds(10)); + loop_.task_runner()->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), + base::TimeDelta::FromSeconds(10)); run_loop.Run(); } @@ -163,9 +160,8 @@ TEST_F(WebSocketTest, CloseOnReceive) { scoped_ptr<WebSocket> sock(CreateConnectedWebSocket(&listener)); ASSERT_TRUE(sock); ASSERT_TRUE(sock->Send("hi")); - loop_.PostDelayedTask( - FROM_HERE, run_loop.QuitClosure(), - base::TimeDelta::FromSeconds(10)); + loop_.task_runner()->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), + base::TimeDelta::FromSeconds(10)); run_loop.Run(); } @@ -177,9 +173,8 @@ TEST_F(WebSocketTest, CloseOnSend) { server_.Stop(); sock->Send("hi"); - loop_.PostDelayedTask( - FROM_HERE, run_loop.QuitClosure(), - base::TimeDelta::FromSeconds(10)); + loop_.task_runner()->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), + base::TimeDelta::FromSeconds(10)); run_loop.Run(); ASSERT_FALSE(sock->Send("hi")); } diff --git a/chrome/test/chromedriver/server/chromedriver_server.cc b/chrome/test/chromedriver/server/chromedriver_server.cc index 2d73020..4782eb6 100644 --- a/chrome/test/chromedriver/server/chromedriver_server.cc +++ b/chrome/test/chromedriver/server/chromedriver_server.cc @@ -22,6 +22,7 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/synchronization/waitable_event.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "base/threading/thread_local.h" #include "chrome/test/chromedriver/logging.h" @@ -136,12 +137,10 @@ void HandleRequestOnIOThread( const net::HttpServerRequestInfo& request, const HttpResponseSenderFunc& send_response_func) { cmd_task_runner->PostTask( - FROM_HERE, - base::Bind(handle_request_on_cmd_func, - request, - base::Bind(&SendResponseOnCmdThread, - base::MessageLoopProxy::current(), - send_response_func))); + FROM_HERE, base::Bind(handle_request_on_cmd_func, request, + base::Bind(&SendResponseOnCmdThread, + base::ThreadTaskRunnerHandle::Get(), + send_response_func))); } base::LazyInstance<base::ThreadLocalPointer<HttpServer> > @@ -177,22 +176,16 @@ void RunServer(uint16 port, base::MessageLoop cmd_loop; base::RunLoop cmd_run_loop; - HttpHandler handler(cmd_run_loop.QuitClosure(), - io_thread.message_loop_proxy(), - url_base, - adb_port, - port_server.Pass()); + HttpHandler handler(cmd_run_loop.QuitClosure(), io_thread.task_runner(), + url_base, adb_port, port_server.Pass()); HttpRequestHandlerFunc handle_request_func = base::Bind(&HandleRequestOnCmdThread, &handler, whitelisted_ips); - io_thread.message_loop() - ->PostTask(FROM_HERE, - base::Bind(&StartServerOnIOThread, - port, - allow_remote, - base::Bind(&HandleRequestOnIOThread, - cmd_loop.message_loop_proxy(), - handle_request_func))); + io_thread.message_loop()->PostTask( + FROM_HERE, + base::Bind(&StartServerOnIOThread, port, allow_remote, + base::Bind(&HandleRequestOnIOThread, cmd_loop.task_runner(), + handle_request_func))); // Run the command loop. This loop is quit after the response for a shutdown // request is posted to the IO loop. After the command loop quits, a task // is posted to the IO loop to stop the server. Lastly, the IO thread is diff --git a/chrome/test/chromedriver/server/http_handler.cc b/chrome/test/chromedriver/server/http_handler.cc index 78b2cc0a..32cb7e6 100644 --- a/chrome/test/chromedriver/server/http_handler.cc +++ b/chrome/test/chromedriver/server/http_handler.cc @@ -11,11 +11,11 @@ #include "base/logging.h" // For CHECK macros. #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/sys_info.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/test/chromedriver/alert_commands.h" #include "chrome/test/chromedriver/chrome/adb_impl.h" diff --git a/chrome/test/chromedriver/session_commands.cc b/chrome/test/chromedriver/session_commands.cc index 5c56d82..99f5f02 100644 --- a/chrome/test/chromedriver/session_commands.cc +++ b/chrome/test/chromedriver/session_commands.cc @@ -11,9 +11,9 @@ #include "base/files/file_util.h" #include "base/logging.h" // For CHECK macros. #include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/synchronization/lock.h" #include "base/synchronization/waitable_event.h" +#include "base/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/test/chromedriver/basic_types.h" #include "chrome/test/chromedriver/capabilities.h" diff --git a/chrome/test/ppapi/ppapi_test.cc b/chrome/test/ppapi/ppapi_test.cc index 48d758a..6e9fc03 100644 --- a/chrome/test/ppapi/ppapi_test.cc +++ b/chrome/test/ppapi/ppapi_test.cc @@ -6,9 +6,12 @@ #include "base/command_line.h" #include "base/files/file_util.h" +#include "base/location.h" #include "base/path_service.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "base/thread_task_runner_handle.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" @@ -93,9 +96,9 @@ void PPAPITestBase::InfoBarObserver::Observe( // It's not safe to remove the infobar here, since other observers (e.g. the // InfoBarContainer) may still need to access it. Instead, post a task to // do all necessary infobar manipulation as soon as this call stack returns. - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&InfoBarObserver::VerifyInfoBarState, - base::Unretained(this))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::Bind(&InfoBarObserver::VerifyInfoBarState, base::Unretained(this))); } void PPAPITestBase::InfoBarObserver::VerifyInfoBarState() { diff --git a/chrome/utility/font_cache_handler_win.cc b/chrome/utility/font_cache_handler_win.cc index cd7aa70..cf850c0 100644 --- a/chrome/utility/font_cache_handler_win.cc +++ b/chrome/utility/font_cache_handler_win.cc @@ -29,7 +29,7 @@ bool FontCacheHandler::OnMessageReceived(const IPC::Message& message) { void FontCacheHandler::OnBuildFontCache(const base::FilePath& full_path) { DCHECK(!cache_thread_); - utility_task_runner_ = base::MessageLoop::current()->message_loop_proxy(); + utility_task_runner_ = base::MessageLoop::current()->task_runner(); // Create worker thread for building font cache. cache_thread_.reset(new base::Thread("font_cache_thread")); diff --git a/chrome/utility/image_writer/image_writer.cc b/chrome/utility/image_writer/image_writer.cc index 2a2b8a1..1df1513 100644 --- a/chrome/utility/image_writer/image_writer.cc +++ b/chrome/utility/image_writer/image_writer.cc @@ -4,7 +4,10 @@ #include "chrome/utility/image_writer/image_writer.h" +#include "base/location.h" #include "base/memory/aligned_memory.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "chrome/utility/image_writer/error_messages.h" #include "chrome/utility/image_writer/image_writer_handler.h" #include "content/public/utility/utility_thread.h" @@ -69,7 +72,7 @@ const base::FilePath& ImageWriter::GetImagePath() { return image_path_; } const base::FilePath& ImageWriter::GetDevicePath() { return device_path_; } void ImageWriter::PostTask(const base::Closure& task) { - base::MessageLoop::current()->PostTask(FROM_HERE, task); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); } void ImageWriter::PostProgress(int64 progress) { diff --git a/chrome/utility/local_discovery/service_discovery_message_handler.cc b/chrome/utility/local_discovery/service_discovery_message_handler.cc index 3110c94..429257a 100644 --- a/chrome/utility/local_discovery/service_discovery_message_handler.cc +++ b/chrome/utility/local_discovery/service_discovery_message_handler.cc @@ -7,6 +7,8 @@ #include <algorithm> #include "base/lazy_instance.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "chrome/common/local_discovery/local_discovery_messages.h" #include "chrome/common/local_discovery/service_discovery_client_impl.h" #include "content/public/utility/utility_thread.h" @@ -202,11 +204,11 @@ bool ServiceDiscoveryMessageHandler::InitializeThread() { return true; if (discovery_thread_) return false; - utility_task_runner_ = base::MessageLoop::current()->message_loop_proxy(); + utility_task_runner_ = base::MessageLoop::current()->task_runner(); discovery_thread_.reset(new base::Thread("ServiceDiscoveryThread")); base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); if (discovery_thread_->StartWithOptions(thread_options)) { - discovery_task_runner_ = discovery_thread_->message_loop_proxy(); + discovery_task_runner_ = discovery_thread_->task_runner(); discovery_task_runner_->PostTask(FROM_HERE, base::Bind(&ServiceDiscoveryMessageHandler::InitializeMdns, base::Unretained(this))); diff --git a/chrome/utility/media_galleries/media_metadata_parser.cc b/chrome/utility/media_galleries/media_metadata_parser.cc index dbce009..c5da99e 100644 --- a/chrome/utility/media_galleries/media_metadata_parser.cc +++ b/chrome/utility/media_galleries/media_metadata_parser.cc @@ -7,8 +7,8 @@ #include <string> #include "base/bind.h" +#include "base/location.h" #include "base/memory/linked_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/strings/string_util.h" #include "base/task_runner_util.h" #include "base/threading/thread.h" @@ -175,10 +175,9 @@ void MediaMetadataParser::Start(const MetadataCallback& callback) { media_thread_.reset(new base::Thread("media_thread")); CHECK(media_thread_->Start()); - media_thread_->message_loop_proxy()->PostTaskAndReply( - FROM_HERE, - base::Bind(&ParseAudioVideoMetadata, source_, get_attached_images_, - metadata, attached_images), + media_thread_->task_runner()->PostTaskAndReply( + FROM_HERE, base::Bind(&ParseAudioVideoMetadata, source_, + get_attached_images_, metadata, attached_images), base::Bind(&FinishParseAudioVideoMetadata, callback, base::Owned(metadata), base::Owned(attached_images))); return; diff --git a/chrome/utility/profile_import_handler.cc b/chrome/utility/profile_import_handler.cc index 30941e5..62ad739 100644 --- a/chrome/utility/profile_import_handler.cc +++ b/chrome/utility/profile_import_handler.cc @@ -5,7 +5,9 @@ #include "chrome/utility/profile_import_handler.h" #include "base/bind.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/threading/thread.h" #include "chrome/common/importer/profile_import_process_messages.h" @@ -64,7 +66,7 @@ void ProfileImportHandler::OnImportStart( NOTREACHED(); ImporterCleanup(); } - import_thread_->message_loop()->PostTask( + import_thread_->task_runner()->PostTask( FROM_HERE, base::Bind(&Importer::StartImport, importer_.get(), source_profile, items, bridge_)); } |