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" | |
no sievers
2014/11/04 20:41:41
nit: unneeded
rmcilroy
2014/11/05 00:34:01
Done.
| |
12 #include "base/single_thread_task_runner.h" | |
13 #include "base/time/time.h" | |
14 | |
15 namespace content { | |
16 | |
17 // A SingleThreadIdleTaskRunner is a task runner for running idle tasks. Idle | |
18 // tasks have an unbound argument which is bound to a deadline | |
19 // (in base::TimeTicks) when they are run. The idle task is expected to | |
20 // complete by this deadline. | |
21 class SingleThreadIdleTaskRunner | |
22 : public base::RefCountedThreadSafe<SingleThreadIdleTaskRunner> { | |
23 public: | |
24 typedef base::Callback<void(base::TimeTicks)> IdleTask; | |
25 | |
26 SingleThreadIdleTaskRunner( | |
27 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
28 base::Callback<void(base::TimeTicks*)> deadline_supplier); | |
29 | |
30 virtual void PostIdleTask(const tracked_objects::Location& from_here, | |
31 const IdleTask& idle_task); | |
32 | |
33 bool RunsTasksOnCurrentThread() const; | |
34 | |
35 protected: | |
36 virtual ~SingleThreadIdleTaskRunner(); | |
37 | |
38 private: | |
39 friend class base::RefCountedThreadSafe<SingleThreadIdleTaskRunner>; | |
40 | |
41 void RunTask(IdleTask idle_task); | |
42 | |
43 scoped_refptr<base::TaskRunner> task_runner_; | |
44 base::Callback<void(base::TimeTicks*)> deadline_supplier_; | |
no sievers
2014/11/04 20:41:41
nit: DISALLOW_COPY_AND_ASSIGN
rmcilroy
2014/11/05 00:34:01
Done.
| |
45 }; | |
46 | |
47 } // namespace content | |
48 | |
49 #endif // CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ | |
OLD | NEW |