Chromium Code Reviews| Index: content/renderer/scheduler/single_thread_idle_task_runner.h |
| diff --git a/content/renderer/scheduler/single_thread_idle_task_runner.h b/content/renderer/scheduler/single_thread_idle_task_runner.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5f105d4bb24328d6a55865debfcb38945967ca29 |
| --- /dev/null |
| +++ b/content/renderer/scheduler/single_thread_idle_task_runner.h |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ |
| +#define CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ |
| + |
| +#include "base/bind.h" |
| +#include "base/callback.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/single_thread_task_runner.h" |
| +#include "base/time/time.h" |
| + |
| +namespace content { |
| + |
| +class IdleTaskDeadlineSupplier; |
| + |
| +// An IdleTaskRunner is a task runner for running idle tasks. Idle tasks have |
| +// an unbound argument which is bound to a deadline (in base::TimeTicks) when |
| +// they are executed. The idle task is expected to complete by this deadline. |
| +class SingleThreadIdleTaskRunner |
| + : public base::RefCountedThreadSafe<SingleThreadIdleTaskRunner> { |
| + public: |
| + typedef base::Callback<void(base::TimeTicks)> IdleTask; |
| + |
| + explicit SingleThreadIdleTaskRunner( |
|
Sami
2014/10/24 10:46:13
nit: No need for explicit.
rmcilroy
2014/10/24 14:58:29
Your right, not now that I added an extra param :)
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| + base::WeakPtr<IdleTaskDeadlineSupplier> deadline_supplier); |
| + |
| + void PostIdleTask(const tracked_objects::Location& from_here, |
| + const IdleTask& idle_task); |
| + |
| + bool RunsTasksOnCurrentThread() const; |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<SingleThreadIdleTaskRunner>; |
|
Sami
2014/10/24 10:46:13
One extra space of indent here.
rmcilroy
2014/10/24 14:58:29
Done.
|
| + ~SingleThreadIdleTaskRunner(); |
| + |
| + void RunTask(IdleTask idle_task); |
| + |
| + scoped_refptr<base::TaskRunner> task_runner_; |
| + base::WeakPtr<IdleTaskDeadlineSupplier> deadline_supplier_; |
| +}; |
| + |
| +class IdleTaskDeadlineSupplier { |
| + public: |
|
Sami
2014/10/24 10:46:13
Indentation is a little off here.
rmcilroy
2014/10/24 14:58:29
Done.
|
| + // Returns the deadline by which an idle task should finish by. |
| + virtual base::TimeTicks CurrentIdleTaskDeadline() const = 0; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ |