Commit bb7239ef authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

Migrate MessageLoop::current() to MessageLoopCurrent in /content/public/test

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=sky@chromium.org

Bug: 825327
Change-Id: I26056af155629353a7a8e0fccf38fc3d2308ecd9
Reviewed-on: https://chromium-review.googlesource.com/1024792Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553307}
parent a6b93644
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <utility> #include <utility>
#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -138,7 +139,7 @@ RenderViewHostTestEnabler::RenderViewHostTestEnabler() ...@@ -138,7 +139,7 @@ RenderViewHostTestEnabler::RenderViewHostTestEnabler()
// tests have their own, so this only creates one when none exists. This // tests have their own, so this only creates one when none exists. This
// means tests must ensure any MessageLoop they make is created before // means tests must ensure any MessageLoop they make is created before
// the RenderViewHostTestEnabler. // the RenderViewHostTestEnabler.
if (!base::MessageLoop::current()) if (!base::MessageLoopCurrent::Get())
message_loop_ = std::make_unique<base::MessageLoop>(); message_loop_ = std::make_unique<base::MessageLoop>();
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
ImageTransportFactory::SetFactory( ImageTransportFactory::SetFactory(
......
...@@ -163,14 +163,14 @@ void RunAllTasksUntilIdle() { ...@@ -163,14 +163,14 @@ void RunAllTasksUntilIdle() {
// current loop iteration and loop in case the MessageLoop posts tasks to // current loop iteration and loop in case the MessageLoop posts tasks to
// the Task Scheduler after the initial flush. // the Task Scheduler after the initial flush.
TaskObserver task_observer; TaskObserver task_observer;
base::MessageLoop::current()->AddTaskObserver(&task_observer); base::MessageLoopCurrent::Get()->AddTaskObserver(&task_observer);
base::RunLoop run_loop; base::RunLoop run_loop;
base::TaskScheduler::GetInstance()->FlushAsyncForTesting( base::TaskScheduler::GetInstance()->FlushAsyncForTesting(
run_loop.QuitWhenIdleClosure()); run_loop.QuitWhenIdleClosure());
run_loop.Run(); run_loop.Run();
base::MessageLoop::current()->RemoveTaskObserver(&task_observer); base::MessageLoopCurrent::Get()->RemoveTaskObserver(&task_observer);
if (!task_observer.processed()) if (!task_observer.processed())
break; break;
......
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