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