Commit 92fe7d11 authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

Migrate MessageLoop::current() to MessageLoopCurrent in /media

These changes were scripted as part of the effort to restrict exposure of the
raw MessageLoop*.

Note that many static methods exposed on MessageLoopCurrent are also deprecated
so it is very well possible that this is migrating to an already deprecated
method.

The goal of this pass is to reduce usage of MessageLoop::current() (and
ultimately make it impossible to obtain the MessageLoop* statically).

As such I will not edit this CL unless the script did something logically wrong.
I defer to owners to fix highlighted usage of already deprecated APIs.

Possible script screw ups / things to look out for in this review:
 - Storing MessageLoopCurrent in a MessageLoop* variable or comparing it against
   one (I will go over that in a separate pass).

Includes should have been stripped if that was the last usage of message_loop.h
in that file.

Please CQ if LGTY

This CL was uploaded by git cl split.

R=wolenetz@chromium.org

Bug: 825327
Change-Id: I7b560649fba9f86c99d259101bc7abc2434f294d
Reviewed-on: https://chromium-review.googlesource.com/1024794
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarMatthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553648}
parent 21ff8048
......@@ -12,6 +12,7 @@
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "base/threading/thread_checker_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media {
......@@ -44,15 +45,13 @@ void BoundIntegersSet(int* a_var, int* b_var, int a_val, int b_val) {
}
struct ThreadRestrictionChecker {
ThreadRestrictionChecker() : bound_loop_(base::MessageLoop::current()) {}
void Run() { EXPECT_EQ(bound_loop_, base::MessageLoop::current()); }
void Run() { EXPECT_TRUE(thread_checker_.CalledOnValidThread()); }
~ThreadRestrictionChecker() {
EXPECT_EQ(bound_loop_, base::MessageLoop::current());
EXPECT_TRUE(thread_checker_.CalledOnValidThread());
}
base::MessageLoop* bound_loop_;
base::ThreadCheckerImpl thread_checker_;
};
void ClearReference(base::OnceClosure cb) {}
......
......@@ -17,6 +17,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
#include "media/base/keyboard_event_counter.h"
......@@ -32,7 +33,7 @@ namespace {
// UserInputMonitorLinux since it needs to be deleted on the IO thread.
class UserInputMonitorLinuxCore
: public base::SupportsWeakPtr<UserInputMonitorLinuxCore>,
public base::MessageLoop::DestructionObserver {
public base::MessageLoopCurrent::DestructionObserver {
public:
explicit UserInputMonitorLinuxCore(
const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
......@@ -186,7 +187,7 @@ void UserInputMonitorLinuxCore::StartMonitor() {
// Start observing message loop destruction if we start monitoring the first
// event.
base::MessageLoop::current()->AddDestructionObserver(this);
base::MessageLoopCurrent::Get()->AddDestructionObserver(this);
// Fetch pending events if any.
OnXEvent();
......@@ -219,7 +220,7 @@ void UserInputMonitorLinuxCore::StopMonitor() {
x_control_display_ = NULL;
}
// Stop observing message loop destruction if no event is being monitored.
base::MessageLoop::current()->RemoveDestructionObserver(this);
base::MessageLoopCurrent::Get()->RemoveDestructionObserver(this);
}
void UserInputMonitorLinuxCore::OnXEvent() {
......
......@@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
......@@ -41,7 +42,7 @@ std::unique_ptr<RAWINPUTDEVICE> GetRawInputDevices(HWND hwnd, DWORD flags) {
// UserInputMonitorWin since it needs to be deleted on the UI thread.
class UserInputMonitorWinCore
: public base::SupportsWeakPtr<UserInputMonitorWinCore>,
public base::MessageLoop::DestructionObserver {
public base::MessageLoopCurrent::DestructionObserver {
public:
enum EventBitMask {
MOUSE_EVENT_MASK = 1,
......@@ -140,7 +141,7 @@ void UserInputMonitorWinCore::StartMonitor() {
window_ = std::move(window);
// Start observing message loop destruction if we start monitoring the first
// event.
base::MessageLoop::current()->AddDestructionObserver(this);
base::MessageLoopCurrent::Get()->AddDestructionObserver(this);
}
void UserInputMonitorWinCore::StopMonitor() {
......@@ -160,7 +161,7 @@ void UserInputMonitorWinCore::StopMonitor() {
window_ = nullptr;
// Stop observing message loop destruction if no event is being monitored.
base::MessageLoop::current()->RemoveDestructionObserver(this);
base::MessageLoopCurrent::Get()->RemoveDestructionObserver(this);
}
LRESULT UserInputMonitorWinCore::OnInput(HRAWINPUT input_handle) {
......
......@@ -6,7 +6,7 @@
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/time/time.h"
#include "media/base/media_util.h"
......@@ -102,7 +102,7 @@ class VideoDecodeStatsReporterTest : public ::testing::Test {
void SetUp() override {
// Do this first. Lots of pieces depend on the task runner.
auto message_loop = base::MessageLoop::current();
auto message_loop = base::MessageLoopCurrent::Get();
original_task_runner_ = message_loop.task_runner();
task_runner_ = new base::TestMockTimeTaskRunner();
message_loop.SetTaskRunner(task_runner_);
......@@ -124,7 +124,7 @@ class VideoDecodeStatsReporterTest : public ::testing::Test {
// Run task runner to have Mojo cleanup interceptor_.
task_runner_->RunUntilIdle();
base::MessageLoop::current().SetTaskRunner(original_task_runner_);
base::MessageLoopCurrent::Get().SetTaskRunner(original_task_runner_);
}
PipelineStatistics MakeAdvancingDecodeStats() {
......
......@@ -6,7 +6,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "base/test/test_mock_time_task_runner.h"
#include "media/base/mock_media_log.h"
......@@ -230,7 +230,7 @@ class WatchTimeReporterTest
has_audio_(std::get<1>(GetParam())),
fake_metrics_provider_(this) {
// Do this first. Lots of pieces depend on the task runner.
auto message_loop = base::MessageLoop::current();
auto message_loop = base::MessageLoopCurrent::Get();
original_task_runner_ = message_loop.task_runner();
task_runner_ = new base::TestMockTimeTaskRunner();
message_loop.SetTaskRunner(task_runner_);
......@@ -239,7 +239,7 @@ class WatchTimeReporterTest
~WatchTimeReporterTest() override {
CycleReportingTimer();
task_runner_->RunUntilIdle();
base::MessageLoop::current().SetTaskRunner(original_task_runner_);
base::MessageLoopCurrent::Get().SetTaskRunner(original_task_runner_);
}
protected:
......
......@@ -50,7 +50,7 @@ void DeviceMonitorLinux::Initialize() {
DCHECK(io_task_runner_->BelongsToCurrentThread());
// We want to be notified of IO message loop destruction to delete |udev_|.
base::MessageLoop::current()->AddDestructionObserver(this);
base::MessageLoopCurrent::Get()->AddDestructionObserver(this);
std::vector<device::UdevLinux::UdevMonitorFilter> filters;
for (const SubsystemMap& entry : kSubsystemMap) {
......
......@@ -13,6 +13,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/single_thread_task_runner.h"
#include "media/base/media_export.h"
......@@ -27,7 +28,7 @@ class UdevLinux;
namespace media {
class MEDIA_EXPORT DeviceMonitorLinux
: public base::MessageLoop::DestructionObserver {
: public base::MessageLoopCurrent::DestructionObserver {
public:
explicit DeviceMonitorLinux(
const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
......
......@@ -15,6 +15,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
......@@ -280,13 +281,13 @@ class VideoRendererImplTest : public testing::Test {
}
void AdvanceWallclockTimeInMs(int time_ms) {
DCHECK_EQ(&message_loop_, base::MessageLoop::current());
DCHECK_EQ(&message_loop_, base::MessageLoopCurrent::Get());
base::AutoLock l(lock_);
tick_clock_.Advance(base::TimeDelta::FromMilliseconds(time_ms));
}
void AdvanceTimeInMs(int time_ms) {
DCHECK_EQ(&message_loop_, base::MessageLoop::current());
DCHECK_EQ(&message_loop_, base::MessageLoopCurrent::Get());
base::AutoLock l(lock_);
time_ += base::TimeDelta::FromMilliseconds(time_ms);
time_source_.StopTicking();
......@@ -470,7 +471,7 @@ class VideoRendererImplTest : public testing::Test {
private:
void DecodeRequested(scoped_refptr<DecoderBuffer> buffer,
const VideoDecoder::DecodeCB& decode_cb) {
DCHECK_EQ(&message_loop_, base::MessageLoop::current());
DCHECK_EQ(&message_loop_, base::MessageLoopCurrent::Get());
CHECK(decode_cb_.is_null());
decode_cb_ = decode_cb;
......@@ -488,7 +489,7 @@ class VideoRendererImplTest : public testing::Test {
}
void FlushRequested(const base::Closure& callback) {
DCHECK_EQ(&message_loop_, base::MessageLoop::current());
DCHECK_EQ(&message_loop_, base::MessageLoopCurrent::Get());
decode_results_.clear();
if (!decode_cb_.is_null()) {
QueueFrames("abort");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment