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

Unified Diff: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc

Issue 2258133002: [scheduler] Implement time-based cpu throttling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 3 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: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
index 963662e7959c4a86a846215c11e90240fb33a654..0785e8d223049ce92bd458346d1d60784a432023 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
+++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
@@ -341,6 +341,13 @@ bool TaskQueueImpl::HasPendingImmediateWork() const {
return !any_thread().immediate_incoming_queue.empty();
}
+base::Optional<base::TimeTicks> TaskQueueImpl::GetNextScheduledWakeUp() {
+ if (main_thread_only().delayed_incoming_queue.empty())
+ return base::nullopt;
+
+ return main_thread_only().delayed_incoming_queue.top().delayed_run_time;
+}
+
void TaskQueueImpl::WakeUpForDelayedWork(LazyNow* lazy_now) {
// Enqueue all delayed tasks that should be running now, skipping any that
// have been canceled.
@@ -516,22 +523,26 @@ void TaskQueueImpl::NotifyDidProcessTask(
}
void TaskQueueImpl::SetTimeDomain(TimeDomain* time_domain) {
- base::AutoLock lock(any_thread_lock_);
- DCHECK(time_domain);
- // NOTE this is similar to checking |any_thread().task_queue_manager| but the
- // TaskQueueSelectorTests constructs TaskQueueImpl directly with a null
- // task_queue_manager. Instead we check |any_thread().time_domain| which is
- // another way of asserting that UnregisterTaskQueue has not been called.
- DCHECK(any_thread().time_domain);
- if (!any_thread().time_domain)
- return;
- DCHECK(main_thread_checker_.CalledOnValidThread());
- if (time_domain == main_thread_only().time_domain)
- return;
-
+ {
+ base::AutoLock lock(any_thread_lock_);
+ DCHECK(time_domain);
+ // NOTE this is similar to checking |any_thread().task_queue_manager| but
+ // the TaskQueueSelectorTests constructs TaskQueueImpl directly with a null
+ // task_queue_manager. Instead we check |any_thread().time_domain| which is
+ // another way of asserting that UnregisterTaskQueue has not been called.
+ DCHECK(any_thread().time_domain);
+ if (!any_thread().time_domain)
+ return;
+ DCHECK(main_thread_checker_.CalledOnValidThread());
+ if (time_domain == main_thread_only().time_domain)
+ return;
+
+ any_thread().time_domain = time_domain;
+ }
+ // We rely here on TimeDomain::MigrateQueue being thread-safe to use with
+ // TimeDomain::Register/UnregisterAsUpdatableTaskQueue.
main_thread_only().time_domain->MigrateQueue(this, time_domain);
main_thread_only().time_domain = time_domain;
- any_thread().time_domain = time_domain;
}
TimeDomain* TaskQueueImpl::GetTimeDomain() const {

Powered by Google App Engine
This is Rietveld 408576698