Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: components/scheduler/child/single_thread_idle_task_runner.h

Issue 1151353003: [scheduler]: Avoid waking up the scheduler to end long idle periods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@end_idle_sync_2
Patch Set: Review comments. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/scheduler/child/single_thread_idle_task_runner.h
diff --git a/components/scheduler/child/single_thread_idle_task_runner.h b/components/scheduler/child/single_thread_idle_task_runner.h
index 358389a96dc50607a7a1ad449d983f719369f0b9..f692ce7a37ce9e1a4fbe5da3d22550ef260af5ac 100644
--- a/components/scheduler/child/single_thread_idle_task_runner.h
+++ b/components/scheduler/child/single_thread_idle_task_runner.h
@@ -10,6 +10,7 @@
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
+#include "components/scheduler/scheduler_export.h"
namespace scheduler {
@@ -22,12 +23,34 @@ class SingleThreadIdleTaskRunner
public:
typedef base::Callback<void(base::TimeTicks)> IdleTask;
+ // Used to request idle task deadlines and signal posting of idle tasks.
+ class SCHEDULER_EXPORT Delegate {
+ public:
+ Delegate();
+ virtual ~Delegate();
+
+ // Signals that an idle task has been posted. This will be called on the
+ // posting thread, which may not be the same thread as the
+ // SingleThreadIdleTaskRunner runs on.
+ virtual void OnIdleTaskPosted() = 0;
+
+ // Signals that a new idle task is about to be run and returns the deadline
+ // for this idle task.
+ virtual base::TimeTicks WillProcessIdleTask() const = 0;
+
+ // Signals that an idle task has finished being run.
+ virtual void DidProcessIdleTask() = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Delegate);
+ };
+
// NOTE Category strings must have application lifetime (statics or
// literals). They may not include " chars.
SingleThreadIdleTaskRunner(
scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> after_wakeup_task_runner,
- base::Callback<void(base::TimeTicks*)> deadline_supplier,
+ Delegate* Delegate,
const char* tracing_category);
virtual void PostIdleTask(const tracked_objects::Location& from_here,
@@ -53,7 +76,7 @@ class SingleThreadIdleTaskRunner
scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> after_wakeup_task_runner_;
- base::Callback<void(base::TimeTicks*)> deadline_supplier_;
+ Delegate* delegate_; // NOT OWNED
const char* tracing_category_;
base::WeakPtr<SingleThreadIdleTaskRunner> weak_scheduler_ptr_;
base::WeakPtrFactory<SingleThreadIdleTaskRunner> weak_factory_;

Powered by Google App Engine
This is Rietveld 408576698