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 #ifndef CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ | |
| 6 #define CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ | |
| 7 | |
| 8 #include "base/bind.h" | |
| 9 #include "base/callback.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "base/single_thread_task_runner.h" | |
| 13 #include "base/time/time.h" | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 class IdleTaskDeadlineSupplier; | |
| 18 | |
| 19 // An IdleTaskRunner is a task runner for running idle tasks. Idle tasks have | |
| 20 // an unbound argument which is bound to a deadline (in base::TimeTicks) when | |
| 21 // they are executed. The idle task is expected to complete by this deadline. | |
| 22 class SingleThreadIdleTaskRunner | |
| 23 : public base::RefCountedThreadSafe<SingleThreadIdleTaskRunner> { | |
| 24 public: | |
| 25 typedef base::Callback<void(base::TimeTicks)> IdleTask; | |
| 26 | |
| 27 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 :)
| |
| 28 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
| 29 base::WeakPtr<IdleTaskDeadlineSupplier> deadline_supplier); | |
| 30 | |
| 31 void PostIdleTask(const tracked_objects::Location& from_here, | |
| 32 const IdleTask& idle_task); | |
| 33 | |
| 34 bool RunsTasksOnCurrentThread() const; | |
| 35 | |
| 36 private: | |
| 37 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.
| |
| 38 ~SingleThreadIdleTaskRunner(); | |
| 39 | |
| 40 void RunTask(IdleTask idle_task); | |
| 41 | |
| 42 scoped_refptr<base::TaskRunner> task_runner_; | |
| 43 base::WeakPtr<IdleTaskDeadlineSupplier> deadline_supplier_; | |
| 44 }; | |
| 45 | |
| 46 class IdleTaskDeadlineSupplier { | |
| 47 public: | |
|
Sami
2014/10/24 10:46:13
Indentation is a little off here.
rmcilroy
2014/10/24 14:58:29
Done.
| |
| 48 // Returns the deadline by which an idle task should finish by. | |
| 49 virtual base::TimeTicks CurrentIdleTaskDeadline() const = 0; | |
| 50 }; | |
| 51 | |
| 52 } // namespace content | |
| 53 | |
| 54 #endif // CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ | |
| OLD | NEW |