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

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: scheduler: Suspend timers while virtual time is paused 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 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 } 1196 }
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::VIRTUAL)
1207 task_queue->SetTimeDomain(real_time_domain());
alex clarke (OOO till 29th) 2017/03/09 11:11:33 Setting this redundantly is cheap. Maybe just mov
Sami 2017/03/09 11:25:33 Done. (FWIW setting this takes a lock, but I think
1208
1206 if (old_task_queue_policy.time_domain_type == TimeDomainType::THROTTLED) { 1209 if (old_task_queue_policy.time_domain_type == TimeDomainType::THROTTLED) {
1207 task_queue_throttler_->DecreaseThrottleRefCount(task_queue); 1210 task_queue_throttler_->DecreaseThrottleRefCount(task_queue);
1208 } else if (new_task_queue_policy.time_domain_type == 1211 } else if (new_task_queue_policy.time_domain_type ==
1209 TimeDomainType::THROTTLED) { 1212 TimeDomainType::THROTTLED) {
1210 task_queue_throttler_->IncreaseThrottleRefCount(task_queue); 1213 task_queue_throttler_->IncreaseThrottleRefCount(task_queue);
1211 } else if (new_task_queue_policy.time_domain_type == 1214 } else if (new_task_queue_policy.time_domain_type ==
1212 TimeDomainType::VIRTUAL) { 1215 TimeDomainType::VIRTUAL) {
1213 DCHECK(virtual_time_domain_); 1216 DCHECK(virtual_time_domain_);
1214 task_queue->SetTimeDomain(virtual_time_domain_.get()); 1217 task_queue->SetTimeDomain(virtual_time_domain_.get());
1215 } 1218 }
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 MainThreadOnly().use_virtual_time = true; 1818 MainThreadOnly().use_virtual_time = true;
1816 1819
1817 // The |unthrottled_task_runners_| are not actively managed by UpdatePolicy(). 1820 // The |unthrottled_task_runners_| are not actively managed by UpdatePolicy().
1818 AutoAdvancingVirtualTimeDomain* time_domain = GetVirtualTimeDomain(); 1821 AutoAdvancingVirtualTimeDomain* time_domain = GetVirtualTimeDomain();
1819 for (const scoped_refptr<TaskQueue>& task_queue : unthrottled_task_runners_) 1822 for (const scoped_refptr<TaskQueue>& task_queue : unthrottled_task_runners_)
1820 task_queue->SetTimeDomain(time_domain); 1823 task_queue->SetTimeDomain(time_domain);
1821 1824
1822 ForceUpdatePolicy(); 1825 ForceUpdatePolicy();
1823 } 1826 }
1824 1827
1828 void RendererSchedulerImpl::DisableVirtualTimeForTesting() {
1829 MainThreadOnly().use_virtual_time = false;
1830
1831 RealTimeDomain* time_domain = real_time_domain();
1832 // The |unthrottled_task_runners_| are not actively managed by UpdatePolicy().
1833 for (const scoped_refptr<TaskQueue>& task_queue : unthrottled_task_runners_)
1834 task_queue->SetTimeDomain(time_domain);
1835
1836 ForceUpdatePolicy();
1837 }
1838
1825 bool RendererSchedulerImpl::ShouldDisableThrottlingBecauseOfAudio( 1839 bool RendererSchedulerImpl::ShouldDisableThrottlingBecauseOfAudio(
1826 base::TimeTicks now) { 1840 base::TimeTicks now) {
1827 if (!MainThreadOnly().last_audio_state_change) 1841 if (!MainThreadOnly().last_audio_state_change)
1828 return false; 1842 return false;
1829 1843
1830 if (MainThreadOnly().is_audio_playing) 1844 if (MainThreadOnly().is_audio_playing)
1831 return true; 1845 return true;
1832 1846
1833 return MainThreadOnly().last_audio_state_change.value() + 1847 return MainThreadOnly().last_audio_state_change.value() +
1834 kThrottlingDelayAfterAudioIsPlayed > 1848 kThrottlingDelayAfterAudioIsPlayed >
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 case TimeDomainType::VIRTUAL: 1914 case TimeDomainType::VIRTUAL:
1901 return "virtual"; 1915 return "virtual";
1902 default: 1916 default:
1903 NOTREACHED(); 1917 NOTREACHED();
1904 return nullptr; 1918 return nullptr;
1905 } 1919 }
1906 } 1920 }
1907 1921
1908 } // namespace scheduler 1922 } // namespace scheduler
1909 } // namespace blink 1923 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698