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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc

Issue 2725633002: scheduler: Suspend timers while virtual time is paused (Closed)
Patch Set: Rebased Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" 5 #include "platform/scheduler/renderer/renderer_scheduler_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/stack_trace.h" 8 #include "base/debug/stack_trace.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 1197
1198 // Make sure if there's no voter that the task queue is enabled. 1198 // Make sure if there's no voter that the task queue is enabled.
1199 DCHECK(task_queue_enabled_voter || old_task_queue_policy.is_enabled); 1199 DCHECK(task_queue_enabled_voter || old_task_queue_policy.is_enabled);
1200 1200
1201 if (old_task_queue_policy.priority != new_task_queue_policy.priority) 1201 if (old_task_queue_policy.priority != new_task_queue_policy.priority)
1202 task_queue->SetQueuePriority(new_task_queue_policy.priority); 1202 task_queue->SetQueuePriority(new_task_queue_policy.priority);
1203 1203
1204 if (old_task_queue_policy.time_domain_type != 1204 if (old_task_queue_policy.time_domain_type !=
1205 new_task_queue_policy.time_domain_type) { 1205 new_task_queue_policy.time_domain_type) {
1206 if (old_task_queue_policy.time_domain_type == TimeDomainType::THROTTLED) { 1206 if (old_task_queue_policy.time_domain_type == TimeDomainType::THROTTLED) {
1207 task_queue->SetTimeDomain(real_time_domain());
1207 task_queue_throttler_->DecreaseThrottleRefCount(task_queue); 1208 task_queue_throttler_->DecreaseThrottleRefCount(task_queue);
1208 } else if (new_task_queue_policy.time_domain_type == 1209 } else if (new_task_queue_policy.time_domain_type ==
1209 TimeDomainType::THROTTLED) { 1210 TimeDomainType::THROTTLED) {
1211 task_queue->SetTimeDomain(real_time_domain());
1210 task_queue_throttler_->IncreaseThrottleRefCount(task_queue); 1212 task_queue_throttler_->IncreaseThrottleRefCount(task_queue);
1211 } else if (new_task_queue_policy.time_domain_type == 1213 } else if (new_task_queue_policy.time_domain_type ==
1212 TimeDomainType::VIRTUAL) { 1214 TimeDomainType::VIRTUAL) {
1213 DCHECK(virtual_time_domain_); 1215 DCHECK(virtual_time_domain_);
1214 task_queue->SetTimeDomain(virtual_time_domain_.get()); 1216 task_queue->SetTimeDomain(virtual_time_domain_.get());
1217 } else {
1218 task_queue->SetTimeDomain(real_time_domain());
1215 } 1219 }
1216 } 1220 }
1217 } 1221 }
1218 1222
1219 RendererSchedulerImpl::UseCase RendererSchedulerImpl::ComputeCurrentUseCase( 1223 RendererSchedulerImpl::UseCase RendererSchedulerImpl::ComputeCurrentUseCase(
1220 base::TimeTicks now, 1224 base::TimeTicks now,
1221 base::TimeDelta* expected_use_case_duration) const { 1225 base::TimeDelta* expected_use_case_duration) const {
1222 any_thread_lock_.AssertAcquired(); 1226 any_thread_lock_.AssertAcquired();
1223 // Special case for flings. This is needed because we don't get notification 1227 // Special case for flings. This is needed because we don't get notification
1224 // of a fling ending (although we do for cancellation). 1228 // of a fling ending (although we do for cancellation).
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 MainThreadOnly().use_virtual_time = true; 1819 MainThreadOnly().use_virtual_time = true;
1816 1820
1817 // The |unthrottled_task_runners_| are not actively managed by UpdatePolicy(). 1821 // The |unthrottled_task_runners_| are not actively managed by UpdatePolicy().
1818 AutoAdvancingVirtualTimeDomain* time_domain = GetVirtualTimeDomain(); 1822 AutoAdvancingVirtualTimeDomain* time_domain = GetVirtualTimeDomain();
1819 for (const scoped_refptr<TaskQueue>& task_queue : unthrottled_task_runners_) 1823 for (const scoped_refptr<TaskQueue>& task_queue : unthrottled_task_runners_)
1820 task_queue->SetTimeDomain(time_domain); 1824 task_queue->SetTimeDomain(time_domain);
1821 1825
1822 ForceUpdatePolicy(); 1826 ForceUpdatePolicy();
1823 } 1827 }
1824 1828
1829 void RendererSchedulerImpl::DisableVirtualTimeForTesting() {
1830 MainThreadOnly().use_virtual_time = false;
1831
1832 RealTimeDomain* time_domain = real_time_domain();
1833 // The |unthrottled_task_runners_| are not actively managed by UpdatePolicy().
1834 for (const scoped_refptr<TaskQueue>& task_queue : unthrottled_task_runners_)
1835 task_queue->SetTimeDomain(time_domain);
1836
1837 ForceUpdatePolicy();
1838 }
1839
1825 bool RendererSchedulerImpl::ShouldDisableThrottlingBecauseOfAudio( 1840 bool RendererSchedulerImpl::ShouldDisableThrottlingBecauseOfAudio(
1826 base::TimeTicks now) { 1841 base::TimeTicks now) {
1827 if (!MainThreadOnly().last_audio_state_change) 1842 if (!MainThreadOnly().last_audio_state_change)
1828 return false; 1843 return false;
1829 1844
1830 if (MainThreadOnly().is_audio_playing) 1845 if (MainThreadOnly().is_audio_playing)
1831 return true; 1846 return true;
1832 1847
1833 return MainThreadOnly().last_audio_state_change.value() + 1848 return MainThreadOnly().last_audio_state_change.value() +
1834 kThrottlingDelayAfterAudioIsPlayed > 1849 kThrottlingDelayAfterAudioIsPlayed >
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 case TimeDomainType::VIRTUAL: 1915 case TimeDomainType::VIRTUAL:
1901 return "virtual"; 1916 return "virtual";
1902 default: 1917 default:
1903 NOTREACHED(); 1918 NOTREACHED();
1904 return nullptr; 1919 return nullptr;
1905 } 1920 }
1906 } 1921 }
1907 1922
1908 } // namespace scheduler 1923 } // namespace scheduler
1909 } // namespace blink 1924 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698