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

Unified Diff: components/scheduler/base/time_domain.h

Issue 1441073006: Move throttling of background timers into the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Last few changes Sami requested Created 5 years, 1 month 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
« no previous file with comments | « components/scheduler/base/task_queue_sets_unittest.cc ('k') | components/scheduler/base/time_domain.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/scheduler/base/time_domain.h
diff --git a/components/scheduler/base/time_domain.h b/components/scheduler/base/time_domain.h
index 476a68eb5f4299f78b66d2b069fef24320a1b37a..5cf39b709d11c09c47564c78a3f849565f6e7430 100644
--- a/components/scheduler/base/time_domain.h
+++ b/components/scheduler/base/time_domain.h
@@ -23,9 +23,24 @@ class TaskQueueImpl;
class TaskQueueManager;
class TaskQueueManagerDelegate;
-class SCHEDULER_EXPORT TimeDomain : public base::RefCounted<TimeDomain> {
+class SCHEDULER_EXPORT TimeDomain {
public:
- TimeDomain();
+ class SCHEDULER_EXPORT Observer {
+ public:
+ virtual ~Observer() {}
+
+ // Called when an empty TaskQueue registered with this TimeDomain has a task
+ // enqueued.
+ virtual void OnTimeDomainHasImmediateWork() = 0;
+
+ // Called when a TaskQueue registered with this TimeDomain has a delayed
+ // task enqueued and no other delayed tasks associated with this TimeDomain
+ // are pending.
+ virtual void OnTimeDomainHasDelayedWork() = 0;
+ };
+
+ explicit TimeDomain(Observer* observer);
+ virtual ~TimeDomain();
// Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from
// any thread.
@@ -46,9 +61,6 @@ class SCHEDULER_EXPORT TimeDomain : public base::RefCounted<TimeDomain> {
protected:
friend class internal::TaskQueueImpl;
friend class TaskQueueManager;
- friend class base::RefCounted<TimeDomain>;
-
- virtual ~TimeDomain();
void AsValueInto(base::trace_event::TracedValue* state) const;
@@ -70,6 +82,9 @@ class SCHEDULER_EXPORT TimeDomain : public base::RefCounted<TimeDomain> {
base::TimeTicks delayed_run_time,
LazyNow* lazy_now);
+ // Registers the |queue|.
+ void RegisterQueue(internal::TaskQueueImpl* queue);
+
// Removes |queue| from the set of task queues that UpdateWorkQueues calls
// UpdateWorkQueue on.
void UnregisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue);
@@ -115,6 +130,10 @@ class SCHEDULER_EXPORT TimeDomain : public base::RefCounted<TimeDomain> {
// only be accessed from the main thread.
std::set<internal::TaskQueueImpl*> updatable_queue_set_;
+ std::set<internal::TaskQueueImpl*> registered_task_queues_;
+
+ Observer* observer_;
+
base::ThreadChecker main_thread_checker_;
DISALLOW_COPY_AND_ASSIGN(TimeDomain);
« no previous file with comments | « components/scheduler/base/task_queue_sets_unittest.cc ('k') | components/scheduler/base/time_domain.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698