Commit bc7a25ff authored by Yuta Kitamura's avatar Yuta Kitamura Committed by Commit Bot

Use Thread::Current()/MainThread() in bindings/ and controller/.

This CL simplifies lengthy function calls via Platform::Current() that
obtain the current thread and the main thread by using Thread::Current()
and Thread::MainThread().

Also now-redundant null checks for those functions are removed.

Bug: 826203
Change-Id: Iedfd7f09b5334dc84fa921cdca84ca39ad9b3af9
Reviewed-on: https://chromium-review.googlesource.com/c/1318773Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Yuta Kitamura <yutak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605600}
parent 952982f1
......@@ -116,7 +116,7 @@ TEST(DOMWrapperWorldTest, Basic) {
ThreadCreationParams(WebThreadType::kTestThread)
.SetThreadNameForTest("DOMWrapperWorld test thread"));
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner =
Platform::Current()->CurrentThread()->GetTaskRunner();
Thread::Current()->GetTaskRunner();
thread->BackingThread().PostTask(
FROM_HERE,
CrossThreadBind(&WorkerThreadFunc, CrossThreadUnretained(thread.get()),
......
......@@ -123,19 +123,14 @@ void InitializeCommon(Platform* platform,
GetBlinkInitializer().RegisterInterfaces(*registry);
// currentThread is null if we are running on a thread without a message loop.
if (Thread* current_thread = platform->CurrentThread()) {
DCHECK(!g_end_of_task_runner);
g_end_of_task_runner = new EndOfTaskRunner;
current_thread->AddTaskObserver(g_end_of_task_runner);
}
DCHECK(!g_end_of_task_runner);
g_end_of_task_runner = new EndOfTaskRunner;
Thread::Current()->AddTaskObserver(g_end_of_task_runner);
if (Thread* main_thread = Platform::Current()->MainThread()) {
scoped_refptr<base::SequencedTaskRunner> task_runner =
main_thread->GetTaskRunner();
if (task_runner)
MemoryAblationExperiment::MaybeStartForRenderer(task_runner);
}
scoped_refptr<base::SequencedTaskRunner> task_runner =
Thread::MainThread()->GetTaskRunner();
if (task_runner)
MemoryAblationExperiment::MaybeStartForRenderer(task_runner);
#if defined(OS_ANDROID)
// Initialize CrashMemoryMetricsReporterImpl in order to assure that memory
......@@ -164,10 +159,10 @@ void CreateMainThreadAndInitialize(Platform* platform,
void BlinkInitializer::RegisterInterfaces(
service_manager::BinderRegistry& registry) {
ModulesInitializer::RegisterInterfaces(registry);
Thread* main_thread = Platform::Current()->MainThread();
Thread* main_thread = Thread::MainThread();
// GetSingleThreadTaskRunner() uses GetTaskRunner() internally.
// crbug.com/781664
if (!main_thread || !main_thread->GetTaskRunner())
if (!main_thread->GetTaskRunner())
return;
#if defined(OS_ANDROID)
......
......@@ -25,7 +25,7 @@
namespace blink {
BlinkLeakDetector::BlinkLeakDetector()
: delayed_gc_timer_(Platform::Current()->CurrentThread()->GetTaskRunner(),
: delayed_gc_timer_(Thread::Current()->GetTaskRunner(),
this,
&BlinkLeakDetector::TimerFiredGC) {}
......
......@@ -23,7 +23,7 @@ void OomInterventionImpl::Create(mojom::blink::OomInterventionRequest request) {
}
OomInterventionImpl::OomInterventionImpl()
: timer_(Platform::Current()->MainThread()->GetTaskRunner(),
: timer_(Thread::MainThread()->GetTaskRunner(),
this,
&OomInterventionImpl::Check) {}
......
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