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..ef4391b6f7d2596021afe436861a912368684be6 |
--- /dev/null |
+++ b/content/renderer/scheduler/single_thread_idle_task_runner.h |
@@ -0,0 +1,60 @@ |
+// 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; |
+ |
+// A SingleThreadIdleTaskRunner 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 run. The idle task is expected to |
+// complete by this deadline. |
+class SingleThreadIdleTaskRunner |
+ : public base::RefCountedThreadSafe<SingleThreadIdleTaskRunner> { |
+ public: |
+ typedef base::Callback<void(base::TimeTicks)> IdleTask; |
+ |
+ SingleThreadIdleTaskRunner( |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
+ base::WeakPtr<IdleTaskDeadlineSupplier> deadline_supplier); |
+ |
+ virtual void PostIdleTask(const tracked_objects::Location& from_here, |
+ const IdleTask& idle_task); |
+ |
+ bool RunsTasksOnCurrentThread() const; |
+ |
+ protected: |
+ virtual ~SingleThreadIdleTaskRunner(); |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<SingleThreadIdleTaskRunner>; |
+ |
+ void RunTask(IdleTask idle_task); |
+ |
+ scoped_refptr<base::TaskRunner> task_runner_; |
+ base::WeakPtr<IdleTaskDeadlineSupplier> deadline_supplier_; |
+}; |
+ |
+class IdleTaskDeadlineSupplier { |
no sievers
2014/10/30 23:40:51
Can this be a CancelableCallback?
rmcilroy
2014/11/03 19:02:53
I don't thinks so. We need to be able to pass the
no sievers
2014/11/03 22:19:01
I meant just to avoid needing the interface class.
rmcilroy
2014/11/04 02:22:19
Ahh I see what you mean, good idea. Done, but usi
|
+ public: |
+ // Returns the deadline by which an idle task should finish by. |
+ virtual base::TimeTicks CurrentIdleTaskDeadline() const = 0; |
+ |
+ protected: |
+ virtual ~IdleTaskDeadlineSupplier(); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ |