Skip to content

Commit

Permalink
Rename MessageLoopCurrent to CurrentThread
Browse files Browse the repository at this point in the history
Get rid of all references to MessageLoopCurrent(ForIO|ForUI)

This is a mechanical change. Just ran the following commands

mffr.py base/message_loop/message_loop_current base/task/current_thread
mffr.py -f MessageLoopCurrentForUI CurrentUIThread
mffr.py -f MessageLoopCurrentForIO CurrentIOThread
mffr.py -f MessageLoopCurrent CurrentThread
rm base/message_loop/message_loop_current.h

This patch will be reviewed according to
https://chromium.googlesource.com/chromium/src/+/master/docs/code_reviews.md#mechanical-changes

TBR=gab@chromium.org

Bug: 891670
Change-Id: If3892558ad71333f93a4698ac5411f141ccd5657
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2279990
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789421}
  • Loading branch information
carlscabgro authored and Commit Bot committed Jul 17, 2020
1 parent 10fc388 commit b25fe84
Show file tree
Hide file tree
Showing 220 changed files with 608 additions and 645 deletions.
4 changes: 2 additions & 2 deletions android_webview/browser/aw_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/i18n/rtl.h"
#include "base/message_loop/message_loop_current.h"
#include "base/message_loop/message_pump_type.h"
#include "base/path_service.h"
#include "base/task/current_thread.h"
#include "components/crash/content/browser/child_exit_observer_android.h"
#include "components/crash/core/common/crash_key.h"
#include "components/embedder_support/android/metrics/memory_metrics_logger.h"
Expand Down Expand Up @@ -75,7 +75,7 @@ int AwBrowserMainParts::PreEarlyInitialization() {

// Creates a SingleThreadTaskExecutor for Android WebView if doesn't exist.
DCHECK(!main_task_executor_.get());
if (!base::MessageLoopCurrent::IsSet()) {
if (!base::CurrentThread::IsSet()) {
main_task_executor_ = std::make_unique<base::SingleThreadTaskExecutor>(
base::MessagePumpType::UI);
}
Expand Down
2 changes: 1 addition & 1 deletion android_webview/browser/aw_browser_terminator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void OnRenderProcessGone(
switch (delegate->OnRenderProcessGone(child_process_pid, crashed)) {
case AwRenderProcessGoneDelegate::RenderProcessGoneResult::kException:
// Let the exception propagate back to the message loop.
base::MessageLoopCurrentForUI::Get()->Abort();
base::CurrentUIThread::Get()->Abort();
return;
case AwRenderProcessGoneDelegate::RenderProcessGoneResult::kUnhandled:
if (crashed) {
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/aw_contents_client_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "base/android/jni_string.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop_current.h"
#include "base/task/current_thread.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/render_frame_host.h"
Expand Down Expand Up @@ -386,7 +386,7 @@ bool AwContentsClientBridge::ShouldOverrideUrlLoading(const base::string16& url,
// Tell the chromium message loop to not perform any tasks after the current
// one - we want to make sure we return to Java cleanly without first making
// any new JNI calls.
base::MessageLoopCurrentForUI::Get()->Abort();
base::CurrentUIThread::Get()->Abort();
// If we crashed we don't want to continue the navigation.
*ignore_navigation = true;
return false;
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/aw_proxy_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/feature_list.h"
#include "base/message_loop/message_loop_current.h"
#include "base/task/current_thread.h"
#include "content/public/browser/browser_thread.h"
#include "net/proxy_resolution/proxy_config_service_android.h"

Expand Down Expand Up @@ -40,7 +40,7 @@ void ProxyOverrideChanged(const JavaRef<jobject>& obj,
// Tell the chromium message loop to not perform any tasks after the current
// one - we want to make sure we return to Java cleanly without first making
// any new JNI calls.
base::MessageLoopCurrentForUI::Get()->Abort();
base::CurrentUIThread::Get()->Abort();
}
}

Expand Down
6 changes: 3 additions & 3 deletions ash/wallpaper/wallpaper_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/task/current_thread.h"
#include "base/task/post_task.h"
#include "base/task/task_observer.h"
#include "base/task/thread_pool/thread_pool_instance.h"
Expand Down Expand Up @@ -220,12 +220,12 @@ class TaskObserver : public base::TaskObserver {
void RunAllTasksUntilIdle() {
while (true) {
TaskObserver task_observer;
base::MessageLoopCurrent::Get()->AddTaskObserver(&task_observer);
base::CurrentThread::Get()->AddTaskObserver(&task_observer);
// May spin message loop.
base::ThreadPoolInstance::Get()->FlushForTesting();

base::RunLoop().RunUntilIdle();
base::MessageLoopCurrent::Get()->RemoveTaskObserver(&task_observer);
base::CurrentThread::Get()->RemoveTaskObserver(&task_observer);

if (!task_observer.processed())
break;
Expand Down
1 change: 0 additions & 1 deletion base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ jumbo_component("base") {
"memory/weak_ptr.h",
"memory/writable_shared_memory_region.cc",
"memory/writable_shared_memory_region.h",
"message_loop/message_loop_current.h",
"message_loop/message_pump.cc",
"message_loop/message_pump.h",
"message_loop/message_pump_default.cc",
Expand Down
17 changes: 8 additions & 9 deletions base/files/file_descriptor_watcher_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop_current.h"
#include "base/message_loop/message_pump_for_io.h"
#include "base/no_destructor.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/current_thread.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_checker.h"
#include "base/threading/thread_local.h"
Expand All @@ -34,7 +34,7 @@ ThreadLocalPointer<FileDescriptorWatcher>& GetTlsFdWatcher() {

class FileDescriptorWatcher::Controller::Watcher
: public MessagePumpForIO::FdWatcher,
public MessageLoopCurrent::DestructionObserver {
public CurrentThread::DestructionObserver {
public:
Watcher(WeakPtr<Controller> controller, MessagePumpForIO::Mode mode, int fd);
~Watcher() override;
Expand All @@ -48,7 +48,7 @@ class FileDescriptorWatcher::Controller::Watcher
void OnFileCanReadWithoutBlocking(int fd) override;
void OnFileCanWriteWithoutBlocking(int fd) override;

// MessageLoopCurrent::DestructionObserver:
// CurrentThread::DestructionObserver:
void WillDestroyCurrentMessageLoop() override;

// The MessagePumpForIO's watch handle (stops the watch when destroyed).
Expand Down Expand Up @@ -96,20 +96,19 @@ FileDescriptorWatcher::Controller::Watcher::Watcher(

FileDescriptorWatcher::Controller::Watcher::~Watcher() {
DCHECK(thread_checker_.CalledOnValidThread());
MessageLoopCurrentForIO::Get()->RemoveDestructionObserver(this);
CurrentIOThread::Get()->RemoveDestructionObserver(this);
}

void FileDescriptorWatcher::Controller::Watcher::StartWatching() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(MessageLoopCurrentForIO::IsSet());
DCHECK(CurrentIOThread::IsSet());

const bool watch_success =
MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
fd_, false, mode_, &fd_watch_controller_, this);
const bool watch_success = CurrentIOThread::Get()->WatchFileDescriptor(
fd_, false, mode_, &fd_watch_controller_, this);
DCHECK(watch_success) << "Failed to watch fd=" << fd_;

if (!registered_as_destruction_observer_) {
MessageLoopCurrentForIO::Get()->AddDestructionObserver(this);
CurrentIOThread::Get()->AddDestructionObserver(this);
registered_as_destruction_observer_ = true;
}
}
Expand Down
40 changes: 20 additions & 20 deletions base/message_loop/fd_watch_controller_posix_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop_current.h"
#include "base/message_loop/message_pump_for_io.h"
#include "base/posix/eintr_wrapper.h"
#include "base/run_loop.h"
#include "base/task/current_thread.h"
#include "base/test/gtest_util.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
Expand Down Expand Up @@ -137,9 +137,9 @@ TEST_F(FdWatchControllerPosixTest, FileDescriptorWatcherOutlivesMessageLoop) {
{
test::TaskEnvironment env(test::TaskEnvironment::MainThreadType::IO);

MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
write_fd_.get(), true, MessagePumpForIO::WATCH_WRITE, &watcher,
&handler);
CurrentIOThread::Get()->WatchFileDescriptor(write_fd_.get(), true,
MessagePumpForIO::WATCH_WRITE,
&watcher, &handler);
// Don't run the message loop, just destroy it.
}

Expand All @@ -156,9 +156,9 @@ TEST_F(FdWatchControllerPosixTest, FileDescriptorWatcherDoubleStop) {
MessagePumpForIO::FdWatchController watcher(FROM_HERE);

TestHandler handler;
MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
write_fd_.get(), true, MessagePumpForIO::WATCH_WRITE, &watcher,
&handler);
CurrentIOThread::Get()->WatchFileDescriptor(write_fd_.get(), true,
MessagePumpForIO::WATCH_WRITE,
&watcher, &handler);
ASSERT_TRUE(watcher.StopWatchingFileDescriptor());
ASSERT_TRUE(watcher.StopWatchingFileDescriptor());
}
Expand All @@ -173,7 +173,7 @@ TEST_F(FdWatchControllerPosixTest, FileDescriptorWatcherDeleteInCallback) {
handler.watcher_to_delete_ =
std::make_unique<MessagePumpForIO::FdWatchController>(FROM_HERE);

MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
CurrentIOThread::Get()->WatchFileDescriptor(
write_fd_.get(), true, MessagePumpForIO::WATCH_WRITE,
handler.watcher_to_delete_.get(), &handler);
RunLoop().Run();
Expand Down Expand Up @@ -281,7 +281,7 @@ TEST_P(MessageLoopForIoPosixReadAndWriteTest, AfterRead) {
// The triggered read will cause the watcher action to run. |one| would
// also be immediately available for writing, so this should not cause a
// use-after-free on the |handler|.
MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
CurrentIOThread::Get()->WatchFileDescriptor(
one.get(), true, MessagePumpForIO::WATCH_READ_WRITE,
handler->controller(), handler);
run_loop.Run();
Expand Down Expand Up @@ -314,7 +314,7 @@ TEST_P(MessageLoopForIoPosixReadAndWriteTest, AfterWrite) {
// should cause both the read and write watchers to be triggered. The
// |handler| will do its action in response to the write event, which should
// not trigger a use-after-free for the second read that was queued.
MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
CurrentIOThread::Get()->WatchFileDescriptor(
one.get(), true, MessagePumpForIO::WATCH_READ_WRITE,
handler->controller(), handler);
run_loop.Run();
Expand All @@ -331,7 +331,7 @@ TEST_F(FdWatchControllerPosixTest, WatchReadable) {
TestHandler handler;

// Watch the pipe for readability.
ASSERT_TRUE(MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
ASSERT_TRUE(CurrentIOThread::Get()->WatchFileDescriptor(
read_fd_.get(), /*persistent=*/false, MessagePumpForIO::WATCH_READ,
&watcher, &handler));

Expand All @@ -357,7 +357,7 @@ TEST_F(FdWatchControllerPosixTest, WatchWritable) {
TestHandler handler;

// Watch the pipe for writability.
ASSERT_TRUE(MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
ASSERT_TRUE(CurrentIOThread::Get()->WatchFileDescriptor(
write_fd_.get(), /*persistent=*/false, MessagePumpForIO::WATCH_WRITE,
&watcher, &handler));

Expand All @@ -380,7 +380,7 @@ TEST_F(FdWatchControllerPosixTest, RunUntilIdle) {
TestHandler handler;

// Watch the pipe for readability.
ASSERT_TRUE(MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
ASSERT_TRUE(CurrentIOThread::Get()->WatchFileDescriptor(
read_fd_.get(), /*persistent=*/false, MessagePumpForIO::WATCH_READ,
&watcher, &handler));

Expand Down Expand Up @@ -409,7 +409,7 @@ TEST_F(FdWatchControllerPosixTest, StopFromHandler) {
OnceClosure());

// Create persistent watcher.
ASSERT_TRUE(MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
ASSERT_TRUE(CurrentIOThread::Get()->WatchFileDescriptor(
read_fd_.get(), /*persistent=*/true, MessagePumpForIO::WATCH_READ,
&watcher, &handler));

Expand All @@ -430,7 +430,7 @@ TEST_F(FdWatchControllerPosixTest, NonPersistentWatcher) {
CallClosureHandler handler(run_loop.QuitClosure(), OnceClosure());

// Create a non-persistent watcher.
ASSERT_TRUE(MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
ASSERT_TRUE(CurrentIOThread::Get()->WatchFileDescriptor(
read_fd_.get(), /*persistent=*/false, MessagePumpForIO::WATCH_READ,
&watcher, &handler));

Expand All @@ -451,7 +451,7 @@ TEST_F(FdWatchControllerPosixTest, PersistentWatcher) {
CallClosureHandler handler(run_loop1.QuitClosure(), OnceClosure());

// Create persistent watcher.
ASSERT_TRUE(MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
ASSERT_TRUE(CurrentIOThread::Get()->WatchFileDescriptor(
read_fd_.get(), /*persistent=*/true, MessagePumpForIO::WATCH_READ,
&watcher, &handler));

Expand All @@ -473,7 +473,7 @@ void StopWatchingAndWatchAgain(MessagePumpForIO::FdWatchController* controller,
RunLoop* run_loop) {
controller->StopWatchingFileDescriptor();

ASSERT_TRUE(MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
ASSERT_TRUE(CurrentIOThread::Get()->WatchFileDescriptor(
fd, /*persistent=*/true, MessagePumpForIO::WATCH_READ, controller,
new_handler));

Expand All @@ -493,7 +493,7 @@ TEST_F(FdWatchControllerPosixTest, StopAndRestartFromHandler) {
OnceClosure());

// Create persistent watcher.
ASSERT_TRUE(MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
ASSERT_TRUE(CurrentIOThread::Get()->WatchFileDescriptor(
read_fd_.get(), /*persistent=*/true, MessagePumpForIO::WATCH_READ,
&watcher, &handler1));

Expand All @@ -520,7 +520,7 @@ TEST_F(FdWatchControllerPosixTest, IoEventThenTimer) {
CallClosureHandler handler(watcher_run_loop.QuitClosure(), OnceClosure());

// Create a non-persistent watcher.
ASSERT_TRUE(MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
ASSERT_TRUE(CurrentIOThread::Get()->WatchFileDescriptor(
read_fd_.get(), /*persistent=*/false, MessagePumpForIO::WATCH_READ,
&watcher, &handler));

Expand Down Expand Up @@ -551,7 +551,7 @@ TEST_F(FdWatchControllerPosixTest, TimerThenIoEvent) {
CallClosureHandler handler(run_loop.QuitClosure(), OnceClosure());

// Create a non-persistent watcher.
ASSERT_TRUE(MessageLoopCurrentForIO::Get()->WatchFileDescriptor(
ASSERT_TRUE(CurrentIOThread::Get()->WatchFileDescriptor(
read_fd_.get(), /*persistent=*/false, MessagePumpForIO::WATCH_READ,
&watcher, &handler));

Expand Down
26 changes: 0 additions & 26 deletions base/message_loop/message_loop_current.h

This file was deleted.

8 changes: 4 additions & 4 deletions base/message_loop/message_pump_glib_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop_current.h"
#include "base/message_loop/message_pump_type.h"
#include "base/posix/eintr_wrapper.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/synchronization/waitable_event_watcher.h"
#include "base/task/current_thread.h"
#include "base/task/single_thread_task_executor.h"
#include "base/test/task_environment.h"
#include "base/threading/thread.h"
Expand Down Expand Up @@ -472,7 +472,7 @@ void TestGLibLoopInternal(EventInjector* injector, OnceClosure done) {

// Run a nested, straight GLib message loop.
{
MessageLoopCurrent::ScopedNestableTaskAllower allow_nestable_tasks;
CurrentThread::ScopedNestableTaskAllower allow_nestable_tasks;
runner->RunGLib();
}

Expand Down Expand Up @@ -506,7 +506,7 @@ void TestGtkLoopInternal(EventInjector* injector, OnceClosure done) {

// Run a nested, straight Gtk message loop.
{
MessageLoopCurrent::ScopedNestableTaskAllower allow_nestable_tasks;
CurrentThread::ScopedNestableTaskAllower allow_nestable_tasks;
runner->RunLoop();
}

Expand Down Expand Up @@ -745,7 +745,7 @@ TEST_F(MessagePumpGLibFdWatchTest, QuitWatcher) {
Unretained(watcher.get()), &event,
std::move(write_fd_task), io_runner()));

// Queue |event| to signal on |MessageLoopCurrentForUI::Get()|.
// Queue |event| to signal on |CurrentUIThread::Get()|.
ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, BindOnce(&WaitableEvent::Signal, Unretained(&event)));

Expand Down
Loading

0 comments on commit b25fe84

Please sign in to comment.