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 SingleThreadIdleTaskRunner( | |
28 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
29 base::WeakPtr<IdleTaskDeadlineSupplier> deadline_supplier); | |
30 | |
31 virtual void PostIdleTask(const tracked_objects::Location& from_here, | |
32 const IdleTask& idle_task); | |
33 | |
34 bool RunsTasksOnCurrentThread() const; | |
35 | |
36 protected: | |
37 virtual ~SingleThreadIdleTaskRunner(); | |
38 | |
39 private: | |
40 friend class base::RefCountedThreadSafe<SingleThreadIdleTaskRunner>; | |
41 | |
42 void RunTask(IdleTask idle_task); | |
43 | |
44 scoped_refptr<base::TaskRunner> task_runner_; | |
45 base::WeakPtr<IdleTaskDeadlineSupplier> deadline_supplier_; | |
46 }; | |
47 | |
48 class IdleTaskDeadlineSupplier { | |
49 public: | |
50 // Returns the deadline by which an idle task should finish by. | |
51 virtual base::TimeTicks CurrentIdleTaskDeadline() const = 0; | |
Sami
2014/10/27 12:02:38
protected:
virtual ~IdleTaskDeadlineSupplier();
rmcilroy
2014/10/27 16:25:01
Done.
| |
52 }; | |
53 | |
54 } // namespace content | |
55 | |
56 #endif // CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ | |
OLD | NEW |