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

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

Issue 2841463003: scheduler: Make virtual time expiration deterministic (Closed)
Patch Set: Rebased Created 3 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 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 scoped_refptr<TaskQueue> RendererSchedulerImpl::TimerTaskQueue() { 302 scoped_refptr<TaskQueue> RendererSchedulerImpl::TimerTaskQueue() {
303 helper_.CheckOnValidThread(); 303 helper_.CheckOnValidThread();
304 return default_timer_task_queue_; 304 return default_timer_task_queue_;
305 } 305 }
306 306
307 scoped_refptr<TaskQueue> RendererSchedulerImpl::ControlTaskQueue() { 307 scoped_refptr<TaskQueue> RendererSchedulerImpl::ControlTaskQueue() {
308 helper_.CheckOnValidThread(); 308 helper_.CheckOnValidThread();
309 return helper_.ControlTaskQueue(); 309 return helper_.ControlTaskQueue();
310 } 310 }
311 311
312 scoped_refptr<TaskQueue> RendererSchedulerImpl::VirtualTimeControlTaskQueue() {
313 helper_.CheckOnValidThread();
314 return virtual_time_control_task_queue_;
315 }
316
312 scoped_refptr<TaskQueue> RendererSchedulerImpl::NewLoadingTaskQueue( 317 scoped_refptr<TaskQueue> RendererSchedulerImpl::NewLoadingTaskQueue(
313 TaskQueue::QueueType queue_type) { 318 TaskQueue::QueueType queue_type) {
314 helper_.CheckOnValidThread(); 319 helper_.CheckOnValidThread();
315 scoped_refptr<TaskQueue> loading_task_queue(helper_.NewTaskQueue( 320 scoped_refptr<TaskQueue> loading_task_queue(helper_.NewTaskQueue(
316 TaskQueue::Spec(queue_type) 321 TaskQueue::Spec(queue_type)
317 .SetShouldMonitorQuiescence(true) 322 .SetShouldMonitorQuiescence(true)
318 .SetTimeDomain(GetMainThreadOnly().use_virtual_time 323 .SetTimeDomain(GetMainThreadOnly().use_virtual_time
319 ? GetVirtualTimeDomain() 324 ? GetVirtualTimeDomain()
320 : nullptr))); 325 : nullptr)));
321 auto insert_result = loading_task_runners_.insert(std::make_pair( 326 auto insert_result = loading_task_runners_.insert(std::make_pair(
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 } 1849 }
1845 1850
1846 void RendererSchedulerImpl::EnableVirtualTime() { 1851 void RendererSchedulerImpl::EnableVirtualTime() {
1847 GetMainThreadOnly().use_virtual_time = true; 1852 GetMainThreadOnly().use_virtual_time = true;
1848 1853
1849 // The |unthrottled_task_runners_| are not actively managed by UpdatePolicy(). 1854 // The |unthrottled_task_runners_| are not actively managed by UpdatePolicy().
1850 AutoAdvancingVirtualTimeDomain* time_domain = GetVirtualTimeDomain(); 1855 AutoAdvancingVirtualTimeDomain* time_domain = GetVirtualTimeDomain();
1851 for (const scoped_refptr<TaskQueue>& task_queue : unthrottled_task_runners_) 1856 for (const scoped_refptr<TaskQueue>& task_queue : unthrottled_task_runners_)
1852 task_queue->SetTimeDomain(time_domain); 1857 task_queue->SetTimeDomain(time_domain);
1853 1858
1859 DCHECK(!virtual_time_control_task_queue_);
1860 virtual_time_control_task_queue_ =
1861 helper_.NewTaskQueue(TaskQueue::Spec(TaskQueue::QueueType::CONTROL));
1862 virtual_time_control_task_queue_->SetQueuePriority(
1863 TaskQueue::CONTROL_PRIORITY);
1864 virtual_time_control_task_queue_->SetTimeDomain(time_domain);
1865
1854 ForceUpdatePolicy(); 1866 ForceUpdatePolicy();
1855 } 1867 }
1856 1868
1857 void RendererSchedulerImpl::DisableVirtualTimeForTesting() { 1869 void RendererSchedulerImpl::DisableVirtualTimeForTesting() {
1858 GetMainThreadOnly().use_virtual_time = false; 1870 GetMainThreadOnly().use_virtual_time = false;
1859 1871
1860 RealTimeDomain* time_domain = real_time_domain(); 1872 RealTimeDomain* time_domain = real_time_domain();
1861 // The |unthrottled_task_runners_| are not actively managed by UpdatePolicy(). 1873 // The |unthrottled_task_runners_| are not actively managed by UpdatePolicy().
1862 for (const scoped_refptr<TaskQueue>& task_queue : unthrottled_task_runners_) 1874 for (const scoped_refptr<TaskQueue>& task_queue : unthrottled_task_runners_)
1863 task_queue->SetTimeDomain(time_domain); 1875 task_queue->SetTimeDomain(time_domain);
1876 virtual_time_control_task_queue_->UnregisterTaskQueue();
1877 virtual_time_control_task_queue_ = nullptr;
1864 1878
1865 ForceUpdatePolicy(); 1879 ForceUpdatePolicy();
1866 } 1880 }
1867 1881
1868 bool RendererSchedulerImpl::ShouldDisableThrottlingBecauseOfAudio( 1882 bool RendererSchedulerImpl::ShouldDisableThrottlingBecauseOfAudio(
1869 base::TimeTicks now) { 1883 base::TimeTicks now) {
1870 if (!GetMainThreadOnly().last_audio_state_change) 1884 if (!GetMainThreadOnly().last_audio_state_change)
1871 return false; 1885 return false;
1872 1886
1873 if (GetMainThreadOnly().is_audio_playing) 1887 if (GetMainThreadOnly().is_audio_playing)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 case TimeDomainType::VIRTUAL: 1957 case TimeDomainType::VIRTUAL:
1944 return "virtual"; 1958 return "virtual";
1945 default: 1959 default:
1946 NOTREACHED(); 1960 NOTREACHED();
1947 return nullptr; 1961 return nullptr;
1948 } 1962 }
1949 } 1963 }
1950 1964
1951 } // namespace scheduler 1965 } // namespace scheduler
1952 } // namespace blink 1966 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698