diff options
author | skyostil <skyostil@chromium.org> | 2015-05-27 08:40:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-27 15:41:28 +0000 |
commit | 2d3b5bd3338ffe8ceb6a9691fb7cd2a6388aba8a (patch) | |
tree | e9d6c041a19e9bd79066c92ff1d071ae6d0fccac | |
parent | 0fe6e09efc3b889bc740aeb175537929020f6754 (diff) | |
download | chromium_src-2d3b5bd3338ffe8ceb6a9691fb7cd2a6388aba8a.zip chromium_src-2d3b5bd3338ffe8ceb6a9691fb7cd2a6388aba8a.tar.gz chromium_src-2d3b5bd3338ffe8ceb6a9691fb7cd2a6388aba8a.tar.bz2 |
content/renderer: 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/1144023007
Cr-Commit-Position: refs/heads/master@{#331576}
106 files changed, 591 insertions, 583 deletions
diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc index 8541d15..bf1cff2 100644 --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc @@ -6,6 +6,7 @@ #include "base/command_line.h" #include "base/observer_list.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/android/in_process/context_provider_in_process.h" #include "content/browser/android/in_process/synchronous_compositor_external_begin_frame_source.h" #include "content/browser/android/in_process/synchronous_compositor_impl.h" @@ -128,8 +129,8 @@ SynchronousCompositorFactoryImpl::SynchronousCompositorFactoryImpl() SynchronousCompositorFactoryImpl::~SynchronousCompositorFactoryImpl() {} -scoped_refptr<base::MessageLoopProxy> -SynchronousCompositorFactoryImpl::GetCompositorMessageLoop() { +scoped_refptr<base::SingleThreadTaskRunner> +SynchronousCompositorFactoryImpl::GetCompositorTaskRunner() { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); } @@ -209,8 +210,8 @@ SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D( void SynchronousCompositorFactoryImpl::CompositorInitializedHardwareDraw() { base::AutoLock lock(num_hardware_compositor_lock_); num_hardware_compositors_++; - if (num_hardware_compositors_ == 1 && main_thread_proxy_.get()) { - main_thread_proxy_->PostTask( + if (num_hardware_compositors_ == 1 && main_thread_task_runner_.get()) { + main_thread_task_runner_->PostTask( FROM_HERE, base::Bind( &SynchronousCompositorFactoryImpl::RestoreContextOnMainThread, @@ -238,7 +239,7 @@ scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() { { base::AutoLock lock(num_hardware_compositor_lock_); - main_thread_proxy_ = base::MessageLoopProxy::current(); + main_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get(); } // Always fail creation even if |video_context_provider_| is not NULL. diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.h b/content/browser/android/in_process/synchronous_compositor_factory_impl.h index 81a4930..01b8b32 100644 --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.h +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.h @@ -28,7 +28,8 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory { ~SynchronousCompositorFactoryImpl() override; // SynchronousCompositorFactory - scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop() override; + scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner() + override; bool RecordFullLayer() override; scoped_ptr<cc::OutputSurface> CreateOutputSurface( int routing_id, @@ -78,7 +79,7 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory { // read on renderer main thread. base::Lock num_hardware_compositor_lock_; unsigned int num_hardware_compositors_; - scoped_refptr<base::MessageLoopProxy> main_thread_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; }; } // namespace content diff --git a/content/renderer/accessibility/renderer_accessibility.cc b/content/renderer/accessibility/renderer_accessibility.cc index 8e3b41c..609348f 100644 --- a/content/renderer/accessibility/renderer_accessibility.cc +++ b/content/renderer/accessibility/renderer_accessibility.cc @@ -7,8 +7,10 @@ #include <queue> #include "base/bind.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/renderer/accessibility/blink_ax_enum_conversion.h" #include "content/renderer/render_frame_impl.h" #include "content/renderer/render_view_impl.h" @@ -193,7 +195,7 @@ void RendererAccessibility::HandleAXEvent( // When no accessibility events are in-flight post a task to send // the events to the browser. We use PostTask so that we can queue // up additional events. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&RendererAccessibility::SendPendingAccessibilityEvents, weak_factory_.GetWeakPtr())); diff --git a/content/renderer/android/synchronous_compositor_factory.h b/content/renderer/android/synchronous_compositor_factory.h index 7906f5f..6c238a0 100644 --- a/content/renderer/android/synchronous_compositor_factory.h +++ b/content/renderer/android/synchronous_compositor_factory.h @@ -10,7 +10,7 @@ #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } namespace cc { @@ -44,8 +44,8 @@ class SynchronousCompositorFactory { static void SetInstance(SynchronousCompositorFactory* instance); static SynchronousCompositorFactory* GetInstance(); - virtual scoped_refptr<base::MessageLoopProxy> - GetCompositorMessageLoop() = 0; + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetCompositorTaskRunner() = 0; virtual bool RecordFullLayer() = 0; virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( int routing_id, diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc index eb9c93f..95bea53 100644 --- a/content/renderer/browser_plugin/browser_plugin.cc +++ b/content/renderer/browser_plugin/browser_plugin.cc @@ -5,9 +5,11 @@ #include "content/renderer/browser_plugin/browser_plugin.h" #include "base/command_line.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/common/browser_plugin/browser_plugin_constants.h" #include "content/common/browser_plugin/browser_plugin_messages.h" #include "content/common/view_messages.h" @@ -202,10 +204,9 @@ void BrowserPlugin::OnGuestGone(int browser_plugin_instance_id) { // to fire their listeners and potentially overlay the webview with custom // behavior. If the BrowserPlugin is destroyed in the meantime, then the // task will not be executed. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&BrowserPlugin::ShowSadGraphic, - weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&BrowserPlugin::ShowSadGraphic, + weak_ptr_factory_.GetWeakPtr())); } void BrowserPlugin::OnSetContentsOpaque(int browser_plugin_instance_id, @@ -302,10 +303,9 @@ bool BrowserPlugin::initialize(WebPluginContainer* container) { // Defer attach call so that if there's any pending browser plugin // destruction, then it can progress first. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&BrowserPlugin::UpdateInternalInstanceId, - weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&BrowserPlugin::UpdateInternalInstanceId, + weak_ptr_factory_.GetWeakPtr())); return true; } diff --git a/content/renderer/device_sensors/device_light_event_pump_unittest.cc b/content/renderer/device_sensors/device_light_event_pump_unittest.cc index 4f19f0d..bc05b64 100644 --- a/content/renderer/device_sensors/device_light_event_pump_unittest.cc +++ b/content/renderer/device_sensors/device_light_event_pump_unittest.cc @@ -4,7 +4,9 @@ #include "device_light_event_pump.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/common/device_sensors/device_light_hardware_buffer.h" #include "content/public/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" @@ -146,10 +148,9 @@ TEST_F(DeviceLightEventPumpTest, DidStartPollingValuesEqual) { // Reset the pump's listener. light_pump()->Start(listener()); - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&DeviceLightEventPumpForTesting::FireEvent, - base::Unretained(light_pump()))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&DeviceLightEventPumpForTesting::FireEvent, + base::Unretained(light_pump()))); base::MessageLoop::current()->Run(); // No change in device light as present value is same as previous value. diff --git a/content/renderer/device_sensors/device_motion_event_pump_unittest.cc b/content/renderer/device_sensors/device_motion_event_pump_unittest.cc index 95b0fea..226356d 100644 --- a/content/renderer/device_sensors/device_motion_event_pump_unittest.cc +++ b/content/renderer/device_sensors/device_motion_event_pump_unittest.cc @@ -4,9 +4,11 @@ #include "device_motion_event_pump.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/common/device_sensors/device_motion_hardware_buffer.h" #include "content/public/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" @@ -191,7 +193,7 @@ TEST_F(DeviceMotionEventPumpTest, PumpThrottlesEventRate) { motion_pump()->Start(listener()); motion_pump()->OnDidStart(handle()); - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::MessageLoop::QuitClosure(), base::TimeDelta::FromMilliseconds(100)); base::MessageLoop::current()->Run(); diff --git a/content/renderer/device_sensors/device_orientation_event_pump_unittest.cc b/content/renderer/device_sensors/device_orientation_event_pump_unittest.cc index 4a2ace1..3787121 100644 --- a/content/renderer/device_sensors/device_orientation_event_pump_unittest.cc +++ b/content/renderer/device_sensors/device_orientation_event_pump_unittest.cc @@ -4,8 +4,10 @@ #include "device_orientation_event_pump.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/common/device_sensors/device_orientation_hardware_buffer.h" #include "content/public/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" @@ -181,9 +183,9 @@ TEST_F(DeviceOrientationEventPumpTest, UpdateRespectsOrientationThreshold) { // Reset the pump's listener. orientation_pump()->Start(listener()); - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(&DeviceOrientationEventPumpForTesting::FireEvent, - base::Unretained(orientation_pump()))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&DeviceOrientationEventPumpForTesting::FireEvent, + base::Unretained(orientation_pump()))); base::MessageLoop::current()->Run(); EXPECT_FALSE(listener()->did_change_device_orientation()); @@ -202,9 +204,9 @@ TEST_F(DeviceOrientationEventPumpTest, UpdateRespectsOrientationThreshold) { // Reset the pump's listener. orientation_pump()->Start(listener()); - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(&DeviceOrientationEventPumpForTesting::FireEvent, - base::Unretained(orientation_pump()))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&DeviceOrientationEventPumpForTesting::FireEvent, + base::Unretained(orientation_pump()))); base::MessageLoop::current()->Run(); EXPECT_TRUE(listener()->did_change_device_orientation()); diff --git a/content/renderer/devtools/v8_sampling_profiler.cc b/content/renderer/devtools/v8_sampling_profiler.cc index 20b2238..e70a5f5 100644 --- a/content/renderer/devtools/v8_sampling_profiler.cc +++ b/content/renderer/devtools/v8_sampling_profiler.cc @@ -14,8 +14,10 @@ #endif #include "base/format_macros.h" +#include "base/location.h" #include "base/strings/stringprintf.h" #include "base/synchronization/cancellation_flag.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/platform_thread.h" #include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event_argument.h" @@ -566,7 +568,7 @@ void V8SamplingThread::Stop() { V8SamplingProfiler::V8SamplingProfiler(bool underTest) : sampling_thread_(nullptr), render_thread_sampler_(Sampler::CreateForCurrentThread()), - message_loop_proxy_(base::MessageLoopProxy::current()) { + task_runner_(base::ThreadTaskRunnerHandle::Get()) { DCHECK(underTest || RenderThreadImpl::current()); // Force the "v8.cpu_profile" category to show up in the trace viewer. TraceLog::GetCategoryGroupEnabled( @@ -601,9 +603,9 @@ void V8SamplingProfiler::OnTraceLogEnabled() { if (record_mode == base::trace_event::TraceRecordMode::RECORD_CONTINUOUSLY) return; - message_loop_proxy_->PostTask( - FROM_HERE, base::Bind(&V8SamplingProfiler::StartSamplingThread, - base::Unretained(this))); + task_runner_->PostTask(FROM_HERE, + base::Bind(&V8SamplingProfiler::StartSamplingThread, + base::Unretained(this))); } void V8SamplingProfiler::OnTraceLogDisabled() { diff --git a/content/renderer/devtools/v8_sampling_profiler.h b/content/renderer/devtools/v8_sampling_profiler.h index 5b7d094..49ab310 100644 --- a/content/renderer/devtools/v8_sampling_profiler.h +++ b/content/renderer/devtools/v8_sampling_profiler.h @@ -5,6 +5,7 @@ #ifndef CONTENT_RENDERER_DEVTOOLS_V8_SAMPLING_PROFILER_H_ #define CONTENT_RENDERER_DEVTOOLS_V8_SAMPLING_PROFILER_H_ +#include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" #include "base/trace_event/trace_event_impl.h" #include "content/common/content_export.h" @@ -35,7 +36,7 @@ class CONTENT_EXPORT V8SamplingProfiler final scoped_ptr<base::WaitableEvent> waitable_event_for_testing_; scoped_ptr<V8SamplingThread> sampling_thread_; scoped_ptr<Sampler> render_thread_sampler_; - scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; DISALLOW_COPY_AND_ASSIGN(V8SamplingProfiler); }; diff --git a/content/renderer/gpu/compositor_output_surface.cc b/content/renderer/gpu/compositor_output_surface.cc index bdeefe0..3695a18 100644 --- a/content/renderer/gpu/compositor_output_surface.cc +++ b/content/renderer/gpu/compositor_output_surface.cc @@ -5,7 +5,9 @@ #include "content/renderer/gpu/compositor_output_surface.h" #include "base/command_line.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "cc/output/compositor_frame.h" #include "cc/output/compositor_frame_ack.h" #include "cc/output/managed_memory_policy.h" @@ -146,7 +148,7 @@ void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { context_provider()->ContextSupport()->SignalSyncPoint(sync_point, closure); } else { - base::MessageLoopProxy::current()->PostTask(FROM_HERE, closure); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); } client_->DidSwapBuffers(); return; diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index ff68dd7..4876135 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc @@ -8,11 +8,14 @@ #include <string> #include "base/command_line.h" +#include "base/location.h" #include "base/logging.h" #include "base/profiler/scoped_tracker.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/synchronization/lock.h" #include "base/sys_info.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "base/values.h" #include "cc/base/switches.h" @@ -742,7 +745,7 @@ bool RenderWidgetCompositor::CommitIsSynchronous() const { void RenderWidgetCompositor::ScheduleCommit() { if (CommitIsSynchronous()) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&RenderWidgetCompositor::SynchronousCommit, weak_factory_.GetWeakPtr())); } else { @@ -912,7 +915,7 @@ void RenderWidgetCompositor::DidFailToInitializeOutputSurface() { LOG_IF(FATAL, (num_failed_recreate_attempts_ >= MAX_OUTPUT_SURFACE_RETRIES)) << "Failed to create a fallback OutputSurface."; - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface, weak_factory_.GetWeakPtr())); } diff --git a/content/renderer/gpu/render_widget_compositor_unittest.cc b/content/renderer/gpu/render_widget_compositor_unittest.cc index 48f5968..35774b7 100644 --- a/content/renderer/gpu/render_widget_compositor_unittest.cc +++ b/content/renderer/gpu/render_widget_compositor_unittest.cc @@ -4,6 +4,9 @@ #include "content/renderer/gpu/render_widget_compositor.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "cc/output/begin_frame_args.h" #include "cc/test/failure_output_surface.h" #include "cc/trees/layer_tree_host.h" @@ -173,7 +176,7 @@ class RenderWidgetCompositorOutputSurface : public RenderWidgetCompositor { RenderWidgetCompositor::DidInitializeOutputSurface(); // Post the synchronous composite task so that it is not called // reentrantly as a part of RequestNewOutputSurface. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&RenderWidgetCompositorOutputSurface::SynchronousComposite, base::Unretained(this))); @@ -246,7 +249,7 @@ class RenderWidgetCompositorOutputSurfaceTest : public testing::Test { use_null_output_surface, num_failures_before_success, expected_successes, expected_fallback_succeses); render_widget_compositor_->StartCompositor(); - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&RenderWidgetCompositorOutputSurface::SynchronousComposite, base::Unretained(render_widget_compositor_.get()))); diff --git a/content/renderer/input/input_event_filter.cc b/content/renderer/input/input_event_filter.cc index 7a5a69f..62d7c45 100644 --- a/content/renderer/input/input_event_filter.cc +++ b/content/renderer/input/input_event_filter.cc @@ -7,8 +7,8 @@ #include "base/auto_reset.h" #include "base/bind.h" #include "base/location.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "cc/input/input_handler.h" #include "content/common/input/did_overscroll_params.h" @@ -42,13 +42,13 @@ namespace content { InputEventFilter::InputEventFilter( const base::Callback<void(const IPC::Message&)>& main_listener, const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, - const scoped_refptr<base::MessageLoopProxy>& target_loop) + const scoped_refptr<base::SingleThreadTaskRunner>& target_task_runner) : main_task_runner_(main_task_runner), main_listener_(main_listener), sender_(NULL), - target_loop_(target_loop), + target_task_runner_(target_task_runner), current_overscroll_params_(NULL) { - DCHECK(target_loop_.get()); + DCHECK(target_task_runner_.get()); } void InputEventFilter::SetBoundHandler(const Handler& handler) { @@ -83,7 +83,7 @@ void InputEventFilter::DidStopFlinging(int routing_id) { } void InputEventFilter::OnFilterAdded(IPC::Sender* sender) { - io_loop_ = base::MessageLoopProxy::current(); + io_task_runner_ = base::ThreadTaskRunnerHandle::Get(); sender_ = sender; } @@ -116,7 +116,7 @@ bool InputEventFilter::OnMessageReceived(const IPC::Message& message) { return false; } - target_loop_->PostTask( + target_task_runner_->PostTask( FROM_HERE, base::Bind(&InputEventFilter::ForwardToHandler, this, message)); return true; @@ -128,7 +128,7 @@ InputEventFilter::~InputEventFilter() { void InputEventFilter::ForwardToHandler(const IPC::Message& message) { DCHECK(!handler_.is_null()); - DCHECK(target_loop_->BelongsToCurrentThread()); + DCHECK(target_task_runner_->BelongsToCurrentThread()); TRACE_EVENT1("input", "InputEventFilter::ForwardToHandler", "message_type", GetInputMessageTypeName(message)); @@ -184,16 +184,15 @@ void InputEventFilter::ForwardToHandler(const IPC::Message& message) { } void InputEventFilter::SendMessage(scoped_ptr<IPC::Message> message) { - DCHECK(target_loop_->BelongsToCurrentThread()); + DCHECK(target_task_runner_->BelongsToCurrentThread()); - io_loop_->PostTask(FROM_HERE, - base::Bind(&InputEventFilter::SendMessageOnIOThread, - this, - base::Passed(&message))); + io_task_runner_->PostTask( + FROM_HERE, base::Bind(&InputEventFilter::SendMessageOnIOThread, this, + base::Passed(&message))); } void InputEventFilter::SendMessageOnIOThread(scoped_ptr<IPC::Message> message) { - DCHECK(io_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); if (!sender_) return; // Filter was removed. diff --git a/content/renderer/input/input_event_filter.h b/content/renderer/input/input_event_filter.h index e58798d..b66cf8c 100644 --- a/content/renderer/input/input_event_filter.h +++ b/content/renderer/input/input_event_filter.h @@ -17,7 +17,6 @@ #include "third_party/WebKit/public/web/WebInputEvent.h" namespace base { -class MessageLoopProxy; class SingleThreadTaskRunner; } @@ -42,7 +41,7 @@ class CONTENT_EXPORT InputEventFilter : public InputHandlerManagerClient, InputEventFilter( const base::Callback<void(const IPC::Message&)>& main_listener, const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, - const scoped_refptr<base::MessageLoopProxy>& target_loop); + const scoped_refptr<base::SingleThreadTaskRunner>& target_task_runner); // The |handler| is invoked on the thread associated with |target_loop| to // handle input events matching the filtered routes. @@ -79,11 +78,11 @@ class CONTENT_EXPORT InputEventFilter : public InputHandlerManagerClient, base::Callback<void(const IPC::Message&)> main_listener_; // The sender_ only gets invoked on the thread corresponding to io_loop_. - scoped_refptr<base::MessageLoopProxy> io_loop_; + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; IPC::Sender* sender_; // The handler_ only gets Run on the thread corresponding to target_loop_. - scoped_refptr<base::MessageLoopProxy> target_loop_; + scoped_refptr<base::SingleThreadTaskRunner> target_task_runner_; Handler handler_; // Protects access to routes_. diff --git a/content/renderer/input/input_event_filter_unittest.cc b/content/renderer/input/input_event_filter_unittest.cc index 79cb66c..6795504 100644 --- a/content/renderer/input/input_event_filter_unittest.cc +++ b/content/renderer/input/input_event_filter_unittest.cc @@ -7,7 +7,7 @@ #include <vector> #include "base/bind.h" -#include "base/message_loop/message_loop.h" +#include "base/thread_task_runner_handle.h" #include "content/common/input/synthetic_web_input_event_builders.h" #include "content/common/input_messages.h" #include "content/common/view_messages.h" @@ -129,7 +129,7 @@ class InputEventFilterTest : public testing::Test { filter_ = new InputEventFilter( base::Bind(base::IgnoreResult(&IPCMessageRecorder::OnMessageReceived), base::Unretained(&message_recorder_)), - base::MessageLoopProxy::current(), message_loop_.message_loop_proxy()); + base::ThreadTaskRunnerHandle::Get(), message_loop_.task_runner()); filter_->SetBoundHandler(base::Bind(&InputEventRecorder::HandleInputEvent, base::Unretained(&event_recorder_))); diff --git a/content/renderer/input/input_handler_manager.cc b/content/renderer/input/input_handler_manager.cc index ef011cc..b1a5263 100644 --- a/content/renderer/input/input_handler_manager.cc +++ b/content/renderer/input/input_handler_manager.cc @@ -5,7 +5,9 @@ #include "content/renderer/input/input_handler_manager.h" #include "base/bind.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "cc/input/input_handler.h" #include "components/scheduler/renderer/renderer_scheduler.h" @@ -37,10 +39,10 @@ InputEventAckState InputEventDispositionToAck( } // namespace InputHandlerManager::InputHandlerManager( - const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy, + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, InputHandlerManagerClient* client, scheduler::RendererScheduler* renderer_scheduler) - : message_loop_proxy_(message_loop_proxy), + : task_runner_(task_runner), client_(client), renderer_scheduler_(renderer_scheduler) { DCHECK(client_); @@ -56,29 +58,26 @@ void InputHandlerManager::AddInputHandler( int routing_id, const base::WeakPtr<cc::InputHandler>& input_handler, const base::WeakPtr<RenderViewImpl>& render_view_impl) { - if (message_loop_proxy_->BelongsToCurrentThread()) { + if (task_runner_->BelongsToCurrentThread()) { AddInputHandlerOnCompositorThread(routing_id, - base::MessageLoopProxy::current(), - input_handler, - render_view_impl); + base::ThreadTaskRunnerHandle::Get(), + input_handler, render_view_impl); } else { - message_loop_proxy_->PostTask( + task_runner_->PostTask( FROM_HERE, base::Bind(&InputHandlerManager::AddInputHandlerOnCompositorThread, - base::Unretained(this), - routing_id, - base::MessageLoopProxy::current(), - input_handler, + base::Unretained(this), routing_id, + base::ThreadTaskRunnerHandle::Get(), input_handler, render_view_impl)); } } void InputHandlerManager::AddInputHandlerOnCompositorThread( int routing_id, - const scoped_refptr<base::MessageLoopProxy>& main_loop, + const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, const base::WeakPtr<cc::InputHandler>& input_handler, const base::WeakPtr<RenderViewImpl>& render_view_impl) { - DCHECK(message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); // The handler could be gone by this point if the compositor has shut down. if (!input_handler) @@ -92,13 +91,13 @@ void InputHandlerManager::AddInputHandlerOnCompositorThread( "InputHandlerManager::AddInputHandlerOnCompositorThread", "result", "AddingRoute"); client_->DidAddInputHandler(routing_id, input_handler.get()); - input_handlers_.add(routing_id, - make_scoped_ptr(new InputHandlerWrapper(this, - routing_id, main_loop, input_handler, render_view_impl))); + input_handlers_.add(routing_id, make_scoped_ptr(new InputHandlerWrapper( + this, routing_id, main_task_runner, + input_handler, render_view_impl))); } void InputHandlerManager::RemoveInputHandler(int routing_id) { - DCHECK(message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(input_handlers_.contains(routing_id)); TRACE_EVENT0("input", "InputHandlerManager::RemoveInputHandler"); @@ -111,7 +110,7 @@ void InputHandlerManager::ObserveWheelEventAndResultOnMainThread( int routing_id, const blink::WebMouseWheelEvent& wheel_event, const cc::InputHandlerScrollResult& scroll_result) { - message_loop_proxy_->PostTask( + task_runner_->PostTask( FROM_HERE, base::Bind( &InputHandlerManager::ObserveWheelEventAndResultOnCompositorThread, @@ -136,7 +135,7 @@ InputEventAckState InputHandlerManager::HandleInputEvent( int routing_id, const WebInputEvent* input_event, ui::LatencyInfo* latency_info) { - DCHECK(message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); auto it = input_handlers_.find(routing_id); if (it == input_handlers_.end()) { diff --git a/content/renderer/input/input_handler_manager.h b/content/renderer/input/input_handler_manager.h index a44dc2d..bfb62d1 100644 --- a/content/renderer/input/input_handler_manager.h +++ b/content/renderer/input/input_handler_manager.h @@ -12,7 +12,7 @@ #include "content/renderer/render_view_impl.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } namespace cc { @@ -39,12 +39,12 @@ struct DidOverscrollParams; // the WebViews in this renderer. class InputHandlerManager { public: - // |message_loop_proxy| is the MessageLoopProxy of the compositor thread. The + // |task_runner| is the SingleThreadTaskRunner of the compositor thread. The // underlying MessageLoop and supplied |client| and the |renderer_scheduler| // must outlive this object. The RendererScheduler needs to know when input // events and fling animations occur, which is why it's passed in here. InputHandlerManager( - const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy, + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, InputHandlerManagerClient* client, scheduler::RendererScheduler* renderer_scheduler); ~InputHandlerManager(); @@ -84,7 +84,7 @@ class InputHandlerManager { // Called from the compositor's thread. void AddInputHandlerOnCompositorThread( int routing_id, - const scoped_refptr<base::MessageLoopProxy>& main_loop, + const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, const base::WeakPtr<cc::InputHandler>& input_handler, const base::WeakPtr<RenderViewImpl>& render_view_impl); @@ -98,7 +98,7 @@ class InputHandlerManager { InputHandlerMap; InputHandlerMap input_handlers_; - scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; InputHandlerManagerClient* client_; scheduler::RendererScheduler* renderer_scheduler_; // Not owned. }; diff --git a/content/renderer/input/input_handler_proxy.cc b/content/renderer/input/input_handler_proxy.cc index b89379d..4e2802d 100644 --- a/content/renderer/input/input_handler_proxy.cc +++ b/content/renderer/input/input_handler_proxy.cc @@ -6,8 +6,11 @@ #include "base/auto_reset.h" #include "base/command_line.h" +#include "base/location.h" #include "base/logging.h" #include "base/metrics/histogram.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "content/common/input/did_overscroll_params.h" #include "content/common/input/web_input_event_traits.h" @@ -406,7 +409,7 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel( // Note that the call to the elasticity controller is made asynchronously, // to minimize divergence between main thread and impl thread event // handling paths. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&InputScrollElasticityController::ObserveWheelEventAndResult, scroll_elasticity_controller_->GetWeakPtr(), wheel_event, diff --git a/content/renderer/input/input_handler_wrapper.cc b/content/renderer/input/input_handler_wrapper.cc index e46943b..6c7b09d 100644 --- a/content/renderer/input/input_handler_wrapper.cc +++ b/content/renderer/input/input_handler_wrapper.cc @@ -4,7 +4,7 @@ #include "content/renderer/input/input_handler_wrapper.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" #include "content/renderer/input/input_event_filter.h" #include "content/renderer/input/input_handler_manager.h" #include "third_party/WebKit/public/platform/Platform.h" @@ -14,13 +14,13 @@ namespace content { InputHandlerWrapper::InputHandlerWrapper( InputHandlerManager* input_handler_manager, int routing_id, - const scoped_refptr<base::MessageLoopProxy>& main_loop, + const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, const base::WeakPtr<cc::InputHandler>& input_handler, const base::WeakPtr<RenderViewImpl>& render_view_impl) : input_handler_manager_(input_handler_manager), routing_id_(routing_id), input_handler_proxy_(input_handler.get(), this), - main_loop_(main_loop), + main_task_runner_(main_task_runner), render_view_impl_(render_view_impl) { DCHECK(input_handler); } @@ -30,11 +30,9 @@ InputHandlerWrapper::~InputHandlerWrapper() { void InputHandlerWrapper::TransferActiveWheelFlingAnimation( const blink::WebActiveWheelFlingParameters& params) { - main_loop_->PostTask( - FROM_HERE, - base::Bind(&RenderViewImpl::TransferActiveWheelFlingAnimation, - render_view_impl_, - params)); + main_task_runner_->PostTask( + FROM_HERE, base::Bind(&RenderViewImpl::TransferActiveWheelFlingAnimation, + render_view_impl_, params)); } void InputHandlerWrapper::WillShutdown() { diff --git a/content/renderer/input/input_handler_wrapper.h b/content/renderer/input/input_handler_wrapper.h index f40c990..51263c6 100644 --- a/content/renderer/input/input_handler_wrapper.h +++ b/content/renderer/input/input_handler_wrapper.h @@ -6,6 +6,7 @@ #define CONTENT_RENDERER_INPUT_INPUT_HANDLER_WRAPPER_H_ #include "base/memory/weak_ptr.h" +#include "base/single_thread_task_runner.h" #include "content/renderer/input/input_handler_manager.h" #include "content/renderer/input/input_handler_proxy.h" #include "content/renderer/input/input_handler_proxy_client.h" @@ -15,11 +16,12 @@ namespace content { // This class lives on the compositor thread. class InputHandlerWrapper : public InputHandlerProxyClient { public: - InputHandlerWrapper(InputHandlerManager* input_handler_manager, - int routing_id, - const scoped_refptr<base::MessageLoopProxy>& main_loop, - const base::WeakPtr<cc::InputHandler>& input_handler, - const base::WeakPtr<RenderViewImpl>& render_view_impl); + InputHandlerWrapper( + InputHandlerManager* input_handler_manager, + int routing_id, + const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, + const base::WeakPtr<cc::InputHandler>& input_handler, + const base::WeakPtr<RenderViewImpl>& render_view_impl); ~InputHandlerWrapper() override; int routing_id() const { return routing_id_; } @@ -43,7 +45,7 @@ class InputHandlerWrapper : public InputHandlerProxyClient { InputHandlerManager* input_handler_manager_; int routing_id_; InputHandlerProxy input_handler_proxy_; - scoped_refptr<base::MessageLoopProxy> main_loop_; + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; // Can only be accessed on the main thread. base::WeakPtr<RenderViewImpl> render_view_impl_; diff --git a/content/renderer/media/android/media_source_delegate.cc b/content/renderer/media/android/media_source_delegate.cc index 927057c..1a5cbe9 100644 --- a/content/renderer/media/android/media_source_delegate.cc +++ b/content/renderer/media/android/media_source_delegate.cc @@ -8,8 +8,8 @@ #include <string> #include <vector> -#include "base/message_loop/message_loop_proxy.h" #include "base/strings/string_number_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/renderer/media/android/renderer_demuxer_android.h" #include "media/base/android/demuxer_stream_player_params.h" #include "media/base/bind_to_current_loop.h" @@ -57,7 +57,7 @@ MediaSourceDelegate::MediaSourceDelegate( browser_seek_time_(media::kNoTimestamp()), expecting_regular_seek_(false), access_unit_size_(0), - main_task_runner_(base::MessageLoopProxy::current()), + main_task_runner_(base::ThreadTaskRunnerHandle::Get()), media_task_runner_(media_task_runner), main_weak_factory_(this), media_weak_factory_(this) { diff --git a/content/renderer/media/android/stream_texture_factory.h b/content/renderer/media/android/stream_texture_factory.h index deb6dfe..812fd1e 100644 --- a/content/renderer/media/android/stream_texture_factory.h +++ b/content/renderer/media/android/stream_texture_factory.h @@ -7,7 +7,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "cc/layers/video_frame_provider.h" #include "gpu/command_buffer/common/mailbox.h" #include "ui/gfx/geometry/size.h" @@ -31,7 +31,7 @@ class StreamTextureProxy { // on any thread, but must be called with the same loop every time. virtual void BindToLoop(int32 stream_id, cc::VideoFrameProvider::Client* client, - scoped_refptr<base::MessageLoopProxy> loop) = 0; + scoped_refptr<base::SingleThreadTaskRunner> loop) = 0; // Causes this instance to be deleted on the thread it is bound to. virtual void Release() = 0; diff --git a/content/renderer/media/android/stream_texture_factory_impl.cc b/content/renderer/media/android/stream_texture_factory_impl.cc index e67fee9..a17531b 100644 --- a/content/renderer/media/android/stream_texture_factory_impl.cc +++ b/content/renderer/media/android/stream_texture_factory_impl.cc @@ -24,7 +24,7 @@ class StreamTextureProxyImpl : public StreamTextureProxy, // StreamTextureProxy implementation: void BindToLoop(int32 stream_id, cc::VideoFrameProvider::Client* client, - scoped_refptr<base::MessageLoopProxy> loop) override; + scoped_refptr<base::SingleThreadTaskRunner> loop) override; void Release() override; // StreamTextureHost::Listener implementation: @@ -39,7 +39,7 @@ class StreamTextureProxyImpl : public StreamTextureProxy, // Protects access to |client_| and |loop_|. base::Lock lock_; cc::VideoFrameProvider::Client* client_; - scoped_refptr<base::MessageLoopProxy> loop_; + scoped_refptr<base::SingleThreadTaskRunner> loop_; DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureProxyImpl); }; @@ -68,7 +68,7 @@ void StreamTextureProxyImpl::Release() { void StreamTextureProxyImpl::BindToLoop( int32 stream_id, cc::VideoFrameProvider::Client* client, - scoped_refptr<base::MessageLoopProxy> loop) { + scoped_refptr<base::SingleThreadTaskRunner> loop) { DCHECK(loop.get()); { diff --git a/content/renderer/media/android/stream_texture_factory_synchronous_impl.cc b/content/renderer/media/android/stream_texture_factory_synchronous_impl.cc index 9c0d61a..d92d3ab8 100644 --- a/content/renderer/media/android/stream_texture_factory_synchronous_impl.cc +++ b/content/renderer/media/android/stream_texture_factory_synchronous_impl.cc @@ -10,8 +10,8 @@ #include "base/callback.h" #include "base/location.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/process/process_handle.h" +#include "base/single_thread_task_runner.h" #include "base/synchronization/lock.h" #include "cc/output/context_provider.h" #include "content/common/android/surface_texture_peer.h" @@ -36,7 +36,7 @@ class StreamTextureProxyImpl // StreamTextureProxy implementation: void BindToLoop(int32 stream_id, cc::VideoFrameProvider::Client* client, - scoped_refptr<base::MessageLoopProxy> loop) override; + scoped_refptr<base::SingleThreadTaskRunner> loop) override; void Release() override; private: @@ -46,7 +46,7 @@ class StreamTextureProxyImpl // Protects access to |client_| and |loop_|. base::Lock lock_; cc::VideoFrameProvider::Client* client_; - scoped_refptr<base::MessageLoopProxy> loop_; + scoped_refptr<base::SingleThreadTaskRunner> loop_; // Accessed on the |loop_| thread only. base::Closure callback_; @@ -86,7 +86,7 @@ void StreamTextureProxyImpl::Release() { void StreamTextureProxyImpl::BindToLoop( int32 stream_id, cc::VideoFrameProvider::Client* client, - scoped_refptr<base::MessageLoopProxy> loop) { + scoped_refptr<base::SingleThreadTaskRunner> loop) { DCHECK(loop.get()); { diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc index ec36cf2..7495dc3 100644 --- a/content/renderer/media/android/webmediaplayer_android.cc +++ b/content/renderer/media/android/webmediaplayer_android.cc @@ -179,9 +179,9 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid( has_size_info_(false), // Compositor thread does not exist in layout tests. compositor_loop_( - RenderThreadImpl::current()->compositor_message_loop_proxy().get() - ? RenderThreadImpl::current()->compositor_message_loop_proxy() - : base::MessageLoopProxy::current()), + RenderThreadImpl::current()->compositor_task_runner().get() + ? RenderThreadImpl::current()->compositor_task_runner() + : base::ThreadTaskRunnerHandle::Get()), stream_texture_factory_(factory), needs_external_surface_(false), is_fullscreen_(false), diff --git a/content/renderer/media/android/webmediaplayer_android.h b/content/renderer/media/android/webmediaplayer_android.h index 2627ac0..3e67623 100644 --- a/content/renderer/media/android/webmediaplayer_android.h +++ b/content/renderer/media/android/webmediaplayer_android.h @@ -438,7 +438,7 @@ class WebMediaPlayerAndroid : public blink::WebMediaPlayer, // Whether the video size info is available. bool has_size_info_; - const scoped_refptr<base::MessageLoopProxy> compositor_loop_; + const scoped_refptr<base::SingleThreadTaskRunner> compositor_loop_; // Object for allocating stream textures. scoped_refptr<StreamTextureFactory> stream_texture_factory_; diff --git a/content/renderer/media/audio_message_filter_unittest.cc b/content/renderer/media/audio_message_filter_unittest.cc index 45a0681..9122019 100644 --- a/content/renderer/media/audio_message_filter_unittest.cc +++ b/content/renderer/media/audio_message_filter_unittest.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/message_loop/message_loop.h" #include "content/common/media/audio_messages.h" #include "content/renderer/media/audio_message_filter.h" #include "media/audio/audio_output_ipc.h" @@ -72,8 +71,8 @@ class MockAudioDelegate : public media::AudioOutputIPCDelegate { TEST(AudioMessageFilterTest, Basic) { base::MessageLoopForIO message_loop; - scoped_refptr<AudioMessageFilter> filter(new AudioMessageFilter( - message_loop.message_loop_proxy())); + scoped_refptr<AudioMessageFilter> filter( + new AudioMessageFilter(message_loop.task_runner())); MockAudioDelegate delegate; const scoped_ptr<media::AudioOutputIPC> ipc = @@ -113,8 +112,8 @@ TEST(AudioMessageFilterTest, Basic) { TEST(AudioMessageFilterTest, Delegates) { base::MessageLoopForIO message_loop; - scoped_refptr<AudioMessageFilter> filter(new AudioMessageFilter( - message_loop.message_loop_proxy())); + scoped_refptr<AudioMessageFilter> filter( + new AudioMessageFilter(message_loop.task_runner())); MockAudioDelegate delegate1; MockAudioDelegate delegate2; diff --git a/content/renderer/media/crypto/ppapi_decryptor.cc b/content/renderer/media/crypto/ppapi_decryptor.cc index b828de5..a4b9148 100644 --- a/content/renderer/media/crypto/ppapi_decryptor.cc +++ b/content/renderer/media/crypto/ppapi_decryptor.cc @@ -7,9 +7,10 @@ #include <string> #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/renderer/media/crypto/cdm_initialized_promise.h" #include "content/renderer/pepper/content_decryptor_delegate.h" #include "content/renderer/pepper/pepper_plugin_instance_impl.h" @@ -41,7 +42,7 @@ void PpapiDecryptor::Create( create_pepper_cdm_cb.Run(plugin_type, security_origin); if (!pepper_cdm_wrapper) { DLOG(ERROR) << "Plugin instance creation failed."; - base::MessageLoopProxy::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(cdm_created_cb, nullptr, "Plugin instance creation failed.")); return; @@ -74,7 +75,7 @@ PpapiDecryptor::PpapiDecryptor( legacy_session_error_cb_(legacy_session_error_cb), session_keys_change_cb_(session_keys_change_cb), session_expiration_update_cb_(session_expiration_update_cb), - render_loop_proxy_(base::MessageLoopProxy::current()), + render_task_runner_(base::ThreadTaskRunnerHandle::Get()), weak_ptr_factory_(this) { DCHECK(pepper_cdm_wrapper_.get()); DCHECK(!session_message_cb_.is_null()); @@ -109,7 +110,7 @@ void PpapiDecryptor::SetServerCertificate( const std::vector<uint8_t>& certificate, scoped_ptr<media::SimpleCdmPromise> promise) { DVLOG(2) << __FUNCTION__; - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); if (!CdmDelegate()) { promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); @@ -125,7 +126,7 @@ void PpapiDecryptor::CreateSessionAndGenerateRequest( const std::vector<uint8_t>& init_data, scoped_ptr<media::NewSessionCdmPromise> promise) { DVLOG(2) << __FUNCTION__; - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); if (!CdmDelegate()) { promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); @@ -141,7 +142,7 @@ void PpapiDecryptor::LoadSession( const std::string& session_id, scoped_ptr<media::NewSessionCdmPromise> promise) { DVLOG(2) << __FUNCTION__; - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); if (!CdmDelegate()) { promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); @@ -154,7 +155,7 @@ void PpapiDecryptor::UpdateSession( const std::string& session_id, const std::vector<uint8_t>& response, scoped_ptr<media::SimpleCdmPromise> promise) { - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); if (!CdmDelegate()) { promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); @@ -165,7 +166,7 @@ void PpapiDecryptor::UpdateSession( void PpapiDecryptor::CloseSession(const std::string& session_id, scoped_ptr<media::SimpleCdmPromise> promise) { - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); if (!CdmDelegate()) { promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); @@ -178,7 +179,7 @@ void PpapiDecryptor::CloseSession(const std::string& session_id, void PpapiDecryptor::RemoveSession( const std::string& session_id, scoped_ptr<media::SimpleCdmPromise> promise) { - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); if (!CdmDelegate()) { promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); @@ -202,12 +203,11 @@ int PpapiDecryptor::GetCdmId() const { void PpapiDecryptor::RegisterNewKeyCB(StreamType stream_type, const NewKeyCB& new_key_cb) { - if (!render_loop_proxy_->BelongsToCurrentThread()) { - render_loop_proxy_->PostTask(FROM_HERE, - base::Bind(&PpapiDecryptor::RegisterNewKeyCB, - weak_ptr_factory_.GetWeakPtr(), - stream_type, - new_key_cb)); + if (!render_task_runner_->BelongsToCurrentThread()) { + render_task_runner_->PostTask( + FROM_HERE, + base::Bind(&PpapiDecryptor::RegisterNewKeyCB, + weak_ptr_factory_.GetWeakPtr(), stream_type, new_key_cb)); return; } @@ -228,13 +228,11 @@ void PpapiDecryptor::Decrypt( StreamType stream_type, const scoped_refptr<media::DecoderBuffer>& encrypted, const DecryptCB& decrypt_cb) { - if (!render_loop_proxy_->BelongsToCurrentThread()) { - render_loop_proxy_->PostTask(FROM_HERE, - base::Bind(&PpapiDecryptor::Decrypt, - weak_ptr_factory_.GetWeakPtr(), - stream_type, - encrypted, - decrypt_cb)); + if (!render_task_runner_->BelongsToCurrentThread()) { + render_task_runner_->PostTask( + FROM_HERE, + base::Bind(&PpapiDecryptor::Decrypt, weak_ptr_factory_.GetWeakPtr(), + stream_type, encrypted, decrypt_cb)); return; } @@ -246,11 +244,10 @@ void PpapiDecryptor::Decrypt( } void PpapiDecryptor::CancelDecrypt(StreamType stream_type) { - if (!render_loop_proxy_->BelongsToCurrentThread()) { - render_loop_proxy_->PostTask(FROM_HERE, - base::Bind(&PpapiDecryptor::CancelDecrypt, - weak_ptr_factory_.GetWeakPtr(), - stream_type)); + if (!render_task_runner_->BelongsToCurrentThread()) { + render_task_runner_->PostTask( + FROM_HERE, base::Bind(&PpapiDecryptor::CancelDecrypt, + weak_ptr_factory_.GetWeakPtr(), stream_type)); return; } @@ -262,13 +259,10 @@ void PpapiDecryptor::CancelDecrypt(StreamType stream_type) { void PpapiDecryptor::InitializeAudioDecoder( const media::AudioDecoderConfig& config, const DecoderInitCB& init_cb) { - if (!render_loop_proxy_->BelongsToCurrentThread()) { - render_loop_proxy_->PostTask( - FROM_HERE, - base::Bind(&PpapiDecryptor::InitializeAudioDecoder, - weak_ptr_factory_.GetWeakPtr(), - config, - init_cb)); + if (!render_task_runner_->BelongsToCurrentThread()) { + render_task_runner_->PostTask( + FROM_HERE, base::Bind(&PpapiDecryptor::InitializeAudioDecoder, + weak_ptr_factory_.GetWeakPtr(), config, init_cb)); return; } @@ -290,13 +284,10 @@ void PpapiDecryptor::InitializeAudioDecoder( void PpapiDecryptor::InitializeVideoDecoder( const media::VideoDecoderConfig& config, const DecoderInitCB& init_cb) { - if (!render_loop_proxy_->BelongsToCurrentThread()) { - render_loop_proxy_->PostTask( - FROM_HERE, - base::Bind(&PpapiDecryptor::InitializeVideoDecoder, - weak_ptr_factory_.GetWeakPtr(), - config, - init_cb)); + if (!render_task_runner_->BelongsToCurrentThread()) { + render_task_runner_->PostTask( + FROM_HERE, base::Bind(&PpapiDecryptor::InitializeVideoDecoder, + weak_ptr_factory_.GetWeakPtr(), config, init_cb)); return; } @@ -318,13 +309,11 @@ void PpapiDecryptor::InitializeVideoDecoder( void PpapiDecryptor::DecryptAndDecodeAudio( const scoped_refptr<media::DecoderBuffer>& encrypted, const AudioDecodeCB& audio_decode_cb) { - if (!render_loop_proxy_->BelongsToCurrentThread()) { - render_loop_proxy_->PostTask( + if (!render_task_runner_->BelongsToCurrentThread()) { + render_task_runner_->PostTask( FROM_HERE, base::Bind(&PpapiDecryptor::DecryptAndDecodeAudio, - weak_ptr_factory_.GetWeakPtr(), - encrypted, - audio_decode_cb)); + weak_ptr_factory_.GetWeakPtr(), encrypted, audio_decode_cb)); return; } @@ -338,13 +327,11 @@ void PpapiDecryptor::DecryptAndDecodeAudio( void PpapiDecryptor::DecryptAndDecodeVideo( const scoped_refptr<media::DecoderBuffer>& encrypted, const VideoDecodeCB& video_decode_cb) { - if (!render_loop_proxy_->BelongsToCurrentThread()) { - render_loop_proxy_->PostTask( + if (!render_task_runner_->BelongsToCurrentThread()) { + render_task_runner_->PostTask( FROM_HERE, base::Bind(&PpapiDecryptor::DecryptAndDecodeVideo, - weak_ptr_factory_.GetWeakPtr(), - encrypted, - video_decode_cb)); + weak_ptr_factory_.GetWeakPtr(), encrypted, video_decode_cb)); return; } @@ -356,11 +343,10 @@ void PpapiDecryptor::DecryptAndDecodeVideo( } void PpapiDecryptor::ResetDecoder(StreamType stream_type) { - if (!render_loop_proxy_->BelongsToCurrentThread()) { - render_loop_proxy_->PostTask(FROM_HERE, - base::Bind(&PpapiDecryptor::ResetDecoder, - weak_ptr_factory_.GetWeakPtr(), - stream_type)); + if (!render_task_runner_->BelongsToCurrentThread()) { + render_task_runner_->PostTask( + FROM_HERE, base::Bind(&PpapiDecryptor::ResetDecoder, + weak_ptr_factory_.GetWeakPtr(), stream_type)); return; } @@ -370,12 +356,10 @@ void PpapiDecryptor::ResetDecoder(StreamType stream_type) { } void PpapiDecryptor::DeinitializeDecoder(StreamType stream_type) { - if (!render_loop_proxy_->BelongsToCurrentThread()) { - render_loop_proxy_->PostTask( - FROM_HERE, - base::Bind(&PpapiDecryptor::DeinitializeDecoder, - weak_ptr_factory_.GetWeakPtr(), - stream_type)); + if (!render_task_runner_->BelongsToCurrentThread()) { + render_task_runner_->PostTask( + FROM_HERE, base::Bind(&PpapiDecryptor::DeinitializeDecoder, + weak_ptr_factory_.GetWeakPtr(), stream_type)); return; } @@ -386,7 +370,7 @@ void PpapiDecryptor::DeinitializeDecoder(StreamType stream_type) { void PpapiDecryptor::OnDecoderInitialized(StreamType stream_type, bool success) { - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); switch (stream_type) { case kAudio: DCHECK(!audio_decoder_init_cb_.is_null()); @@ -405,7 +389,7 @@ void PpapiDecryptor::OnSessionMessage(const std::string& session_id, MessageType message_type, const std::vector<uint8_t>& message, const GURL& legacy_destination_url) { - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); session_message_cb_.Run(session_id, message_type, message, legacy_destination_url); } @@ -413,7 +397,7 @@ void PpapiDecryptor::OnSessionMessage(const std::string& session_id, void PpapiDecryptor::OnSessionKeysChange(const std::string& session_id, bool has_additional_usable_key, media::CdmKeysInfo keys_info) { - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); // TODO(jrummell): Handling resume playback should be done in the media // player, not in the Decryptors. http://crbug.com/413413. @@ -427,12 +411,12 @@ void PpapiDecryptor::OnSessionKeysChange(const std::string& session_id, void PpapiDecryptor::OnSessionExpirationUpdate( const std::string& session_id, const base::Time& new_expiry_time) { - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); session_expiration_update_cb_.Run(session_id, new_expiry_time); } void PpapiDecryptor::OnSessionClosed(const std::string& session_id) { - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); session_closed_cb_.Run(session_id); } @@ -441,7 +425,7 @@ void PpapiDecryptor::OnLegacySessionError( MediaKeys::Exception exception_code, uint32_t system_code, const std::string& error_description) { - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); legacy_session_error_cb_.Run(session_id, exception_code, system_code, error_description); } @@ -455,12 +439,12 @@ void PpapiDecryptor::AttemptToResumePlayback() { } void PpapiDecryptor::OnFatalPluginError() { - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); pepper_cdm_wrapper_.reset(); } ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { - DCHECK(render_loop_proxy_->BelongsToCurrentThread()); + DCHECK(render_task_runner_->BelongsToCurrentThread()); return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; } diff --git a/content/renderer/media/crypto/ppapi_decryptor.h b/content/renderer/media/crypto/ppapi_decryptor.h index a4f26b5..6660a7b 100644 --- a/content/renderer/media/crypto/ppapi_decryptor.h +++ b/content/renderer/media/crypto/ppapi_decryptor.h @@ -21,7 +21,7 @@ class GURL; namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } namespace content { @@ -147,7 +147,7 @@ class PpapiDecryptor : public media::MediaKeys, media::SessionKeysChangeCB session_keys_change_cb_; media::SessionExpirationUpdateCB session_expiration_update_cb_; - scoped_refptr<base::MessageLoopProxy> render_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_; DecoderInitCB audio_decoder_init_cb_; DecoderInitCB video_decoder_init_cb_; diff --git a/content/renderer/media/crypto/render_cdm_factory.cc b/content/renderer/media/crypto/render_cdm_factory.cc index fe1a5da..d7dc2ab 100644 --- a/content/renderer/media/crypto/render_cdm_factory.cc +++ b/content/renderer/media/crypto/render_cdm_factory.cc @@ -8,7 +8,8 @@ #include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "media/base/cdm_config.h" #include "media/base/cdm_promise.h" #include "media/base/key_systems.h" @@ -56,7 +57,7 @@ void RenderCdmFactory::Create( DCHECK(thread_checker_.CalledOnValidThread()); if (!security_origin.is_valid()) { - base::MessageLoopProxy::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(cdm_created_cb, nullptr, "Invalid origin.")); return; } @@ -69,7 +70,7 @@ void RenderCdmFactory::Create( scoped_ptr<media::MediaKeys> cdm( new media::AesDecryptor(security_origin, session_message_cb, session_closed_cb, session_keys_change_cb)); - base::MessageLoopProxy::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(cdm_created_cb, base::Passed(&cdm), "")); return; } @@ -90,7 +91,7 @@ void RenderCdmFactory::Create( session_keys_change_cb, session_expiration_update_cb, cdm_created_cb); #else // No possible CDM to create, so fail the request. - base::MessageLoopProxy::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(cdm_created_cb, nullptr, "Key system not supported.")); #endif // defined(ENABLE_PEPPER_CDMS) diff --git a/content/renderer/media/media_stream_audio_processor_unittest.cc b/content/renderer/media/media_stream_audio_processor_unittest.cc index a2f1b4e..895480c 100644 --- a/content/renderer/media/media_stream_audio_processor_unittest.cc +++ b/content/renderer/media/media_stream_audio_processor_unittest.cc @@ -415,8 +415,8 @@ TEST_F(MediaStreamAudioProcessorTest, MAYBE_TestAllSampleRates) { TEST_F(MediaStreamAudioProcessorTest, GetAecDumpMessageFilter) { base::MessageLoopForUI message_loop; scoped_refptr<AecDumpMessageFilter> aec_dump_message_filter_( - new AecDumpMessageFilter(message_loop.message_loop_proxy(), - message_loop.message_loop_proxy())); + new AecDumpMessageFilter(message_loop.task_runner(), + message_loop.task_runner())); MockMediaConstraintFactory constraint_factory; scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( diff --git a/content/renderer/media/media_stream_dispatcher.h b/content/renderer/media/media_stream_dispatcher.h index 74a06dc..7784b44 100644 --- a/content/renderer/media/media_stream_dispatcher.h +++ b/content/renderer/media/media_stream_dispatcher.h @@ -19,10 +19,6 @@ #include "content/public/renderer/render_frame_observer.h" #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" -namespace base { -class MessageLoopProxy; -} - namespace content { // MediaStreamDispatcher is a delegate for the Media Stream API messages. diff --git a/content/renderer/media/media_stream_video_capture_source_unittest.cc b/content/renderer/media/media_stream_video_capture_source_unittest.cc index 7995437..6d04584 100644 --- a/content/renderer/media/media_stream_video_capture_source_unittest.cc +++ b/content/renderer/media/media_stream_video_capture_source_unittest.cc @@ -4,8 +4,9 @@ #include "base/bind.h" #include "base/callback_helpers.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "content/child/child_process.h" #include "content/public/renderer/media_stream_video_sink.h" @@ -321,7 +322,7 @@ TEST_F(MediaStreamVideoCapturerSourceTest, CaptureTimeAndMetadataPlumbing) { const scoped_refptr<media::VideoFrame> frame = media::VideoFrame::CreateBlackFrame(gfx::Size(2, 2)); frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE, 30.0); - child_process_->io_message_loop()->PostTask( + child_process_->io_task_runner()->PostTask( FROM_HERE, base::Bind(deliver_frame_cb, frame, reference_capture_time)); run_loop.Run(); FakeMediaStreamVideoSink::RemoveFromVideoTrack(&fake_sink, track); diff --git a/content/renderer/media/media_stream_video_capturer_source.h b/content/renderer/media/media_stream_video_capturer_source.h index 3722b9d..0cf52ee 100644 --- a/content/renderer/media/media_stream_video_capturer_source.h +++ b/content/renderer/media/media_stream_video_capturer_source.h @@ -8,7 +8,6 @@ #include "base/callback.h" #include "base/gtest_prod_util.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/threading/thread_checker.h" #include "content/common/media/video_capture.h" #include "content/renderer/media/media_stream_video_source.h" diff --git a/content/renderer/media/media_stream_video_source.h b/content/renderer/media/media_stream_video_source.h index 52771c7..2de7d3e 100644 --- a/content/renderer/media/media_stream_video_source.h +++ b/content/renderer/media/media_stream_video_source.h @@ -62,7 +62,7 @@ class CONTENT_EXPORT MediaStreamVideoSource // Return true if |name| is a constraint supported by MediaStreamVideoSource. static bool IsConstraintSupported(const std::string& name); - // Returns the MessageLoopProxy where video frames will be delivered on. + // Returns the task runner where video frames will be delivered on. base::SingleThreadTaskRunner* io_task_runner() const; // Constraint keys used by a video source. diff --git a/content/renderer/media/media_stream_video_track.cc b/content/renderer/media/media_stream_video_track.cc index a782018..40f641f 100644 --- a/content/renderer/media/media_stream_video_track.cc +++ b/content/renderer/media/media_stream_video_track.cc @@ -7,6 +7,9 @@ #include <utility> #include "base/bind.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" namespace content { @@ -115,7 +118,7 @@ void MediaStreamVideoTrack::FrameDeliverer::RemoveCallback(VideoSinkId id) { DCHECK(main_render_thread_checker_.CalledOnValidThread()); io_task_runner_->PostTask( FROM_HERE, base::Bind(&FrameDeliverer::RemoveCallbackOnIO, this, id, - base::MessageLoopProxy::current())); + base::ThreadTaskRunnerHandle::Get())); } void MediaStreamVideoTrack::FrameDeliverer::RemoveCallbackOnIO( diff --git a/content/renderer/media/render_media_log.cc b/content/renderer/media/render_media_log.cc index 800fd9c..dacf1cf 100644 --- a/content/renderer/media/render_media_log.cc +++ b/content/renderer/media/render_media_log.cc @@ -5,8 +5,10 @@ #include "content/renderer/media/render_media_log.h" #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/common/view_messages.h" #include "content/public/renderer/render_thread.h" @@ -30,7 +32,7 @@ void Log(media::MediaLogEvent* event) { namespace content { RenderMediaLog::RenderMediaLog() - : task_runner_(base::MessageLoopProxy::current()), + : task_runner_(base::ThreadTaskRunnerHandle::Get()), tick_clock_(new base::DefaultTickClock()), last_ipc_send_time_(tick_clock_->NowTicks()) { DCHECK(RenderThread::Get()) diff --git a/content/renderer/media/render_media_log.h b/content/renderer/media/render_media_log.h index 12c251d..31b9973 100644 --- a/content/renderer/media/render_media_log.h +++ b/content/renderer/media/render_media_log.h @@ -11,10 +11,6 @@ #include "content/common/content_export.h" #include "media/base/media_log.h" -namespace base { -class MessageLoopProxy; -} - namespace content { // RenderMediaLog is an implementation of MediaLog that forwards events to the diff --git a/content/renderer/media/render_media_log_unittest.cc b/content/renderer/media/render_media_log_unittest.cc index e9774ac..0f03650 100644 --- a/content/renderer/media/render_media_log_unittest.cc +++ b/content/renderer/media/render_media_log_unittest.cc @@ -50,6 +50,7 @@ class RenderMediaLogTest : public testing::Test { } private: + base::MessageLoop message_loop_; MockRenderThread render_thread_; scoped_refptr<RenderMediaLog> log_; base::SimpleTestTickClock* tick_clock_; // Owned by |log_|. diff --git a/content/renderer/media/rtc_dtmf_sender_handler.cc b/content/renderer/media/rtc_dtmf_sender_handler.cc index 65b60b8..f335911 100644 --- a/content/renderer/media/rtc_dtmf_sender_handler.cc +++ b/content/renderer/media/rtc_dtmf_sender_handler.cc @@ -9,8 +9,9 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/thread_checker.h" using webrtc::DtmfSenderInterface; @@ -22,7 +23,7 @@ class RtcDtmfSenderHandler::Observer : public webrtc::DtmfSenderObserverInterface { public: explicit Observer(const base::WeakPtr<RtcDtmfSenderHandler>& handler) - : main_thread_(base::MessageLoopProxy::current()), handler_(handler) {} + : main_thread_(base::ThreadTaskRunnerHandle::Get()), handler_(handler) {} private: friend class base::RefCountedThreadSafe<Observer>; diff --git a/content/renderer/media/rtc_peer_connection_handler.cc b/content/renderer/media/rtc_peer_connection_handler.cc index 26c4127..2fec588 100644 --- a/content/renderer/media/rtc_peer_connection_handler.cc +++ b/content/renderer/media/rtc_peer_connection_handler.cc @@ -10,6 +10,7 @@ #include "base/command_line.h" #include "base/lazy_instance.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" @@ -1036,10 +1037,9 @@ bool RTCPeerConnectionHandler::addICECandidate( // TODO(tommi): Instead of calling addICECandidate here, we can do a // PostTaskAndReply kind of a thing. bool result = addICECandidate(candidate); - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&RTCPeerConnectionHandler::OnaddICECandidateResult, - weak_factory_.GetWeakPtr(), request, result)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&RTCPeerConnectionHandler::OnaddICECandidateResult, + weak_factory_.GetWeakPtr(), request, result)); // On failure callback will be triggered. return true; } diff --git a/content/renderer/media/rtc_peer_connection_handler_unittest.cc b/content/renderer/media/rtc_peer_connection_handler_unittest.cc index 7627e7d..6cbdd1d 100644 --- a/content/renderer/media/rtc_peer_connection_handler_unittest.cc +++ b/content/renderer/media/rtc_peer_connection_handler_unittest.cc @@ -5,9 +5,10 @@ #include <string> #include <vector> +#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/strings/utf_string_conversions.h" #include "base/thread_task_runner_handle.h" #include "base/values.h" @@ -58,7 +59,7 @@ using testing::SaveArg; namespace content { ACTION_P2(ExitMessageLoop, message_loop, quit_closure) { - message_loop->PostTask(FROM_HERE, quit_closure); + message_loop->task_runner()->PostTask(FROM_HERE, quit_closure); } class MockRTCStatsResponse : public LocalRTCStatsResponse { diff --git a/content/renderer/media/rtc_video_decoder.cc b/content/renderer/media/rtc_video_decoder.cc index 82c853c..f78c5b8 100644 --- a/content/renderer/media/rtc_video_decoder.cc +++ b/content/renderer/media/rtc_video_decoder.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/logging.h" #include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/histogram.h" #include "base/numerics/safe_conversions.h" #include "base/stl_util.h" diff --git a/content/renderer/media/rtc_video_decoder.h b/content/renderer/media/rtc_video_decoder.h index 8bfcc7c..f2c240e 100644 --- a/content/renderer/media/rtc_video_decoder.h +++ b/content/renderer/media/rtc_video_decoder.h @@ -25,7 +25,6 @@ namespace base { class WaitableEvent; -class MessageLoopProxy; }; namespace media { diff --git a/content/renderer/media/rtc_video_decoder_factory.h b/content/renderer/media/rtc_video_decoder_factory.h index c52b831..d3951a3 100644 --- a/content/renderer/media/rtc_video_decoder_factory.h +++ b/content/renderer/media/rtc_video_decoder_factory.h @@ -5,7 +5,6 @@ #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_FACTORY_H_ #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_FACTORY_H_ -#include "base/message_loop/message_loop_proxy.h" #include "base/threading/thread.h" #include "content/common/content_export.h" #include "third_party/libjingle/source/talk/media/webrtc/webrtcvideodecoderfactory.h" diff --git a/content/renderer/media/rtc_video_decoder_unittest.cc b/content/renderer/media/rtc_video_decoder_unittest.cc index 0e4a558..9bf312c 100644 --- a/content/renderer/media/rtc_video_decoder_unittest.cc +++ b/content/renderer/media/rtc_video_decoder_unittest.cc @@ -3,8 +3,10 @@ // found in the LICENSE file. #include "base/bind.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "content/renderer/media/rtc_video_decoder.h" #include "media/base/gmock_callback_support.h" @@ -33,7 +35,7 @@ class RTCVideoDecoderTest : public ::testing::Test, void SetUp() override { ASSERT_TRUE(vda_thread_.Start()); - vda_task_runner_ = vda_thread_.message_loop_proxy(); + vda_task_runner_ = vda_thread_.task_runner(); mock_vda_ = new media::MockVideoDecodeAccelerator; media::VideoDecodeAccelerator::SupportedProfile supported_profile; @@ -69,7 +71,7 @@ class RTCVideoDecoderTest : public ::testing::Test, int32_t Decoded(webrtc::I420VideoFrame& decoded_image) override { DVLOG(2) << "Decoded"; - EXPECT_EQ(vda_task_runner_, base::MessageLoopProxy::current()); + EXPECT_EQ(vda_task_runner_, base::ThreadTaskRunnerHandle::Get()); return WEBRTC_VIDEO_CODEC_OK; } diff --git a/content/renderer/media/rtc_video_encoder.cc b/content/renderer/media/rtc_video_encoder.cc index 82e61f6..cfc9b0d 100644 --- a/content/renderer/media/rtc_video_encoder.cc +++ b/content/renderer/media/rtc_video_encoder.cc @@ -8,10 +8,11 @@ #include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_vector.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/histogram.h" #include "base/rand_util.h" +#include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" +#include "base/thread_task_runner_handle.h" #include "media/base/bitstream_buffer.h" #include "media/base/video_frame.h" #include "media/base/video_util.h" @@ -174,7 +175,7 @@ class RTCVideoEncoder::Impl const base::WeakPtr<RTCVideoEncoder> weak_encoder_; // The message loop on which to post callbacks to |weak_encoder_|. - const scoped_refptr<base::MessageLoopProxy> encoder_message_loop_proxy_; + const scoped_refptr<base::SingleThreadTaskRunner> encoder_task_runner_; // Factory for creating VEAs, shared memory buffers, etc. const scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories_; @@ -222,7 +223,7 @@ RTCVideoEncoder::Impl::Impl( const base::WeakPtr<RTCVideoEncoder>& weak_encoder, const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories) : weak_encoder_(weak_encoder), - encoder_message_loop_proxy_(base::MessageLoopProxy::current()), + encoder_task_runner_(base::ThreadTaskRunnerHandle::Get()), gpu_factories_(gpu_factories), async_waiter_(NULL), async_retval_(NULL), @@ -435,13 +436,10 @@ void RTCVideoEncoder::Impl::BitstreamBufferReady(int32 bitstream_buffer_id, image->_frameType = (key_frame ? webrtc::kKeyFrame : webrtc::kDeltaFrame); image->_completeFrame = true; - encoder_message_loop_proxy_->PostTask( + encoder_task_runner_->PostTask( FROM_HERE, - base::Bind(&RTCVideoEncoder::ReturnEncodedImage, - weak_encoder_, - base::Passed(&image), - bitstream_buffer_id, - picture_id_)); + base::Bind(&RTCVideoEncoder::ReturnEncodedImage, weak_encoder_, + base::Passed(&image), bitstream_buffer_id, picture_id_)); // Picture ID must wrap after reaching the maximum. picture_id_ = (picture_id_ + 1) & 0x7FFF; } @@ -464,7 +462,7 @@ void RTCVideoEncoder::Impl::NotifyError( if (async_waiter_) { SignalAsyncWaiter(retval); } else { - encoder_message_loop_proxy_->PostTask( + encoder_task_runner_->PostTask( FROM_HERE, base::Bind(&RTCVideoEncoder::NotifyError, weak_encoder_, retval)); } diff --git a/content/renderer/media/rtc_video_encoder.h b/content/renderer/media/rtc_video_encoder.h index e979ac8..2e3500d 100644 --- a/content/renderer/media/rtc_video_encoder.h +++ b/content/renderer/media/rtc_video_encoder.h @@ -17,10 +17,6 @@ #include "third_party/webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" #include "ui/gfx/geometry/size.h" -namespace base { -class MessageLoopProxy; -} // namespace base - namespace media { class GpuVideoAcceleratorFactories; } // namespace media diff --git a/content/renderer/media/rtc_video_renderer.cc b/content/renderer/media/rtc_video_renderer.cc index 76d2ab4..534a841 100644 --- a/content/renderer/media/rtc_video_renderer.cc +++ b/content/renderer/media/rtc_video_renderer.cc @@ -4,7 +4,7 @@ #include "content/renderer/media/rtc_video_renderer.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "media/base/bind_to_current_loop.h" #include "media/base/video_frame.h" @@ -20,7 +20,7 @@ RTCVideoRenderer::RTCVideoRenderer( const RepaintCB& repaint_cb) : error_cb_(error_cb), repaint_cb_(repaint_cb), - message_loop_proxy_(base::MessageLoopProxy::current()), + task_runner_(base::ThreadTaskRunnerHandle::Get()), state_(STOPPED), frame_size_(kMinFrameSize, kMinFrameSize), video_track_(video_track), @@ -31,7 +31,7 @@ RTCVideoRenderer::~RTCVideoRenderer() { } void RTCVideoRenderer::Start() { - DCHECK(message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK_EQ(state_, STOPPED); AddToVideoTrack( @@ -51,7 +51,7 @@ void RTCVideoRenderer::Start() { } void RTCVideoRenderer::Stop() { - DCHECK(message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(state_ == STARTED || state_ == PAUSED); RemoveFromVideoTrack(this, video_track_); weak_factory_.InvalidateWeakPtrs(); @@ -61,20 +61,20 @@ void RTCVideoRenderer::Stop() { } void RTCVideoRenderer::Play() { - DCHECK(message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); if (state_ == PAUSED) state_ = STARTED; } void RTCVideoRenderer::Pause() { - DCHECK(message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); if (state_ == STARTED) state_ = PAUSED; } void RTCVideoRenderer::OnReadyStateChanged( blink::WebMediaStreamSource::ReadyState state) { - DCHECK(message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); if (state == blink::WebMediaStreamSource::ReadyStateEnded) RenderSignalingFrame(); } @@ -82,7 +82,7 @@ void RTCVideoRenderer::OnReadyStateChanged( void RTCVideoRenderer::OnVideoFrame( const scoped_refptr<media::VideoFrame>& frame, const base::TimeTicks& estimated_capture_time) { - DCHECK(message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); if (state_ != STARTED) return; diff --git a/content/renderer/media/rtc_video_renderer.h b/content/renderer/media/rtc_video_renderer.h index c68b807..edaec04 100644 --- a/content/renderer/media/rtc_video_renderer.h +++ b/content/renderer/media/rtc_video_renderer.h @@ -15,7 +15,7 @@ #include "ui/gfx/geometry/size.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } namespace content { @@ -66,7 +66,7 @@ class CONTENT_EXPORT RTCVideoRenderer const base::Closure error_cb_; const RepaintCB repaint_cb_; - const scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; + const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; State state_; gfx::Size frame_size_; const blink::WebMediaStreamTrack video_track_; diff --git a/content/renderer/media/user_media_client_impl.cc b/content/renderer/media/user_media_client_impl.cc index 5475d2a..e09ccb6 100644 --- a/content/renderer/media/user_media_client_impl.cc +++ b/content/renderer/media/user_media_client_impl.cc @@ -7,11 +7,14 @@ #include <utility> #include "base/hash.h" +#include "base/location.h" #include "base/logging.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/public/renderer/render_frame.h" #include "content/renderer/media/media_stream.h" #include "content/renderer/media/media_stream_audio_source.h" @@ -722,7 +725,7 @@ void UserMediaClientImpl::GetUserMediaRequestSucceeded( // the UserMediaClientImpl is destroyed if the JavaScript code request the // frame to be destroyed within the scope of the callback. Therefore, // post a task to complete the request with a clean stack. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&UserMediaClientImpl::DelayedGetUserMediaRequestSucceeded, weak_factory_.GetWeakPtr(), stream, request_info)); @@ -744,7 +747,7 @@ void UserMediaClientImpl::GetUserMediaRequestFailed( // the UserMediaClientImpl is destroyed if the JavaScript code request the // frame to be destroyed within the scope of the callback. Therefore, // post a task to complete the request with a clean stack. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&UserMediaClientImpl::DelayedGetUserMediaRequestFailed, weak_factory_.GetWeakPtr(), request_info, result, diff --git a/content/renderer/media/video_capture_impl.cc b/content/renderer/media/video_capture_impl.cc index 6b05dd2..9815f46 100644 --- a/content/renderer/media/video_capture_impl.cc +++ b/content/renderer/media/video_capture_impl.cc @@ -13,6 +13,7 @@ #include "base/bind.h" #include "base/stl_util.h" +#include "base/thread_task_runner_handle.h" #include "content/child/child_process.h" #include "content/common/media/video_capture_messages.h" #include "media/base/bind_to_current_loop.h" @@ -55,7 +56,7 @@ VideoCaptureImpl::VideoCaptureImpl( } VideoCaptureImpl::~VideoCaptureImpl() { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); } void VideoCaptureImpl::Init() { @@ -63,20 +64,20 @@ void VideoCaptureImpl::Init() { // different thread than the IO thread, e.g. wherever unittest runs on. // Therefore, this function should define the thread ownership. #if DCHECK_IS_ON() - io_message_loop_ = base::MessageLoopProxy::current(); + io_task_runner_ = base::ThreadTaskRunnerHandle::Get(); #endif message_filter_->AddDelegate(this); } void VideoCaptureImpl::DeInit() { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); if (state_ == VIDEO_CAPTURE_STATE_STARTED) Send(new VideoCaptureHostMsg_Stop(device_id_)); message_filter_->RemoveDelegate(this); } void VideoCaptureImpl::SuspendCapture(bool suspend) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); Send(suspend ? static_cast<IPC::Message*>(new VideoCaptureHostMsg_Pause(device_id_)) : static_cast<IPC::Message*>( @@ -88,7 +89,7 @@ void VideoCaptureImpl::StartCapture( const media::VideoCaptureParams& params, const VideoCaptureStateUpdateCB& state_update_cb, const VideoCaptureDeliverFrameCB& deliver_frame_cb) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); ClientInfo client_info; client_info.params = params; client_info.state_update_cb = state_update_cb; @@ -136,7 +137,7 @@ void VideoCaptureImpl::StartCapture( } void VideoCaptureImpl::StopCapture(int client_id) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); // A client ID can be in only one client list. // If this ID is in any client list, we can just remove it from @@ -157,7 +158,7 @@ void VideoCaptureImpl::StopCapture(int client_id) { void VideoCaptureImpl::GetDeviceSupportedFormats( const VideoCaptureDeviceFormatsCB& callback) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); device_formats_cb_queue_.push_back(callback); if (device_formats_cb_queue_.size() == 1) Send(new VideoCaptureHostMsg_GetDeviceSupportedFormats(device_id_, @@ -166,7 +167,7 @@ void VideoCaptureImpl::GetDeviceSupportedFormats( void VideoCaptureImpl::GetDeviceFormatsInUse( const VideoCaptureDeviceFormatsCB& callback) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); device_formats_in_use_cb_queue_.push_back(callback); if (device_formats_in_use_cb_queue_.size() == 1) Send( @@ -176,7 +177,7 @@ void VideoCaptureImpl::GetDeviceFormatsInUse( void VideoCaptureImpl::OnBufferCreated( base::SharedMemoryHandle handle, int length, int buffer_id) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); // In case client calls StopCapture before the arrival of created buffer, // just close this buffer and return. @@ -200,7 +201,7 @@ void VideoCaptureImpl::OnBufferCreated( } void VideoCaptureImpl::OnBufferDestroyed(int buffer_id) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); const ClientBufferMap::iterator iter = client_buffers_.find(buffer_id); if (iter == client_buffers_.end()) @@ -216,7 +217,7 @@ void VideoCaptureImpl::OnBufferReceived(int buffer_id, const gfx::Rect& visible_rect, base::TimeTicks timestamp, const base::DictionaryValue& metadata) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); @@ -265,7 +266,7 @@ void VideoCaptureImpl::OnMailboxBufferReceived( const gfx::Size& packed_frame_size, base::TimeTicks timestamp, const base::DictionaryValue& metadata) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); @@ -293,13 +294,13 @@ void VideoCaptureImpl::OnClientBufferFinished( int buffer_id, const scoped_refptr<ClientBuffer>& /* ignored_buffer */, uint32 release_sync_point) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); Send(new VideoCaptureHostMsg_BufferReady( device_id_, buffer_id, release_sync_point)); } void VideoCaptureImpl::OnStateChanged(VideoCaptureState state) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); switch (state) { case VIDEO_CAPTURE_STATE_STARTED: @@ -341,7 +342,7 @@ void VideoCaptureImpl::OnStateChanged(VideoCaptureState state) { void VideoCaptureImpl::OnDeviceSupportedFormatsEnumerated( const media::VideoCaptureFormats& supported_formats) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); for (size_t i = 0; i < device_formats_cb_queue_.size(); ++i) device_formats_cb_queue_[i].Run(supported_formats); device_formats_cb_queue_.clear(); @@ -349,14 +350,14 @@ void VideoCaptureImpl::OnDeviceSupportedFormatsEnumerated( void VideoCaptureImpl::OnDeviceFormatsInUseReceived( const media::VideoCaptureFormats& formats_in_use) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); for (size_t i = 0; i < device_formats_in_use_cb_queue_.size(); ++i) device_formats_in_use_cb_queue_[i].Run(formats_in_use); device_formats_in_use_cb_queue_.clear(); } void VideoCaptureImpl::OnDelegateAdded(int32 device_id) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); DVLOG(1) << "OnDelegateAdded: device_id " << device_id; device_id_ = device_id; @@ -371,7 +372,7 @@ void VideoCaptureImpl::OnDelegateAdded(int32 device_id) { } void VideoCaptureImpl::StopDevice() { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); if (state_ == VIDEO_CAPTURE_STATE_STARTED) { state_ = VIDEO_CAPTURE_STATE_STOPPING; @@ -381,7 +382,7 @@ void VideoCaptureImpl::StopDevice() { } void VideoCaptureImpl::RestartCapture() { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); DCHECK_EQ(state_, VIDEO_CAPTURE_STATE_STOPPED); int width = 0; @@ -402,7 +403,7 @@ void VideoCaptureImpl::RestartCapture() { } void VideoCaptureImpl::StartCaptureInternal() { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); DCHECK(device_id_); Send(new VideoCaptureHostMsg_Start(device_id_, session_id_, params_)); @@ -410,12 +411,12 @@ void VideoCaptureImpl::StartCaptureInternal() { } void VideoCaptureImpl::Send(IPC::Message* message) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); message_filter_->Send(message); } bool VideoCaptureImpl::RemoveClient(int client_id, ClientInfoMap* clients) { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(io_task_runner_->BelongsToCurrentThread()); bool found = false; const ClientInfoMap::iterator it = clients->find(client_id); diff --git a/content/renderer/media/video_capture_impl.h b/content/renderer/media/video_capture_impl.h index 38fc4fc..51933a8 100644 --- a/content/renderer/media/video_capture_impl.h +++ b/content/renderer/media/video_capture_impl.h @@ -17,7 +17,7 @@ #include "media/base/video_capture_types.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } // namespace base namespace gpu { @@ -170,7 +170,7 @@ class CONTENT_EXPORT VideoCaptureImpl VideoCaptureState state_; // IO message loop reference for checking correct class operation. - scoped_refptr<base::MessageLoopProxy> io_message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; // WeakPtrFactory pointing back to |this| object, for use with // media::VideoFrames constructed in OnBufferReceived() from buffers cached diff --git a/content/renderer/media/video_capture_impl_manager.cc b/content/renderer/media/video_capture_impl_manager.cc index 3b687ec9..a7c8deb 100644 --- a/content/renderer/media/video_capture_impl_manager.cc +++ b/content/renderer/media/video_capture_impl_manager.cc @@ -26,6 +26,8 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/location.h" +#include "base/thread_task_runner_handle.h" #include "content/child/child_process.h" #include "content/renderer/media/video_capture_impl.h" #include "content/renderer/media/video_capture_message_filter.h" @@ -36,12 +38,12 @@ namespace content { VideoCaptureImplManager::VideoCaptureImplManager() : next_client_id_(0), filter_(new VideoCaptureMessageFilter()), - render_main_message_loop_(base::MessageLoopProxy::current()), + render_main_task_runner_(base::ThreadTaskRunnerHandle::Get()), weak_factory_(this) { } VideoCaptureImplManager::~VideoCaptureImplManager() { - DCHECK(render_main_message_loop_->BelongsToCurrentThread()); + DCHECK(render_main_task_runner_->BelongsToCurrentThread()); if (devices_.empty()) return; // Forcibly release all video capture resources. @@ -57,7 +59,7 @@ VideoCaptureImplManager::~VideoCaptureImplManager() { base::Closure VideoCaptureImplManager::UseDevice( media::VideoCaptureSessionId id) { - DCHECK(render_main_message_loop_->BelongsToCurrentThread()); + DCHECK(render_main_task_runner_->BelongsToCurrentThread()); VideoCaptureImpl* impl = NULL; const VideoCaptureDeviceMap::iterator it = devices_.find(id); @@ -80,7 +82,7 @@ base::Closure VideoCaptureImplManager::StartCapture( const media::VideoCaptureParams& params, const VideoCaptureStateUpdateCB& state_update_cb, const VideoCaptureDeliverFrameCB& deliver_frame_cb) { - DCHECK(render_main_message_loop_->BelongsToCurrentThread()); + DCHECK(render_main_task_runner_->BelongsToCurrentThread()); const VideoCaptureDeviceMap::const_iterator it = devices_.find(id); DCHECK(it != devices_.end()); VideoCaptureImpl* const impl = it->second.second; @@ -100,7 +102,7 @@ base::Closure VideoCaptureImplManager::StartCapture( void VideoCaptureImplManager::GetDeviceSupportedFormats( media::VideoCaptureSessionId id, const VideoCaptureDeviceFormatsCB& callback) { - DCHECK(render_main_message_loop_->BelongsToCurrentThread()); + DCHECK(render_main_task_runner_->BelongsToCurrentThread()); const VideoCaptureDeviceMap::const_iterator it = devices_.find(id); DCHECK(it != devices_.end()); VideoCaptureImpl* const impl = it->second.second; @@ -112,7 +114,7 @@ void VideoCaptureImplManager::GetDeviceSupportedFormats( void VideoCaptureImplManager::GetDeviceFormatsInUse( media::VideoCaptureSessionId id, const VideoCaptureDeviceFormatsCB& callback) { - DCHECK(render_main_message_loop_->BelongsToCurrentThread()); + DCHECK(render_main_task_runner_->BelongsToCurrentThread()); const VideoCaptureDeviceMap::const_iterator it = devices_.find(id); DCHECK(it != devices_.end()); VideoCaptureImpl* const impl = it->second.second; @@ -130,7 +132,7 @@ VideoCaptureImplManager::CreateVideoCaptureImplForTesting( void VideoCaptureImplManager::StopCapture(int client_id, media::VideoCaptureSessionId id) { - DCHECK(render_main_message_loop_->BelongsToCurrentThread()); + DCHECK(render_main_task_runner_->BelongsToCurrentThread()); const VideoCaptureDeviceMap::const_iterator it = devices_.find(id); DCHECK(it != devices_.end()); VideoCaptureImpl* const impl = it->second.second; @@ -141,7 +143,7 @@ void VideoCaptureImplManager::StopCapture(int client_id, void VideoCaptureImplManager::UnrefDevice( media::VideoCaptureSessionId id) { - DCHECK(render_main_message_loop_->BelongsToCurrentThread()); + DCHECK(render_main_task_runner_->BelongsToCurrentThread()); const VideoCaptureDeviceMap::iterator it = devices_.find(id); DCHECK(it != devices_.end()); VideoCaptureImpl* const impl = it->second.second; @@ -159,7 +161,7 @@ void VideoCaptureImplManager::UnrefDevice( } void VideoCaptureImplManager::SuspendDevices(bool suspend) { - DCHECK(render_main_message_loop_->BelongsToCurrentThread()); + DCHECK(render_main_task_runner_->BelongsToCurrentThread()); for (const auto& device : devices_) { VideoCaptureImpl* const impl = device.second.second; ChildProcess::current()->io_task_runner()->PostTask( diff --git a/content/renderer/media/video_capture_impl_manager.h b/content/renderer/media/video_capture_impl_manager.h index 4fce3c7..2b1146a 100644 --- a/content/renderer/media/video_capture_impl_manager.h +++ b/content/renderer/media/video_capture_impl_manager.h @@ -12,7 +12,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "base/synchronization/lock.h" #include "base/threading/thread_checker.h" #include "content/common/content_export.h" @@ -117,7 +117,7 @@ class CONTENT_EXPORT VideoCaptureImplManager { // Hold a pointer to the Render Main message loop to check we operate on the // right thread. - const scoped_refptr<base::MessageLoopProxy> render_main_message_loop_; + const scoped_refptr<base::SingleThreadTaskRunner> render_main_task_runner_; // Bound to the render thread. // NOTE: Weak pointers must be invalidated before all other member variables. diff --git a/content/renderer/media/webrtc/peer_connection_dependency_factory.cc b/content/renderer/media/webrtc/peer_connection_dependency_factory.cc index b3d3283..35f5a31 100644 --- a/content/renderer/media/webrtc/peer_connection_dependency_factory.cc +++ b/content/renderer/media/webrtc/peer_connection_dependency_factory.cc @@ -7,6 +7,7 @@ #include <vector> #include "base/command_line.h" +#include "base/location.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/waitable_event.h" #include "content/common/media/media_stream_messages.h" @@ -303,17 +304,17 @@ void PeerConnectionDependencyFactory::CreatePeerConnectionFactory() { CHECK(chrome_worker_thread_.Start()); base::WaitableEvent start_worker_event(true, false); - chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( - &PeerConnectionDependencyFactory::InitializeWorkerThread, - base::Unretained(this), - &worker_thread_, - &start_worker_event)); + chrome_worker_thread_.task_runner()->PostTask( + FROM_HERE, + base::Bind(&PeerConnectionDependencyFactory::InitializeWorkerThread, + base::Unretained(this), &worker_thread_, &start_worker_event)); base::WaitableEvent create_network_manager_event(true, false); - chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( - &PeerConnectionDependencyFactory::CreateIpcNetworkManagerOnWorkerThread, - base::Unretained(this), - &create_network_manager_event)); + chrome_worker_thread_.task_runner()->PostTask( + FROM_HERE, + base::Bind(&PeerConnectionDependencyFactory:: + CreateIpcNetworkManagerOnWorkerThread, + base::Unretained(this), &create_network_manager_event)); start_worker_event.Wait(); create_network_manager_event.Wait(); @@ -333,11 +334,12 @@ void PeerConnectionDependencyFactory::CreatePeerConnectionFactory() { #endif base::WaitableEvent start_signaling_event(true, false); - chrome_signaling_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( - &PeerConnectionDependencyFactory::InitializeSignalingThread, - base::Unretained(this), - RenderThreadImpl::current()->GetGpuFactories(), - &start_signaling_event)); + chrome_signaling_thread_.task_runner()->PostTask( + FROM_HERE, + base::Bind(&PeerConnectionDependencyFactory::InitializeSignalingThread, + base::Unretained(this), + RenderThreadImpl::current()->GetGpuFactories(), + &start_signaling_event)); start_signaling_event.Wait(); CHECK(signaling_thread_); @@ -600,9 +602,10 @@ void PeerConnectionDependencyFactory::CleanupPeerConnectionFactory() { // The network manager needs to free its resources on the thread they were // created, which is the worked thread. if (chrome_worker_thread_.IsRunning()) { - chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( - &PeerConnectionDependencyFactory::DeleteIpcNetworkManager, - base::Unretained(this))); + chrome_worker_thread_.task_runner()->PostTask( + FROM_HERE, + base::Bind(&PeerConnectionDependencyFactory::DeleteIpcNetworkManager, + base::Unretained(this))); // Stopping the thread will wait until all tasks have been // processed before returning. We wait for the above task to finish before // letting the the function continue to avoid any potential race issues. @@ -630,16 +633,19 @@ PeerConnectionDependencyFactory::CreateAudioCapturer( audio_source); } -scoped_refptr<base::MessageLoopProxy> +scoped_refptr<base::SingleThreadTaskRunner> PeerConnectionDependencyFactory::GetWebRtcWorkerThread() const { DCHECK(CalledOnValidThread()); - return chrome_worker_thread_.message_loop_proxy(); + return chrome_worker_thread_.IsRunning() ? chrome_worker_thread_.task_runner() + : nullptr; } -scoped_refptr<base::MessageLoopProxy> +scoped_refptr<base::SingleThreadTaskRunner> PeerConnectionDependencyFactory::GetWebRtcSignalingThread() const { DCHECK(CalledOnValidThread()); - return chrome_signaling_thread_.message_loop_proxy(); + return chrome_signaling_thread_.IsRunning() + ? chrome_signaling_thread_.task_runner() + : nullptr; } void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { diff --git a/content/renderer/media/webrtc/peer_connection_dependency_factory.h b/content/renderer/media/webrtc/peer_connection_dependency_factory.h index 65fef8f..d3f3e3c 100644 --- a/content/renderer/media/webrtc/peer_connection_dependency_factory.h +++ b/content/renderer/media/webrtc/peer_connection_dependency_factory.h @@ -9,7 +9,7 @@ #include "base/basictypes.h" #include "base/files/file.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/threading/thread.h" #include "content/common/content_export.h" #include "content/public/renderer/render_process_observer.h" @@ -124,8 +124,8 @@ class CONTENT_EXPORT PeerConnectionDependencyFactory WebRtcAudioDeviceImpl* GetWebRtcAudioDevice(); - scoped_refptr<base::MessageLoopProxy> GetWebRtcWorkerThread() const; - scoped_refptr<base::MessageLoopProxy> GetWebRtcSignalingThread() const; + scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcWorkerThread() const; + scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcSignalingThread() const; protected: // Asks the PeerConnection factory to create a Local Audio Source. diff --git a/content/renderer/media/webrtc/webrtc_local_audio_track_adapter.cc b/content/renderer/media/webrtc/webrtc_local_audio_track_adapter.cc index 14c4878..5826505 100644 --- a/content/renderer/media/webrtc/webrtc_local_audio_track_adapter.cc +++ b/content/renderer/media/webrtc/webrtc_local_audio_track_adapter.cc @@ -4,6 +4,7 @@ #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" +#include "base/location.h" #include "base/logging.h" #include "content/renderer/media/media_stream_audio_processor.h" #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" @@ -22,7 +23,7 @@ WebRtcLocalAudioTrackAdapter::Create( webrtc::AudioSourceInterface* track_source) { // TODO(tommi): Change this so that the signaling thread is one of the // parameters to this method. - scoped_refptr<base::MessageLoopProxy> signaling_thread; + scoped_refptr<base::SingleThreadTaskRunner> signaling_thread; RenderThreadImpl* current = RenderThreadImpl::current(); if (current) { PeerConnectionDependencyFactory* pc_factory = diff --git a/content/renderer/media/webrtc/webrtc_video_capturer_adapter.h b/content/renderer/media/webrtc/webrtc_video_capturer_adapter.h index 847dc74..69f2202 100644 --- a/content/renderer/media/webrtc/webrtc_video_capturer_adapter.h +++ b/content/renderer/media/webrtc/webrtc_video_capturer_adapter.h @@ -8,7 +8,6 @@ #include <vector> #include "base/compiler_specific.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/threading/thread_checker.h" #include "content/common/content_export.h" #include "media/base/video_capture_types.h" diff --git a/content/renderer/media/webrtc/webrtc_video_track_adapter.cc b/content/renderer/media/webrtc/webrtc_video_track_adapter.cc index d3c2036..372fd54 100644 --- a/content/renderer/media/webrtc/webrtc_video_track_adapter.cc +++ b/content/renderer/media/webrtc/webrtc_video_track_adapter.cc @@ -4,8 +4,11 @@ #include "content/renderer/media/webrtc/webrtc_video_track_adapter.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/lock.h" +#include "base/thread_task_runner_handle.h" #include "content/common/media/media_stream_options.h" #include "content/renderer/media/media_stream_video_source.h" #include "content/renderer/media/media_stream_video_track.h" @@ -31,7 +34,8 @@ class WebRtcVideoTrackAdapter::WebRtcVideoSourceAdapter : public base::RefCountedThreadSafe<WebRtcVideoSourceAdapter> { public: WebRtcVideoSourceAdapter( - const scoped_refptr<base::MessageLoopProxy>& libjingle_worker_thread, + const scoped_refptr<base::SingleThreadTaskRunner>& + libjingle_worker_thread, const scoped_refptr<webrtc::VideoSourceInterface>& source, WebRtcVideoCapturerAdapter* capture_adapter); @@ -52,7 +56,7 @@ class WebRtcVideoTrackAdapter::WebRtcVideoSourceAdapter friend class base::RefCountedThreadSafe<WebRtcVideoSourceAdapter>; virtual ~WebRtcVideoSourceAdapter(); - scoped_refptr<base::MessageLoopProxy> render_thread_message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> render_thread_task_runner_; // |render_thread_checker_| is bound to the main render thread. base::ThreadChecker render_thread_checker_; @@ -61,7 +65,7 @@ class WebRtcVideoTrackAdapter::WebRtcVideoSourceAdapter // Used for posting frames to libjingle's worker thread. Accessed on the // IO-thread. - scoped_refptr<base::MessageLoopProxy> libjingle_worker_thread_; + scoped_refptr<base::SingleThreadTaskRunner> libjingle_worker_thread_; scoped_refptr<webrtc::VideoSourceInterface> video_source_; @@ -75,10 +79,10 @@ class WebRtcVideoTrackAdapter::WebRtcVideoSourceAdapter }; WebRtcVideoTrackAdapter::WebRtcVideoSourceAdapter::WebRtcVideoSourceAdapter( - const scoped_refptr<base::MessageLoopProxy>& libjingle_worker_thread, + const scoped_refptr<base::SingleThreadTaskRunner>& libjingle_worker_thread, const scoped_refptr<webrtc::VideoSourceInterface>& source, WebRtcVideoCapturerAdapter* capture_adapter) - : render_thread_message_loop_(base::MessageLoopProxy::current()), + : render_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), libjingle_worker_thread_(libjingle_worker_thread), video_source_(source), capture_adapter_(capture_adapter) { diff --git a/content/renderer/media/webrtc_audio_renderer_unittest.cc b/content/renderer/media/webrtc_audio_renderer_unittest.cc index a0fbba3..2d97f1f 100644 --- a/content/renderer/media/webrtc_audio_renderer_unittest.cc +++ b/content/renderer/media/webrtc_audio_renderer_unittest.cc @@ -4,6 +4,7 @@ #include <vector> +#include "base/single_thread_task_runner.h" #include "content/renderer/media/audio_device_factory.h" #include "content/renderer/media/audio_message_filter.h" #include "content/renderer/media/media_stream_audio_renderer.h" @@ -87,11 +88,11 @@ class WebRtcAudioRendererTest : public testing::Test { mock_ipc_(new MockAudioOutputIPC()), mock_output_device_(new FakeAudioOutputDevice( scoped_ptr<media::AudioOutputIPC>(mock_ipc_), - message_loop_->message_loop_proxy())), + message_loop_->task_runner())), factory_(new MockAudioDeviceFactory()), source_(new MockAudioRendererSource()), stream_(new rtc::RefCountedObject<MockMediaStream>("label")), - renderer_(new WebRtcAudioRenderer(message_loop_->message_loop_proxy(), + renderer_(new WebRtcAudioRenderer(message_loop_->task_runner(), stream_, 1, 1, diff --git a/content/renderer/media/webrtc_identity_service.cc b/content/renderer/media/webrtc_identity_service.cc index c85dce1..2f2b790 100644 --- a/content/renderer/media/webrtc_identity_service.cc +++ b/content/renderer/media/webrtc_identity_service.cc @@ -4,6 +4,9 @@ #include "content/renderer/media/webrtc_identity_service.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/common/media/webrtc_identity_messages.h" #include "content/public/renderer/render_thread.h" #include "net/base/net_errors.h" @@ -128,12 +131,10 @@ void WebRTCIdentityService::SendRequest(const RequestInfo& request_info) { request_info.origin, request_info.identity_name, request_info.common_name))) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&WebRTCIdentityService::OnRequestFailed, - base::Unretained(this), - request_info.request_id, - net::ERR_UNEXPECTED)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&WebRTCIdentityService::OnRequestFailed, + base::Unretained(this), request_info.request_id, + net::ERR_UNEXPECTED)); } } diff --git a/content/renderer/media/webrtc_local_audio_renderer.cc b/content/renderer/media/webrtc_local_audio_renderer.cc index 727ed36..b400b45 100644 --- a/content/renderer/media/webrtc_local_audio_renderer.cc +++ b/content/renderer/media/webrtc_local_audio_renderer.cc @@ -4,10 +4,11 @@ #include "content/renderer/media/webrtc_local_audio_renderer.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/histogram.h" #include "base/synchronization/lock.h" +#include "base/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "content/renderer/media/audio_device_factory.h" #include "content/renderer/media/media_stream_dispatcher.h" @@ -84,10 +85,9 @@ void WebRtcLocalAudioRenderer::OnSetFormat( // Post a task on the main render thread to reconfigure the |sink_| with the // new format. - message_loop_->PostTask( + task_runner_->PostTask( FROM_HERE, - base::Bind(&WebRtcLocalAudioRenderer::ReconfigureSink, this, - params)); + base::Bind(&WebRtcLocalAudioRenderer::ReconfigureSink, this, params)); } // WebRtcLocalAudioRenderer::WebRtcLocalAudioRenderer implementation. @@ -99,7 +99,7 @@ WebRtcLocalAudioRenderer::WebRtcLocalAudioRenderer( : audio_track_(audio_track), source_render_frame_id_(source_render_frame_id), session_id_(session_id), - message_loop_(base::MessageLoopProxy::current()), + task_runner_(base::ThreadTaskRunnerHandle::Get()), playing_(false), frames_per_buffer_(frames_per_buffer), volume_(0.0), @@ -108,14 +108,14 @@ WebRtcLocalAudioRenderer::WebRtcLocalAudioRenderer( } WebRtcLocalAudioRenderer::~WebRtcLocalAudioRenderer() { - DCHECK(message_loop_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(!sink_.get()); DVLOG(1) << "WebRtcLocalAudioRenderer::~WebRtcLocalAudioRenderer()"; } void WebRtcLocalAudioRenderer::Start() { DVLOG(1) << "WebRtcLocalAudioRenderer::Start()"; - DCHECK(message_loop_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); // We get audio data from |audio_track_|... MediaStreamAudioSink::AddToAudioTrack(this, audio_track_); @@ -130,7 +130,7 @@ void WebRtcLocalAudioRenderer::Start() { void WebRtcLocalAudioRenderer::Stop() { DVLOG(1) << "WebRtcLocalAudioRenderer::Stop()"; - DCHECK(message_loop_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); { base::AutoLock auto_lock(thread_lock_); @@ -158,7 +158,7 @@ void WebRtcLocalAudioRenderer::Stop() { void WebRtcLocalAudioRenderer::Play() { DVLOG(1) << "WebRtcLocalAudioRenderer::Play()"; - DCHECK(message_loop_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); if (!sink_.get()) return; @@ -177,7 +177,7 @@ void WebRtcLocalAudioRenderer::Play() { void WebRtcLocalAudioRenderer::Pause() { DVLOG(1) << "WebRtcLocalAudioRenderer::Pause()"; - DCHECK(message_loop_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); if (!sink_.get()) return; @@ -191,7 +191,7 @@ void WebRtcLocalAudioRenderer::Pause() { void WebRtcLocalAudioRenderer::SetVolume(float volume) { DVLOG(1) << "WebRtcLocalAudioRenderer::SetVolume(" << volume << ")"; - DCHECK(message_loop_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); { base::AutoLock auto_lock(thread_lock_); @@ -208,7 +208,7 @@ void WebRtcLocalAudioRenderer::SetVolume(float volume) { } base::TimeDelta WebRtcLocalAudioRenderer::GetCurrentRenderTime() const { - DCHECK(message_loop_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); base::AutoLock auto_lock(thread_lock_); if (!sink_.get()) return base::TimeDelta(); @@ -220,7 +220,7 @@ bool WebRtcLocalAudioRenderer::IsLocalRenderer() const { } void WebRtcLocalAudioRenderer::MaybeStartSink() { - DCHECK(message_loop_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); DVLOG(1) << "WebRtcLocalAudioRenderer::MaybeStartSink()"; if (!sink_.get() || !source_params_.IsValid()) @@ -245,7 +245,7 @@ void WebRtcLocalAudioRenderer::MaybeStartSink() { void WebRtcLocalAudioRenderer::ReconfigureSink( const media::AudioParameters& params) { - DCHECK(message_loop_->BelongsToCurrentThread()); + DCHECK(task_runner_->BelongsToCurrentThread()); DVLOG(1) << "WebRtcLocalAudioRenderer::ReconfigureSink()"; diff --git a/content/renderer/media/webrtc_local_audio_renderer.h b/content/renderer/media/webrtc_local_audio_renderer.h index 4764e1b..86147a4 100644 --- a/content/renderer/media/webrtc_local_audio_renderer.h +++ b/content/renderer/media/webrtc_local_audio_renderer.h @@ -9,7 +9,7 @@ #include "base/callback.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/lock.h" #include "base/threading/thread_checker.h" #include "content/common/content_export.h" @@ -113,7 +113,7 @@ class CONTENT_EXPORT WebRtcLocalAudioRenderer // MessageLoop associated with the single thread that performs all control // tasks. Set to the MessageLoop that invoked the ctor. - const scoped_refptr<base::MessageLoopProxy> message_loop_; + const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; // The sink (destination) for rendered audio. scoped_refptr<media::AudioOutputDevice> sink_; diff --git a/content/renderer/npapi/webplugin_impl.cc b/content/renderer/npapi/webplugin_impl.cc index f0f3396..127c574 100644 --- a/content/renderer/npapi/webplugin_impl.cc +++ b/content/renderer/npapi/webplugin_impl.cc @@ -7,13 +7,15 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/debug/crash_logging.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/linked_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/metrics/user_metrics_action.h" +#include "base/single_thread_task_runner.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 "cc/blink/web_layer_impl.h" #include "cc/layers/io_surface_layer.h" #include "content/child/appcache/web_application_cache_host_impl.h" @@ -364,10 +366,9 @@ void WebPluginImpl::updateGeometry(const WebRect& window_rect, // geometry received by a call to setFrameRect in the Webkit // layout code path. To workaround this issue we download the // plugin source url on a timer. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&WebPluginImpl::OnDownloadPluginSrcUrl, - weak_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&WebPluginImpl::OnDownloadPluginSrcUrl, + weak_factory_.GetWeakPtr())); } } diff --git a/content/renderer/p2p/host_address_request.cc b/content/renderer/p2p/host_address_request.cc index 6c7f262..5c7a891 100644 --- a/content/renderer/p2p/host_address_request.cc +++ b/content/renderer/p2p/host_address_request.cc @@ -6,7 +6,9 @@ #include "base/bind.h" #include "base/callback_helpers.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/common/p2p_messages.h" #include "content/renderer/p2p/socket_dispatcher.h" #include "jingle/glue/utils.h" @@ -17,7 +19,7 @@ P2PAsyncAddressResolver::P2PAsyncAddressResolver( P2PSocketDispatcher* dispatcher) : dispatcher_(dispatcher), ipc_task_runner_(dispatcher->task_runner()), - delegate_message_loop_(base::MessageLoopProxy::current()), + delegate_task_runner_(base::ThreadTaskRunnerHandle::Get()), state_(STATE_CREATED), request_id_(0), registered_(false) { @@ -31,7 +33,7 @@ P2PAsyncAddressResolver::~P2PAsyncAddressResolver() { void P2PAsyncAddressResolver::Start(const rtc::SocketAddress& host_name, const DoneCallback& done_callback) { - DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); DCHECK_EQ(STATE_CREATED, state_); state_ = STATE_SENT; @@ -41,7 +43,7 @@ void P2PAsyncAddressResolver::Start(const rtc::SocketAddress& host_name, } void P2PAsyncAddressResolver::Cancel() { - DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); if (state_ != STATE_FINISHED) { state_ = STATE_FINISHED; @@ -78,13 +80,14 @@ void P2PAsyncAddressResolver::OnResponse(const net::IPAddressList& addresses) { dispatcher_->UnregisterHostAddressRequest(request_id_); registered_ = false; - delegate_message_loop_->PostTask(FROM_HERE, base::Bind( - &P2PAsyncAddressResolver::DeliverResponse, this, addresses)); + delegate_task_runner_->PostTask( + FROM_HERE, + base::Bind(&P2PAsyncAddressResolver::DeliverResponse, this, addresses)); } void P2PAsyncAddressResolver::DeliverResponse( const net::IPAddressList& addresses) { - DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); if (state_ == STATE_SENT) { state_ = STATE_FINISHED; base::ResetAndReturn(&done_callback_).Run(addresses); diff --git a/content/renderer/p2p/host_address_request.h b/content/renderer/p2p/host_address_request.h index 4197ebe..25450f3 100644 --- a/content/renderer/p2p/host_address_request.h +++ b/content/renderer/p2p/host_address_request.h @@ -15,7 +15,6 @@ namespace base { class MessageLoop; -class MessageLoopProxy; class SingleThreadTaskRunner; } // namespace base @@ -58,7 +57,7 @@ class P2PAsyncAddressResolver P2PSocketDispatcher* dispatcher_; scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; - scoped_refptr<base::MessageLoopProxy> delegate_message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_; // State must be accessed from delegate thread only. State state_; diff --git a/content/renderer/p2p/ipc_network_manager.cc b/content/renderer/p2p/ipc_network_manager.cc index e279f98..ae0cab7 100644 --- a/content/renderer/p2p/ipc_network_manager.cc +++ b/content/renderer/p2p/ipc_network_manager.cc @@ -3,11 +3,15 @@ // found in the LICENSE file. #include "content/renderer/p2p/ipc_network_manager.h" + #include <string> #include "base/bind.h" #include "base/command_line.h" +#include "base/location.h" #include "base/metrics/histogram.h" +#include "base/single_thread_task_runner.h" #include "base/sys_byteorder.h" +#include "base/thread_task_runner_handle.h" #include "content/public/common/content_switches.h" #include "net/base/net_util.h" @@ -51,10 +55,9 @@ IpcNetworkManager::~IpcNetworkManager() { void IpcNetworkManager::StartUpdating() { if (network_list_received_) { // Post a task to avoid reentrancy. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&IpcNetworkManager::SendNetworksChangedSignal, - weak_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&IpcNetworkManager::SendNetworksChangedSignal, + weak_factory_.GetWeakPtr())); } ++start_count_; } diff --git a/content/renderer/p2p/ipc_socket_factory.cc b/content/renderer/p2p/ipc_socket_factory.cc index e3808e8..6654df0 100644 --- a/content/renderer/p2p/ipc_socket_factory.cc +++ b/content/renderer/p2p/ipc_socket_factory.cc @@ -9,7 +9,6 @@ #include "base/compiler_specific.h" #include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/strings/string_number_conversions.h" diff --git a/content/renderer/p2p/socket_client_impl.cc b/content/renderer/p2p/socket_client_impl.cc index 7994cb0..dc7fb15 100644 --- a/content/renderer/p2p/socket_client_impl.cc +++ b/content/renderer/p2p/socket_client_impl.cc @@ -5,7 +5,9 @@ #include "content/renderer/p2p/socket_client_impl.h" #include "base/bind.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/common/p2p_messages.h" #include "content/renderer/p2p/socket_client_delegate.h" @@ -29,7 +31,7 @@ namespace content { P2PSocketClientImpl::P2PSocketClientImpl(P2PSocketDispatcher* dispatcher) : dispatcher_(dispatcher), ipc_task_runner_(dispatcher->task_runner()), - delegate_message_loop_(base::MessageLoopProxy::current()), + delegate_task_runner_(base::ThreadTaskRunnerHandle::Get()), socket_id_(0), delegate_(NULL), state_(STATE_UNINITIALIZED), @@ -47,7 +49,7 @@ void P2PSocketClientImpl::Init( const net::IPEndPoint& local_address, const P2PHostAndIPEndPoint& remote_address, P2PSocketClientDelegate* delegate) { - DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); DCHECK(delegate); // |delegate_| is only accessesed on |delegate_message_loop_|. delegate_ = delegate; @@ -113,7 +115,7 @@ void P2PSocketClientImpl::SetOption(P2PSocketOption option, } void P2PSocketClientImpl::Close() { - DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); delegate_ = NULL; @@ -139,7 +141,7 @@ int P2PSocketClientImpl::GetSocketID() const { } void P2PSocketClientImpl::SetDelegate(P2PSocketClientDelegate* delegate) { - DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); delegate_ = delegate; } @@ -150,16 +152,15 @@ void P2PSocketClientImpl::OnSocketCreated( DCHECK_EQ(state_, STATE_OPENING); state_ = STATE_OPEN; - delegate_message_loop_->PostTask( - FROM_HERE, - base::Bind(&P2PSocketClientImpl::DeliverOnSocketCreated, this, - local_address, remote_address)); + delegate_task_runner_->PostTask( + FROM_HERE, base::Bind(&P2PSocketClientImpl::DeliverOnSocketCreated, this, + local_address, remote_address)); } void P2PSocketClientImpl::DeliverOnSocketCreated( const net::IPEndPoint& local_address, const net::IPEndPoint& remote_address) { - DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); if (delegate_) delegate_->OnOpen(local_address, remote_address); } @@ -173,21 +174,21 @@ void P2PSocketClientImpl::OnIncomingTcpConnection( new P2PSocketClientImpl(dispatcher_); new_client->socket_id_ = dispatcher_->RegisterClient(new_client.get()); new_client->state_ = STATE_OPEN; - new_client->delegate_message_loop_ = delegate_message_loop_; + new_client->delegate_task_runner_ = delegate_task_runner_; dispatcher_->SendP2PMessage(new P2PHostMsg_AcceptIncomingTcpConnection( socket_id_, address, new_client->socket_id_)); - delegate_message_loop_->PostTask( - FROM_HERE, base::Bind( - &P2PSocketClientImpl::DeliverOnIncomingTcpConnection, - this, address, new_client)); + delegate_task_runner_->PostTask( + FROM_HERE, + base::Bind(&P2PSocketClientImpl::DeliverOnIncomingTcpConnection, this, + address, new_client)); } void P2PSocketClientImpl::DeliverOnIncomingTcpConnection( const net::IPEndPoint& address, scoped_refptr<P2PSocketClient> new_client) { - DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); if (delegate_) { delegate_->OnIncomingTcpConnection(address, new_client.get()); } else { @@ -200,14 +201,14 @@ void P2PSocketClientImpl::OnSendComplete( const P2PSendPacketMetrics& send_metrics) { DCHECK(ipc_task_runner_->BelongsToCurrentThread()); - delegate_message_loop_->PostTask( + delegate_task_runner_->PostTask( FROM_HERE, base::Bind(&P2PSocketClientImpl::DeliverOnSendComplete, this, send_metrics)); } void P2PSocketClientImpl::DeliverOnSendComplete( const P2PSendPacketMetrics& send_metrics) { - DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); if (delegate_) delegate_->OnSendComplete(send_metrics); } @@ -216,12 +217,12 @@ void P2PSocketClientImpl::OnError() { DCHECK(ipc_task_runner_->BelongsToCurrentThread()); state_ = STATE_ERROR; - delegate_message_loop_->PostTask( + delegate_task_runner_->PostTask( FROM_HERE, base::Bind(&P2PSocketClientImpl::DeliverOnError, this)); } void P2PSocketClientImpl::DeliverOnError() { - DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); if (delegate_) delegate_->OnError(); } @@ -231,19 +232,15 @@ void P2PSocketClientImpl::OnDataReceived(const net::IPEndPoint& address, const base::TimeTicks& timestamp) { DCHECK(ipc_task_runner_->BelongsToCurrentThread()); DCHECK_EQ(STATE_OPEN, state_); - delegate_message_loop_->PostTask( - FROM_HERE, - base::Bind(&P2PSocketClientImpl::DeliverOnDataReceived, - this, - address, - data, - timestamp)); + delegate_task_runner_->PostTask( + FROM_HERE, base::Bind(&P2PSocketClientImpl::DeliverOnDataReceived, this, + address, data, timestamp)); } void P2PSocketClientImpl::DeliverOnDataReceived( const net::IPEndPoint& address, const std::vector<char>& data, const base::TimeTicks& timestamp) { - DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); if (delegate_) delegate_->OnDataReceived(address, data, timestamp); } diff --git a/content/renderer/p2p/socket_client_impl.h b/content/renderer/p2p/socket_client_impl.h index 3fde54e..4db0148 100644 --- a/content/renderer/p2p/socket_client_impl.h +++ b/content/renderer/p2p/socket_client_impl.h @@ -111,7 +111,7 @@ class P2PSocketClientImpl : public P2PSocketClient { P2PSocketDispatcher* dispatcher_; scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; - scoped_refptr<base::MessageLoopProxy> delegate_message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_; int socket_id_; P2PSocketClientDelegate* delegate_; State state_; diff --git a/content/renderer/pepper/content_decryptor_delegate.cc b/content/renderer/pepper/content_decryptor_delegate.cc index 82f9894..c54aed4 100644 --- a/content/renderer/pepper/content_decryptor_delegate.cc +++ b/content/renderer/pepper/content_decryptor_delegate.cc @@ -5,7 +5,6 @@ #include "content/renderer/pepper/content_decryptor_delegate.h" #include "base/callback_helpers.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/sparse_histogram.h" #include "base/numerics/safe_conversions.h" #include "base/stl_util.h" diff --git a/content/renderer/pepper/message_channel.cc b/content/renderer/pepper/message_channel.cc index 32956e4..fbdc874 100644 --- a/content/renderer/pepper/message_channel.cc +++ b/content/renderer/pepper/message_channel.cc @@ -8,8 +8,10 @@ #include <string> #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/renderer/pepper/host_array_buffer_var.h" #include "content/renderer/pepper/pepper_plugin_instance_impl.h" #include "content/renderer/pepper/pepper_try_catch.h" @@ -25,8 +27,8 @@ #include "ppapi/shared_impl/var.h" #include "ppapi/shared_impl/var_tracker.h" #include "third_party/WebKit/public/web/WebBindings.h" -#include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" +#include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebElement.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebNode.h" @@ -456,10 +458,9 @@ void MessageChannel::DrainJSMessageQueue() { } void MessageChannel::DrainJSMessageQueueSoon() { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&MessageChannel::DrainJSMessageQueue, - weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&MessageChannel::DrainJSMessageQueue, + weak_ptr_factory_.GetWeakPtr())); } void MessageChannel::UnregisterSyncMessageStatusObserver() { diff --git a/content/renderer/pepper/pepper_device_enumeration_host_helper.cc b/content/renderer/pepper/pepper_device_enumeration_host_helper.cc index edc0840..8429d88 100644 --- a/content/renderer/pepper/pepper_device_enumeration_host_helper.cc +++ b/content/renderer/pepper/pepper_device_enumeration_host_helper.cc @@ -5,9 +5,11 @@ #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "ipc/ipc_message.h" #include "ppapi/c/pp_errors.h" #include "ppapi/host/dispatch_host_message.h" @@ -67,12 +69,9 @@ class PepperDeviceEnumerationHostHelper::ScopedRequest int request_id, const std::vector<ppapi::DeviceRefData>& devices) { if (sync_call_) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&ScopedRequest::EnumerateDevicesCallbackBody, - AsWeakPtr(), - request_id, - devices)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ScopedRequest::EnumerateDevicesCallbackBody, + AsWeakPtr(), request_id, devices)); } else { DCHECK_EQ(request_id_, request_id); callback_.Run(request_id, devices); diff --git a/content/renderer/pepper/pepper_graphics_2d_host.cc b/content/renderer/pepper/pepper_graphics_2d_host.cc index 4449e4a..8b7bd42 100644 --- a/content/renderer/pepper/pepper_graphics_2d_host.cc +++ b/content/renderer/pepper/pepper_graphics_2d_host.cc @@ -5,8 +5,10 @@ #include "content/renderer/pepper/pepper_graphics_2d_host.h" #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "cc/resources/shared_bitmap.h" #include "cc/resources/texture_mailbox.h" @@ -783,7 +785,7 @@ void PepperGraphics2DHost::SendOffscreenFlushAck() { void PepperGraphics2DHost::ScheduleOffscreenFlushAck() { offscreen_flush_pending_ = true; - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&PepperGraphics2DHost::SendOffscreenFlushAck, AsWeakPtr()), base::TimeDelta::FromMilliseconds(kOffscreenCallbackDelayMs)); diff --git a/content/renderer/pepper/pepper_hung_plugin_filter.h b/content/renderer/pepper/pepper_hung_plugin_filter.h index 9da4f5a..34c9bf7 100644 --- a/content/renderer/pepper/pepper_hung_plugin_filter.h +++ b/content/renderer/pepper/pepper_hung_plugin_filter.h @@ -7,7 +7,6 @@ #include "base/files/file_path.h" #include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/synchronization/lock.h" #include "ipc/ipc_channel_proxy.h" #include "ipc/ipc_sync_message_filter.h" diff --git a/content/renderer/pepper/pepper_in_process_router.cc b/content/renderer/pepper/pepper_in_process_router.cc index b6fd7b4..174602f 100644 --- a/content/renderer/pepper/pepper_in_process_router.cc +++ b/content/renderer/pepper/pepper_in_process_router.cc @@ -5,7 +5,9 @@ #include "content/renderer/pepper/pepper_in_process_router.h" #include "base/bind.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/public/renderer/render_thread.h" #include "content/renderer/pepper/renderer_ppapi_host_impl.h" #include "content/renderer/render_frame_impl.h" @@ -109,11 +111,10 @@ bool PepperInProcessRouter::SendToHost(IPC::Message* msg) { // This won't cause message reordering problems because the resource // destroyed message is always the last one sent for a resource. if (message->type() == PpapiHostMsg_ResourceDestroyed::ID) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&PepperInProcessRouter::DispatchHostMsg, - weak_factory_.GetWeakPtr(), - base::Owned(message.release()))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&PepperInProcessRouter::DispatchHostMsg, + weak_factory_.GetWeakPtr(), + base::Owned(message.release()))); return true; } else { bool result = host_impl_->GetPpapiHost()->OnMessageReceived(*message); @@ -144,11 +145,10 @@ bool PepperInProcessRouter::SendToPlugin(IPC::Message* msg) { } else { CHECK(!pending_message_id_); // Dispatch plugin messages from the message loop. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PepperInProcessRouter::DispatchPluginMsg, - weak_factory_.GetWeakPtr(), - base::Owned(message.release()))); + weak_factory_.GetWeakPtr(), base::Owned(message.release()))); } return true; } diff --git a/content/renderer/pepper/pepper_media_device_manager.cc b/content/renderer/pepper/pepper_media_device_manager.cc index 676b2fb..e4dd1f6 100644 --- a/content/renderer/pepper/pepper_media_device_manager.cc +++ b/content/renderer/pepper/pepper_media_device_manager.cc @@ -4,7 +4,10 @@ #include "content/renderer/pepper/pepper_media_device_manager.h" +#include "base/location.h" #include "base/logging.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/renderer/media/media_stream_dispatcher.h" #include "content/renderer/render_frame_impl.h" #include "ppapi/shared_impl/ppb_device_ref_shared.h" @@ -76,11 +79,10 @@ void PepperMediaDeviceManager::StopEnumerateDevices(int request_id) { #if defined(ENABLE_WEBRTC) // Need to post task since this function might be called inside the callback // of EnumerateDevices. - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PepperMediaDeviceManager::StopEnumerateDevicesDelayed, - AsWeakPtr(), - request_id)); + AsWeakPtr(), request_id)); #endif } diff --git a/content/renderer/pepper/pepper_media_stream_audio_track_host.cc b/content/renderer/pepper/pepper_media_stream_audio_track_host.cc index c4b4694..c75a87c 100644 --- a/content/renderer/pepper/pepper_media_stream_audio_track_host.cc +++ b/content/renderer/pepper/pepper_media_stream_audio_track_host.cc @@ -10,8 +10,9 @@ #include "base/location.h" #include "base/logging.h" #include "base/macros.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/numerics/safe_math.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "media/base/audio_bus.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_audio_buffer.h" @@ -71,19 +72,20 @@ PepperMediaStreamAudioTrackHost::AudioSink::AudioSink( active_buffers_generation_(0), active_buffer_frame_offset_(0), buffers_generation_(0), - main_message_loop_proxy_(base::MessageLoopProxy::current()), + main_task_runner_(base::ThreadTaskRunnerHandle::Get()), number_of_buffers_(kDefaultNumberOfBuffers), bytes_per_second_(0), bytes_per_frame_(0), user_buffer_duration_(kDefaultDuration), - weak_factory_(this) {} + weak_factory_(this) { +} PepperMediaStreamAudioTrackHost::AudioSink::~AudioSink() { - DCHECK_EQ(main_message_loop_proxy_, base::MessageLoopProxy::current()); + DCHECK_EQ(main_task_runner_, base::ThreadTaskRunnerHandle::Get()); } void PepperMediaStreamAudioTrackHost::AudioSink::EnqueueBuffer(int32_t index) { - DCHECK_EQ(main_message_loop_proxy_, base::MessageLoopProxy::current()); + DCHECK_EQ(main_task_runner_, base::ThreadTaskRunnerHandle::Get()); DCHECK_GE(index, 0); DCHECK_LT(index, host_->buffer_manager()->number_of_buffers()); base::AutoLock lock(lock_); @@ -93,7 +95,7 @@ void PepperMediaStreamAudioTrackHost::AudioSink::EnqueueBuffer(int32_t index) { int32_t PepperMediaStreamAudioTrackHost::AudioSink::Configure( int32_t number_of_buffers, int32_t duration, const ppapi::host::ReplyMessageContext& context) { - DCHECK_EQ(main_message_loop_proxy_, base::MessageLoopProxy::current()); + DCHECK_EQ(main_task_runner_, base::ThreadTaskRunnerHandle::Get()); if (pending_configure_reply_.is_valid()) { return PP_ERROR_INPROGRESS; @@ -138,7 +140,7 @@ void PepperMediaStreamAudioTrackHost::AudioSink::SetFormatOnMainThread( } void PepperMediaStreamAudioTrackHost::AudioSink::InitBuffers() { - DCHECK_EQ(main_message_loop_proxy_, base::MessageLoopProxy::current()); + DCHECK_EQ(main_task_runner_, base::ThreadTaskRunnerHandle::Get()); { base::AutoLock lock(lock_); // Clear |buffers_|, so the audio thread will drop all incoming audio data. @@ -185,7 +187,7 @@ void PepperMediaStreamAudioTrackHost::AudioSink::InitBuffers() { void PepperMediaStreamAudioTrackHost::AudioSink:: SendEnqueueBufferMessageOnMainThread(int32_t index, int32_t buffers_generation) { - DCHECK_EQ(main_message_loop_proxy_, base::MessageLoopProxy::current()); + DCHECK_EQ(main_task_runner_, base::ThreadTaskRunnerHandle::Get()); // If |InitBuffers()| is called after this task being posted from the audio // thread, the buffer should become invalid already. We should ignore it. // And because only the main thread modifies the |buffers_generation_|, @@ -266,11 +268,10 @@ void PepperMediaStreamAudioTrackHost::AudioSink::OnData( DCHECK_LE(active_buffer_frame_offset_, frames_per_buffer); if (active_buffer_frame_offset_ == frames_per_buffer) { - main_message_loop_proxy_->PostTask( + main_task_runner_->PostTask( FROM_HERE, base::Bind(&AudioSink::SendEnqueueBufferMessageOnMainThread, - weak_factory_.GetWeakPtr(), - active_buffer_index_, + weak_factory_.GetWeakPtr(), active_buffer_index_, buffers_generation_)); active_buffer_index_ = -1; } @@ -299,11 +300,10 @@ void PepperMediaStreamAudioTrackHost::AudioSink::OnSetFormat( audio_thread_checker_.DetachFromThread(); audio_params_ = params; - main_message_loop_proxy_->PostTask( + main_task_runner_->PostTask( FROM_HERE, base::Bind(&AudioSink::SetFormatOnMainThread, - weak_factory_.GetWeakPtr(), - params.GetBytesPerSecond(), + weak_factory_.GetWeakPtr(), params.GetBytesPerSecond(), params.GetBytesPerFrame())); } } diff --git a/content/renderer/pepper/pepper_media_stream_audio_track_host.h b/content/renderer/pepper/pepper_media_stream_audio_track_host.h index 2c93bd2..2e69c91 100644 --- a/content/renderer/pepper/pepper_media_stream_audio_track_host.h +++ b/content/renderer/pepper/pepper_media_stream_audio_track_host.h @@ -20,7 +20,7 @@ #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } // namespace base namespace content { @@ -114,7 +114,7 @@ class PepperMediaStreamAudioTrackHost : public PepperMediaStreamTrackHostBase { // Intended size of each output buffer. int32_t output_buffer_size_; - scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; base::ThreadChecker audio_thread_checker_; diff --git a/content/renderer/pepper/pepper_platform_audio_input.cc b/content/renderer/pepper/pepper_platform_audio_input.cc index 28919df..f306027 100644 --- a/content/renderer/pepper/pepper_platform_audio_input.cc +++ b/content/renderer/pepper/pepper_platform_audio_input.cc @@ -5,8 +5,10 @@ #include "content/renderer/pepper/pepper_platform_audio_input.h" #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "build/build_config.h" #include "content/child/child_process.h" #include "content/renderer/media/audio_input_message_filter.h" @@ -46,7 +48,7 @@ PepperPlatformAudioInput* PepperPlatformAudioInput::Create( } void PepperPlatformAudioInput::StartCapture() { - DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(main_task_runner_->BelongsToCurrentThread()); io_task_runner_->PostTask( FROM_HERE, @@ -54,7 +56,7 @@ void PepperPlatformAudioInput::StartCapture() { } void PepperPlatformAudioInput::StopCapture() { - DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(main_task_runner_->BelongsToCurrentThread()); io_task_runner_->PostTask( FROM_HERE, @@ -62,7 +64,7 @@ void PepperPlatformAudioInput::StopCapture() { } void PepperPlatformAudioInput::ShutDown() { - DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(main_task_runner_->BelongsToCurrentThread()); // Make sure we don't call shutdown more than once. if (!client_) @@ -92,18 +94,12 @@ void PepperPlatformAudioInput::OnStreamCreated( // TODO(yzshen): Make use of circular buffer scheme. crbug.com/181449. DCHECK_EQ(1, total_segments); - if (base::MessageLoopProxy::current().get() != - main_message_loop_proxy_.get()) { + if (base::ThreadTaskRunnerHandle::Get().get() != main_task_runner_.get()) { // If shutdown has occurred, |client_| will be NULL and the handles will be // cleaned up on the main thread. - main_message_loop_proxy_->PostTask( - FROM_HERE, - base::Bind(&PepperPlatformAudioInput::OnStreamCreated, - this, - handle, - socket_handle, - length, - total_segments)); + main_task_runner_->PostTask( + FROM_HERE, base::Bind(&PepperPlatformAudioInput::OnStreamCreated, this, + handle, socket_handle, length, total_segments)); } else { // Must dereference the client only on the main thread. Shutdown may have // occurred while the request was in-flight, so we need to NULL check. @@ -138,7 +134,7 @@ PepperPlatformAudioInput::~PepperPlatformAudioInput() { PepperPlatformAudioInput::PepperPlatformAudioInput() : client_(NULL), - main_message_loop_proxy_(base::MessageLoopProxy::current()), + main_task_runner_(base::ThreadTaskRunnerHandle::Get()), io_task_runner_(ChildProcess::current()->io_task_runner()), render_frame_id_(MSG_ROUTING_NONE), create_stream_sent_(false), @@ -153,7 +149,7 @@ bool PepperPlatformAudioInput::Initialize( int sample_rate, int frames_per_buffer, PepperAudioInputHost* client) { - DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(main_task_runner_->BelongsToCurrentThread()); RenderFrameImpl* const render_frame = RenderFrameImpl::FromRoutingID(render_frame_id); @@ -222,7 +218,7 @@ void PepperPlatformAudioInput::ShutDownOnIOThread() { StopCaptureOnIOThread(); - main_message_loop_proxy_->PostTask( + main_task_runner_->PostTask( FROM_HERE, base::Bind(&PepperPlatformAudioInput::CloseDevice, this)); Release(); // Release for the delegate, balances out the reference taken in @@ -232,7 +228,7 @@ void PepperPlatformAudioInput::ShutDownOnIOThread() { void PepperPlatformAudioInput::OnDeviceOpened(int request_id, bool succeeded, const std::string& label) { - DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(main_task_runner_->BelongsToCurrentThread()); pending_open_device_ = false; pending_open_device_id_ = -1; @@ -258,7 +254,7 @@ void PepperPlatformAudioInput::OnDeviceOpened(int request_id, } void PepperPlatformAudioInput::CloseDevice() { - DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(main_task_runner_->BelongsToCurrentThread()); if (!label_.empty()) { PepperMediaDeviceManager* const device_manager = GetMediaDeviceManager(); @@ -276,14 +272,14 @@ void PepperPlatformAudioInput::CloseDevice() { } void PepperPlatformAudioInput::NotifyStreamCreationFailed() { - DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(main_task_runner_->BelongsToCurrentThread()); if (client_) client_->StreamCreationFailed(); } PepperMediaDeviceManager* PepperPlatformAudioInput::GetMediaDeviceManager() { - DCHECK(main_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(main_task_runner_->BelongsToCurrentThread()); RenderFrameImpl* const render_frame = RenderFrameImpl::FromRoutingID(render_frame_id_); diff --git a/content/renderer/pepper/pepper_platform_audio_input.h b/content/renderer/pepper/pepper_platform_audio_input.h index ae5a610..a1ea3cb 100644 --- a/content/renderer/pepper/pepper_platform_audio_input.h +++ b/content/renderer/pepper/pepper_platform_audio_input.h @@ -19,7 +19,6 @@ class GURL; namespace base { class SingleThreadTaskRunner; -class MessageLoopProxy; } namespace media { @@ -104,7 +103,7 @@ class PepperPlatformAudioInput // I/O THREAD. scoped_ptr<media::AudioInputIPC> ipc_; - scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; // The frame containing the Pepper widget. diff --git a/content/renderer/pepper/pepper_platform_audio_output.cc b/content/renderer/pepper/pepper_platform_audio_output.cc index e0a990a..1f8a8e6 100644 --- a/content/renderer/pepper/pepper_platform_audio_output.cc +++ b/content/renderer/pepper/pepper_platform_audio_output.cc @@ -5,8 +5,10 @@ #include "content/renderer/pepper/pepper_platform_audio_output.h" #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "build/build_config.h" #include "content/child/child_process.h" #include "content/common/media/audio_messages.h" @@ -83,20 +85,15 @@ void PepperPlatformAudioOutput::OnStreamCreated( #endif DCHECK(length); - if (base::MessageLoopProxy::current().get() == - main_message_loop_proxy_.get()) { + if (base::ThreadTaskRunnerHandle::Get().get() == main_task_runner_.get()) { // Must dereference the client only on the main thread. Shutdown may have // occurred while the request was in-flight, so we need to NULL check. if (client_) client_->StreamCreated(handle, length, socket_handle); } else { - main_message_loop_proxy_->PostTask( - FROM_HERE, - base::Bind(&PepperPlatformAudioOutput::OnStreamCreated, - this, - handle, - socket_handle, - length)); + main_task_runner_->PostTask( + FROM_HERE, base::Bind(&PepperPlatformAudioOutput::OnStreamCreated, this, + handle, socket_handle, length)); } } @@ -111,7 +108,7 @@ PepperPlatformAudioOutput::~PepperPlatformAudioOutput() { PepperPlatformAudioOutput::PepperPlatformAudioOutput() : client_(NULL), - main_message_loop_proxy_(base::MessageLoopProxy::current()), + main_task_runner_(base::ThreadTaskRunnerHandle::Get()), io_task_runner_(ChildProcess::current()->io_task_runner()) { } diff --git a/content/renderer/pepper/pepper_platform_audio_output.h b/content/renderer/pepper/pepper_platform_audio_output.h index 91b922b..86bce78 100644 --- a/content/renderer/pepper/pepper_platform_audio_output.h +++ b/content/renderer/pepper/pepper_platform_audio_output.h @@ -15,7 +15,6 @@ class AudioParameters; } namespace base { -class MessageLoopProxy; class SingleThreadTaskRunner; } @@ -81,7 +80,7 @@ class PepperPlatformAudioOutput // I/O thread except to send messages and get the message loop. scoped_ptr<media::AudioOutputIPC> ipc_; - scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioOutput); diff --git a/content/renderer/pepper/pepper_platform_camera_device.cc b/content/renderer/pepper/pepper_platform_camera_device.cc index c3dfff2..2be016f 100644 --- a/content/renderer/pepper/pepper_platform_camera_device.cc +++ b/content/renderer/pepper/pepper_platform_camera_device.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" #include "content/renderer/media/video_capture_impl_manager.h" #include "content/renderer/pepper/gfx_conversion.h" #include "content/renderer/pepper/pepper_camera_device_host.h" diff --git a/content/renderer/pepper/pepper_platform_video_capture.cc b/content/renderer/pepper/pepper_platform_video_capture.cc index 68ef480..eb6e748 100644 --- a/content/renderer/pepper/pepper_platform_video_capture.cc +++ b/content/renderer/pepper/pepper_platform_video_capture.cc @@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" #include "content/renderer/media/video_capture_impl_manager.h" #include "content/renderer/pepper/pepper_media_device_manager.h" #include "content/renderer/pepper/pepper_video_capture_host.h" diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 4246837..fec64c4 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -6,14 +6,16 @@ #include "base/bind.h" #include "base/callback_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/metrics/histogram.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_offset_string_conversions.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "base/trace_event/trace_event.h" #include "cc/blink/web_layer_impl.h" @@ -1620,10 +1622,9 @@ bool PepperPluginInstanceImpl::IsAcceptingWheelEvents() const { void PepperPluginInstanceImpl::ScheduleAsyncDidChangeView() { if (view_change_weak_ptr_factory_.HasWeakPtrs()) return; // Already scheduled. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&PepperPluginInstanceImpl::SendAsyncDidChangeView, - view_change_weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&PepperPluginInstanceImpl::SendAsyncDidChangeView, + view_change_weak_ptr_factory_.GetWeakPtr())); } void PepperPluginInstanceImpl::SendAsyncDidChangeView() { @@ -2836,11 +2837,10 @@ void PepperPluginInstanceImpl::SelectionChanged(PP_Instance instance) { // uses a weak pointer rather than exploiting the fact that this class is // refcounted because we don't actually want this operation to affect the // lifetime of the instance. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&PepperPluginInstanceImpl::RequestSurroundingText, - weak_factory_.GetWeakPtr(), - static_cast<size_t>(kExtraCharsForTextInput))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&PepperPluginInstanceImpl::RequestSurroundingText, + weak_factory_.GetWeakPtr(), + static_cast<size_t>(kExtraCharsForTextInput))); } void PepperPluginInstanceImpl::UpdateSurroundingText(PP_Instance instance, @@ -3137,7 +3137,7 @@ bool PepperPluginInstanceImpl::FlashSetFullscreen(bool fullscreen, if (!delay_report) { ReportGeometry(); } else { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&PepperPluginInstanceImpl::ReportGeometry, this)); } diff --git a/content/renderer/pepper/plugin_module.cc b/content/renderer/pepper/plugin_module.cc index 2752840..78ed470 100644 --- a/content/renderer/pepper/plugin_module.cc +++ b/content/renderer/pepper/plugin_module.cc @@ -11,7 +11,6 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/time/time.h" #include "build/build_config.h" #include "content/common/view_messages.h" diff --git a/content/renderer/pepper/ppb_graphics_3d_impl.cc b/content/renderer/pepper/ppb_graphics_3d_impl.cc index 2de5e10..662945c 100644 --- a/content/renderer/pepper/ppb_graphics_3d_impl.cc +++ b/content/renderer/pepper/ppb_graphics_3d_impl.cc @@ -6,8 +6,10 @@ #include "base/bind.h" #include "base/command_line.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "content/common/gpu/client/command_buffer_proxy_impl.h" #include "content/common/gpu/client/gpu_channel_host.h" #include "content/public/common/content_switches.h" @@ -354,10 +356,9 @@ void PPB_Graphics3D_Impl::OnContextLost() { // Send context lost to plugin. This may have been caused by a PPAPI call, so // avoid re-entering. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&PPB_Graphics3D_Impl::SendContextLost, - weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&PPB_Graphics3D_Impl::SendContextLost, + weak_ptr_factory_.GetWeakPtr())); } void PPB_Graphics3D_Impl::SendContextLost() { diff --git a/content/renderer/pepper/ppb_scrollbar_impl.cc b/content/renderer/pepper/ppb_scrollbar_impl.cc index 93b333b..3bf6a3b 100644 --- a/content/renderer/pepper/ppb_scrollbar_impl.cc +++ b/content/renderer/pepper/ppb_scrollbar_impl.cc @@ -5,8 +5,10 @@ #include "content/renderer/pepper/ppb_scrollbar_impl.h" #include "base/bind.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/renderer/pepper/event_conversion.h" #include "content/renderer/pepper/host_globals.h" #include "content/renderer/pepper/pepper_plugin_instance_impl.h" @@ -204,10 +206,9 @@ void PPB_Scrollbar_Impl::invalidateScrollbarRect( // Note: we use a WeakPtrFactory here so that a lingering callback can not // modify the lifetime of this object. Otherwise, blink::WebPluginScrollbar // could outlive blink::WebPluginContainer, which is against its contract. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&PPB_Scrollbar_Impl::NotifyInvalidate, - weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&PPB_Scrollbar_Impl::NotifyInvalidate, + weak_ptr_factory_.GetWeakPtr())); } void PPB_Scrollbar_Impl::getTickmarks( diff --git a/content/renderer/pepper/renderer_ppapi_host_impl.cc b/content/renderer/pepper/renderer_ppapi_host_impl.cc index 61c1ba6..d97edc3 100644 --- a/content/renderer/pepper/renderer_ppapi_host_impl.cc +++ b/content/renderer/pepper/renderer_ppapi_host_impl.cc @@ -6,9 +6,11 @@ #include "base/bind.h" #include "base/files/file_path.h" +#include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop.h" #include "base/process/process_handle.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/common/sandbox_util.h" #include "content/renderer/pepper/fullscreen_container.h" #include "content/renderer/pepper/host_globals.h" @@ -249,7 +251,7 @@ void RendererPpapiHostImpl::CreateBrowserResourceHosts( PepperBrowserConnection* browser_connection = PepperBrowserConnection::Get(render_frame); if (!browser_connection) { - base::MessageLoop::current()->PostTask( + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(callback, std::vector<int>(nested_msgs.size(), 0))); } else { diff --git a/content/renderer/pepper/url_response_info_util.cc b/content/renderer/pepper/url_response_info_util.cc index 2636e19..736a95c 100644 --- a/content/renderer/pepper/url_response_info_util.cc +++ b/content/renderer/pepper/url_response_info_util.cc @@ -6,7 +6,9 @@ #include "base/bind.h" #include "base/files/file_path.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/public/renderer/renderer_ppapi_host.h" #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" #include "content/renderer/pepper/renderer_ppapi_host_impl.h" @@ -106,8 +108,8 @@ void DataFromWebURLResponse(RendererPpapiHostImpl* host_impl, renderer_pending_host_id, callback)); } else { - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, data)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, + base::Bind(callback, data)); } } diff --git a/content/renderer/pepper/v8_var_converter.h b/content/renderer/pepper/v8_var_converter.h index 2a5a9f9..6e53726 100644 --- a/content/renderer/pepper/v8_var_converter.h +++ b/content/renderer/pepper/v8_var_converter.h @@ -8,7 +8,6 @@ #include "base/basictypes.h" #include "base/callback.h" #include "base/compiler_specific.h" -#include "base/message_loop/message_loop_proxy.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_var.h" #include "ppapi/shared_impl/scoped_pp_var.h" diff --git a/content/renderer/pepper/video_decoder_shim.cc b/content/renderer/pepper/video_decoder_shim.cc index 68130c7c..e875f3b 100644 --- a/content/renderer/pepper/video_decoder_shim.cc +++ b/content/renderer/pepper/video_decoder_shim.cc @@ -9,6 +9,8 @@ #include <GLES2/gl2extchromium.h> #include "base/bind.h" +#include "base/location.h" +#include "base/thread_task_runner_handle.h" #ifndef NDEBUG #include "base/logging.h" #endif @@ -669,7 +671,7 @@ class VideoDecoderShim::DecoderImpl { // WeakPtr is bound to main_message_loop_. Use only in shim callbacks. base::WeakPtr<VideoDecoderShim> shim_; scoped_ptr<media::VideoDecoder> decoder_; - scoped_refptr<base::MessageLoopProxy> main_message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; // Queue of decodes waiting for the decoder. typedef std::queue<PendingDecode> PendingDecodeQueue; PendingDecodeQueue pending_decodes_; @@ -685,7 +687,7 @@ class VideoDecoderShim::DecoderImpl { VideoDecoderShim::DecoderImpl::DecoderImpl( const base::WeakPtr<VideoDecoderShim>& proxy) : shim_(proxy), - main_message_loop_(base::MessageLoopProxy::current()), + main_task_runner_(base::ThreadTaskRunnerHandle::Get()), awaiting_decoder_(false), decode_id_(0) { } @@ -700,12 +702,12 @@ void VideoDecoderShim::DecoderImpl::Initialize( #if !defined(MEDIA_DISABLE_LIBVPX) if (config.codec() == media::kCodecVP9) { decoder_.reset( - new media::VpxVideoDecoder(base::MessageLoopProxy::current())); + new media::VpxVideoDecoder(base::ThreadTaskRunnerHandle::Get())); } else #endif { scoped_ptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder( - new media::FFmpegVideoDecoder(base::MessageLoopProxy::current())); + new media::FFmpegVideoDecoder(base::ThreadTaskRunnerHandle::Get())); ffmpeg_video_decoder->set_decode_nalus(true); decoder_ = ffmpeg_video_decoder.Pass(); } @@ -740,11 +742,9 @@ void VideoDecoderShim::DecoderImpl::Reset() { while (!pending_decodes_.empty()) { const PendingDecode& decode = pending_decodes_.front(); scoped_ptr<PendingFrame> pending_frame(new PendingFrame(decode.decode_id)); - main_message_loop_->PostTask(FROM_HERE, - base::Bind(&VideoDecoderShim::OnDecodeComplete, - shim_, - media::VideoDecoder::kAborted, - decode.decode_id)); + main_task_runner_->PostTask( + FROM_HERE, base::Bind(&VideoDecoderShim::OnDecodeComplete, shim_, + media::VideoDecoder::kAborted, decode.decode_id)); pending_decodes_.pop(); } decoder_->Reset(base::Bind(&VideoDecoderShim::DecoderImpl::OnResetComplete, @@ -778,12 +778,9 @@ void VideoDecoderShim::DecoderImpl::OnPipelineStatus( // Calculate how many textures the shim should create. uint32_t shim_texture_pool_size = media::limits::kMaxVideoFrames + 1; - main_message_loop_->PostTask( - FROM_HERE, - base::Bind(&VideoDecoderShim::OnInitializeComplete, - shim_, - result, - shim_texture_pool_size)); + main_task_runner_->PostTask( + FROM_HERE, base::Bind(&VideoDecoderShim::OnInitializeComplete, shim_, + result, shim_texture_pool_size)); } void VideoDecoderShim::DecoderImpl::DoDecode() { @@ -819,10 +816,9 @@ void VideoDecoderShim::DecoderImpl::OnDecodeComplete( break; } - main_message_loop_->PostTask( - FROM_HERE, - base::Bind( - &VideoDecoderShim::OnDecodeComplete, shim_, result, decode_id_)); + main_task_runner_->PostTask( + FROM_HERE, base::Bind(&VideoDecoderShim::OnDecodeComplete, shim_, result, + decode_id_)); DoDecode(); } @@ -840,14 +836,13 @@ void VideoDecoderShim::DecoderImpl::OnOutputComplete( pending_frame.reset(new PendingFrame(decode_id_)); } - main_message_loop_->PostTask(FROM_HERE, - base::Bind(&VideoDecoderShim::OnOutputComplete, - shim_, - base::Passed(&pending_frame))); + main_task_runner_->PostTask( + FROM_HERE, base::Bind(&VideoDecoderShim::OnOutputComplete, shim_, + base::Passed(&pending_frame))); } void VideoDecoderShim::DecoderImpl::OnResetComplete() { - main_message_loop_->PostTask( + main_task_runner_->PostTask( FROM_HERE, base::Bind(&VideoDecoderShim::OnResetComplete, shim_)); } diff --git a/content/renderer/pepper/video_encoder_shim.cc b/content/renderer/pepper/video_encoder_shim.cc index 3fcf261..b69bab0 100644 --- a/content/renderer/pepper/video_encoder_shim.cc +++ b/content/renderer/pepper/video_encoder_shim.cc @@ -10,9 +10,11 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/location.h" #include "base/memory/scoped_vector.h" #include "base/memory/shared_memory.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "content/renderer/pepper/pepper_video_encoder_host.h" #include "content/renderer/render_thread_impl.h" #include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" @@ -99,7 +101,7 @@ class VideoEncoderShim::EncoderImpl { VideoEncoderShim::EncoderImpl::EncoderImpl( const base::WeakPtr<VideoEncoderShim>& shim) : shim_(shim), - renderer_task_runner_(base::MessageLoopProxy::current()), + renderer_task_runner_(base::ThreadTaskRunnerHandle::Get()), initialized_(false) { } diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 842e93f..f9c71e7 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -17,6 +17,7 @@ #include "base/process/process.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "cc/base/switches.h" #include "content/child/appcache/appcache_dispatcher.h" @@ -1649,7 +1650,7 @@ void RenderFrameImpl::OnPostMessageEvent( blink::WebMessagePortChannelArray channels = WebMessagePortChannelImpl::CreatePorts( params.message_ports, params.new_routing_ids, - base::MessageLoopProxy::current().get()); + base::ThreadTaskRunnerHandle::Get().get()); WebSerializedScriptValue serialized_script_value; if (params.is_data_raw_string) { @@ -2005,7 +2006,7 @@ blink::WebMediaPlayer* RenderFrameImpl::createMediaPlayer( static_cast<RenderFrame*>(this)), render_thread->GetAudioRendererMixerManager()->CreateInput(routing_id_), media_log, render_thread->GetMediaThreadTaskRunner(), - render_thread->compositor_message_loop_proxy(), + render_thread->compositor_task_runner(), base::Bind(&GetSharedMainThreadContext3D), GetMediaPermission(), initial_cdm); diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index bc9e6e9..29d649b 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -12,6 +12,7 @@ #include "base/allocator/allocator_extension.h" #include "base/command_line.h" #include "base/lazy_instance.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/discardable_memory_allocator.h" #include "base/memory/shared_memory.h" @@ -24,6 +25,7 @@ #include "base/strings/string_tokenizer.h" #include "base/strings/sys_string_conversions.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/simple_thread.h" #include "base/threading/thread_local.h" #include "base/threading/thread_restrictions.h" @@ -540,9 +542,8 @@ void RenderThreadImpl::Init() { webrtc_identity_service_.reset(new WebRTCIdentityService()); - aec_dump_message_filter_ = - new AecDumpMessageFilter(GetIOMessageLoopProxy(), - message_loop()->message_loop_proxy()); + aec_dump_message_filter_ = new AecDumpMessageFilter( + GetIOMessageLoopProxy(), message_loop()->task_runner()); AddFilter(aec_dump_message_filter_.get()); peer_connection_factory_.reset(new PeerConnectionDependencyFactory( @@ -1044,18 +1045,16 @@ void RenderThreadImpl::EnsureWebKitInitialized() { #if defined(OS_ANDROID) if (SynchronousCompositorFactory* factory = SynchronousCompositorFactory::GetInstance()) - compositor_message_loop_proxy_ = - factory->GetCompositorMessageLoop(); + compositor_task_runner_ = factory->GetCompositorTaskRunner(); #endif - if (!compositor_message_loop_proxy_.get()) { + if (!compositor_task_runner_.get()) { compositor_thread_.reset(new base::Thread("Compositor")); compositor_thread_->Start(); #if defined(OS_ANDROID) compositor_thread_->SetPriority(base::ThreadPriority::DISPLAY); #endif - compositor_message_loop_proxy_ = - compositor_thread_->message_loop_proxy(); - compositor_message_loop_proxy_->PostTask( + compositor_task_runner_ = compositor_thread_->task_runner(); + compositor_task_runner_->PostTask( FROM_HERE, base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), false)); @@ -1072,12 +1071,12 @@ void RenderThreadImpl::EnsureWebKitInitialized() { scoped_refptr<InputEventFilter> compositor_input_event_filter( new InputEventFilter(main_input_callback_.callback(), main_thread_compositor_task_runner_, - compositor_message_loop_proxy_)); + compositor_task_runner_)); input_handler_manager_client = compositor_input_event_filter.get(); input_event_filter_ = compositor_input_event_filter; } input_handler_manager_.reset(new InputHandlerManager( - compositor_message_loop_proxy_, input_handler_manager_client, + compositor_task_runner_, input_handler_manager_client, renderer_scheduler_.get())); } @@ -1091,14 +1090,14 @@ void RenderThreadImpl::EnsureWebKitInitialized() { } AddFilter(input_event_filter_.get()); - scoped_refptr<base::MessageLoopProxy> compositor_impl_side_loop; + scoped_refptr<base::SingleThreadTaskRunner> compositor_impl_side_task_runner; if (enable) - compositor_impl_side_loop = compositor_message_loop_proxy_; + compositor_impl_side_task_runner = compositor_task_runner_; else - compositor_impl_side_loop = base::MessageLoopProxy::current(); + compositor_impl_side_task_runner = base::ThreadTaskRunnerHandle::Get(); compositor_message_filter_ = new CompositorForwardingMessageFilter( - compositor_impl_side_loop.get()); + compositor_impl_side_task_runner.get()); AddFilter(compositor_message_filter_.get()); RenderThreadImpl::RegisterSchemes(); @@ -1444,7 +1443,7 @@ RenderThreadImpl::GetCompositorMainThreadTaskRunner() { scoped_refptr<base::SingleThreadTaskRunner> RenderThreadImpl::GetCompositorImplThreadTaskRunner() { - return compositor_message_loop_proxy_; + return compositor_task_runner_; } gpu::GpuMemoryBufferManager* RenderThreadImpl::GetGpuMemoryBufferManager() { @@ -1798,14 +1797,14 @@ void RenderThreadImpl::OnMemoryPressure( } } -scoped_refptr<base::MessageLoopProxy> +scoped_refptr<base::SingleThreadTaskRunner> RenderThreadImpl::GetFileThreadMessageLoopProxy() { DCHECK(message_loop() == base::MessageLoop::current()); if (!file_thread_) { file_thread_.reset(new base::Thread("Renderer::FILE")); file_thread_->Start(); } - return file_thread_->message_loop_proxy(); + return file_thread_->task_runner(); } scoped_refptr<base::SingleThreadTaskRunner> @@ -1820,7 +1819,7 @@ RenderThreadImpl::GetMediaThreadTaskRunner() { AddFilter(renderer_demuxer_.get()); #endif } - return media_thread_->message_loop_proxy(); + return media_thread_->task_runner(); } void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h index 7231634..68b9df6 100644 --- a/content/renderer/render_thread_impl.h +++ b/content/renderer/render_thread_impl.h @@ -47,7 +47,6 @@ class WebMediaStreamCenterClient; } namespace base { -class MessageLoopProxy; class SingleThreadTaskRunner; class Thread; } @@ -244,8 +243,8 @@ class CONTENT_EXPORT RenderThreadImpl } // Will be null if threaded compositing has not been enabled. - scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy() const { - return compositor_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner() const { + return compositor_task_runner_; } AppCacheDispatcher* appcache_dispatcher() const { @@ -309,10 +308,10 @@ class CONTENT_EXPORT RenderThreadImpl // has been lost. GpuChannelHost* GetGpuChannel(); - // Returns a MessageLoopProxy instance corresponding to the message loop + // Returns a SingleThreadTaskRunner instance corresponding to the message loop // of the thread on which file operations should be run. Must be called // on the renderer's main thread. - scoped_refptr<base::MessageLoopProxy> GetFileThreadMessageLoopProxy(); + scoped_refptr<base::SingleThreadTaskRunner> GetFileThreadMessageLoopProxy(); // Returns a SingleThreadTaskRunner instance corresponding to the message loop // of the thread on which media operations should be run. Must be called @@ -560,9 +559,9 @@ class CONTENT_EXPORT RenderThreadImpl // Thread for running multimedia operations (e.g., video decoding). scoped_ptr<base::Thread> media_thread_; - // Will point to appropriate MessageLoopProxy after initialization, + // Will point to appropriate task runner after initialization, // regardless of whether |compositor_thread_| is overriden. - scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; // Threads used by compositor for rasterization. ScopedVector<base::SimpleThread> compositor_raster_threads_; diff --git a/content/renderer/render_thread_impl_browsertest.cc b/content/renderer/render_thread_impl_browsertest.cc index 264826d..ccff53f 100644 --- a/content/renderer/render_thread_impl_browsertest.cc +++ b/content/renderer/render_thread_impl_browsertest.cc @@ -4,8 +4,10 @@ #include "base/callback.h" #include "base/command_line.h" +#include "base/location.h" #include "base/memory/discardable_memory.h" #include "base/memory/scoped_vector.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/thread_task_runner_handle.h" #include "content/common/in_process_child_thread_params.h" @@ -121,7 +123,8 @@ class QuitOnTestMsgFilter : public IPC::MessageFilter { // IPC::MessageFilter overrides: bool OnMessageReceived(const IPC::Message& message) override { - message_loop_->PostTask(FROM_HERE, base::Bind(&QuitTask, message_loop_)); + message_loop_->task_runner()->PostTask( + FROM_HERE, base::Bind(&QuitTask, message_loop_)); return true; } @@ -195,7 +198,7 @@ TEST_F(RenderThreadImplBrowserTest, WILL_LEAK(InputHandlerManagerDestroyedAfterCompositorThread)) { ASSERT_TRUE(thread_->input_handler_manager()); - thread_->compositor_message_loop_proxy()->PostTask( + thread_->compositor_task_runner()->PostTask( FROM_HERE, base::Bind(&CheckRenderThreadInputHandlerManager, thread_)); } diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc index bf2f15d..8cb8e2a 100644 --- a/content/renderer/render_view_browsertest.cc +++ b/content/renderer/render_view_browsertest.cc @@ -5,9 +5,12 @@ #include "base/basictypes.h" #include "base/bind.h" #include "base/callback.h" +#include "base/location.h" #include "base/memory/shared_memory.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/time/time.h" #include "base/win/windows_version.h" #include "content/child/request_extra_data.h" @@ -2425,8 +2428,9 @@ TEST_F(DevToolsAgentTest, DevToolsResumeOnClose) { // Executing javascript will pause the thread and create nested message loop. // Posting task simulates message coming from browser. - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( - &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); ExecuteJavaScript("debugger;"); // CloseWhilePaused should resume execution and continue here. diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index b528457..821990b 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -18,7 +18,6 @@ #include "base/json/json_writer.h" #include "base/lazy_instance.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/process/kill.h" diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc index d0e593a..c04cffa 100644 --- a/content/renderer/renderer_blink_platform_impl.cc +++ b/content/renderer/renderer_blink_platform_impl.cc @@ -7,13 +7,15 @@ #include "base/command_line.h" #include "base/files/file_path.h" #include "base/lazy_instance.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/shared_memory.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/metrics/histogram.h" #include "base/numerics/safe_conversions.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "build/build_config.h" #include "cc/blink/context_provider_web_context.h" #include "components/scheduler/child/web_scheduler_impl.h" @@ -639,7 +641,7 @@ bool RendererBlinkPlatformImpl::canAccelerate2dCanvas() { bool RendererBlinkPlatformImpl::isThreadedCompositingEnabled() { RenderThreadImpl* thread = RenderThreadImpl::current(); // thread can be NULL in tests. - return thread && thread->compositor_message_loop_proxy().get(); + return thread && thread->compositor_task_runner().get(); } double RendererBlinkPlatformImpl::audioHardwareSampleRate() { @@ -1189,10 +1191,9 @@ void RendererBlinkPlatformImpl::SendFakeDeviceEventDataForTesting( if (!data) return; - base::MessageLoopProxy::current()->PostTask( - FROM_HERE, - base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, - base::Unretained(observer), data)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, + base::Unretained(observer), data)); } void RendererBlinkPlatformImpl::stopListening( diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h index 98f9e9c8..a02f755 100644 --- a/content/renderer/renderer_blink_platform_impl.h +++ b/content/renderer/renderer_blink_platform_impl.h @@ -17,10 +17,6 @@ #include "third_party/WebKit/public/platform/WebScreenOrientationType.h" #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBFactory.h" -namespace base { -class MessageLoopProxy; -} - namespace cc { class ContextProvider; } diff --git a/content/renderer/service_worker/embedded_worker_context_client.cc b/content/renderer/service_worker/embedded_worker_context_client.cc index f0a9410..4cf1941 100644 --- a/content/renderer/service_worker/embedded_worker_context_client.cc +++ b/content/renderer/service_worker/embedded_worker_context_client.cc @@ -8,7 +8,6 @@ #include <string> #include "base/lazy_instance.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/pickle.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" diff --git a/content/renderer/shared_worker/embedded_shared_worker_stub.cc b/content/renderer/shared_worker/embedded_shared_worker_stub.cc index 9d1f82e..290e829 100644 --- a/content/renderer/shared_worker/embedded_shared_worker_stub.cc +++ b/content/renderer/shared_worker/embedded_shared_worker_stub.cc @@ -4,7 +4,7 @@ #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/thread_task_runner_handle.h" #include "content/child/appcache/appcache_dispatcher.h" #include "content/child/appcache/web_application_cache_host_impl.h" #include "content/child/request_extra_data.h" @@ -276,10 +276,8 @@ void EmbeddedSharedWorkerStub::OnConnect(int sent_message_port_id, int routing_id) { TransferredMessagePort port; port.id = sent_message_port_id; - WebMessagePortChannelImpl* channel = - new WebMessagePortChannelImpl(routing_id, - port, - base::MessageLoopProxy::current().get()); + WebMessagePortChannelImpl* channel = new WebMessagePortChannelImpl( + routing_id, port, base::ThreadTaskRunnerHandle::Get().get()); if (runing_) { ConnectToChannel(channel); } else { |