Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/renderer/scheduler/single_thread_idle_task_runner.h" | |
| 6 | |
| 7 #include "base/location.h" | |
| 8 | |
| 9 namespace content { | |
| 10 | |
| 11 IdleTaskDeadlineSupplier::~IdleTaskDeadlineSupplier() { | |
| 12 } | |
| 13 | |
| 14 SingleThreadIdleTaskRunner::SingleThreadIdleTaskRunner( | |
| 15 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
| 16 base::WeakPtr<IdleTaskDeadlineSupplier> deadline_supplier) | |
| 17 : task_runner_(task_runner), deadline_supplier_(deadline_supplier) { | |
|
alexclarke
2014/10/27 17:35:29
Maybe DCHECK that deadline_supplier is not null?
rmcilroy
2014/10/27 18:18:02
Then it would fail with the NullRendererScheduler
| |
| 18 } | |
| 19 | |
| 20 SingleThreadIdleTaskRunner::~SingleThreadIdleTaskRunner() { | |
| 21 } | |
| 22 | |
| 23 bool SingleThreadIdleTaskRunner::RunsTasksOnCurrentThread() const { | |
| 24 return task_runner_->RunsTasksOnCurrentThread(); | |
| 25 } | |
| 26 | |
| 27 void SingleThreadIdleTaskRunner::PostIdleTask( | |
| 28 const tracked_objects::Location& from_here, | |
| 29 const IdleTask& idle_task) { | |
| 30 task_runner_->PostTask( | |
| 31 from_here, | |
| 32 base::Bind(&SingleThreadIdleTaskRunner::RunTask, this, idle_task)); | |
| 33 } | |
| 34 | |
| 35 void SingleThreadIdleTaskRunner::RunTask(IdleTask idle_task) { | |
| 36 if (deadline_supplier_) { | |
| 37 idle_task.Run(deadline_supplier_->CurrentIdleTaskDeadline()); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 } // namespace content | |
| OLD | NEW |