OLD | NEW |
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 "components/scheduler/renderer/renderer_scheduler_impl.h" | 5 #include "components/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" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
13 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
14 #include "cc/output/begin_frame_args.h" | 14 #include "cc/output/begin_frame_args.h" |
15 #include "components/scheduler/base/task_queue_impl.h" | 15 #include "components/scheduler/base/task_queue_impl.h" |
16 #include "components/scheduler/base/task_queue_selector.h" | 16 #include "components/scheduler/base/task_queue_selector.h" |
17 #include "components/scheduler/base/virtual_time_domain.h" | 17 #include "components/scheduler/base/virtual_time_domain.h" |
18 #include "components/scheduler/child/scheduler_tqm_delegate.h" | 18 #include "components/scheduler/child/scheduler_tqm_delegate.h" |
| 19 #include "components/scheduler/renderer/auto_advancing_virtual_time_domain.h" |
19 #include "components/scheduler/renderer/web_view_scheduler_impl.h" | 20 #include "components/scheduler/renderer/web_view_scheduler_impl.h" |
20 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" | 21 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" |
21 | 22 |
22 namespace scheduler { | 23 namespace scheduler { |
23 namespace { | 24 namespace { |
24 // The run time of loading tasks is strongly bimodal. The vast majority are | 25 // The run time of loading tasks is strongly bimodal. The vast majority are |
25 // very cheap, but there are usually a handful of very expensive tasks (e.g ~1 | 26 // very cheap, but there are usually a handful of very expensive tasks (e.g ~1 |
26 // second on a mobile device) so we take a very pessimistic view when estimating | 27 // second on a mobile device) so we take a very pessimistic view when estimating |
27 // the cost of loading tasks. | 28 // the cost of loading tasks. |
28 const int kLoadingTaskEstimationSampleCount = 1000; | 29 const int kLoadingTaskEstimationSampleCount = 1000; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 90 |
90 for (const scoped_refptr<TaskQueue>& loading_queue : loading_task_runners_) { | 91 for (const scoped_refptr<TaskQueue>& loading_queue : loading_task_runners_) { |
91 loading_queue->RemoveTaskObserver( | 92 loading_queue->RemoveTaskObserver( |
92 &MainThreadOnly().loading_task_cost_estimator); | 93 &MainThreadOnly().loading_task_cost_estimator); |
93 } | 94 } |
94 for (const scoped_refptr<TaskQueue>& timer_queue : timer_task_runners_) { | 95 for (const scoped_refptr<TaskQueue>& timer_queue : timer_task_runners_) { |
95 timer_queue->RemoveTaskObserver( | 96 timer_queue->RemoveTaskObserver( |
96 &MainThreadOnly().timer_task_cost_estimator); | 97 &MainThreadOnly().timer_task_cost_estimator); |
97 } | 98 } |
98 | 99 |
| 100 if (virtual_time_domain_) |
| 101 UnregisterTimeDomain(virtual_time_domain_.get()); |
| 102 |
99 // Ensure the renderer scheduler was shut down explicitly, because otherwise | 103 // Ensure the renderer scheduler was shut down explicitly, because otherwise |
100 // we could end up having stale pointers to the Blink heap which has been | 104 // we could end up having stale pointers to the Blink heap which has been |
101 // terminated by this point. | 105 // terminated by this point. |
102 DCHECK(MainThreadOnly().was_shutdown); | 106 DCHECK(MainThreadOnly().was_shutdown); |
103 } | 107 } |
104 | 108 |
105 RendererSchedulerImpl::MainThreadOnly::MainThreadOnly( | 109 RendererSchedulerImpl::MainThreadOnly::MainThreadOnly( |
106 RendererSchedulerImpl* renderer_scheduler_impl, | 110 RendererSchedulerImpl* renderer_scheduler_impl, |
107 const scoped_refptr<TaskQueue>& compositor_task_runner, | 111 const scoped_refptr<TaskQueue>& compositor_task_runner, |
108 base::TickClock* time_source) | 112 base::TickClock* time_source) |
(...skipping 22 matching lines...) Expand all Loading... |
131 loading_tasks_seem_expensive(false), | 135 loading_tasks_seem_expensive(false), |
132 timer_tasks_seem_expensive(false), | 136 timer_tasks_seem_expensive(false), |
133 touchstart_expected_soon(false), | 137 touchstart_expected_soon(false), |
134 have_seen_a_begin_main_frame(false), | 138 have_seen_a_begin_main_frame(false), |
135 have_reported_blocking_intervention_in_current_policy(false), | 139 have_reported_blocking_intervention_in_current_policy(false), |
136 have_reported_blocking_intervention_since_navigation(false), | 140 have_reported_blocking_intervention_since_navigation(false), |
137 has_visible_render_widget_with_touch_handler(false), | 141 has_visible_render_widget_with_touch_handler(false), |
138 begin_frame_not_expected_soon(false), | 142 begin_frame_not_expected_soon(false), |
139 expensive_task_blocking_allowed(true), | 143 expensive_task_blocking_allowed(true), |
140 in_idle_period_for_testing(false), | 144 in_idle_period_for_testing(false), |
| 145 use_virtual_time(false), |
141 rail_mode_observer(nullptr) {} | 146 rail_mode_observer(nullptr) {} |
142 | 147 |
143 RendererSchedulerImpl::MainThreadOnly::~MainThreadOnly() {} | 148 RendererSchedulerImpl::MainThreadOnly::~MainThreadOnly() {} |
144 | 149 |
145 RendererSchedulerImpl::AnyThread::AnyThread() | 150 RendererSchedulerImpl::AnyThread::AnyThread() |
146 : awaiting_touch_start_response(false), | 151 : awaiting_touch_start_response(false), |
147 in_idle_period(false), | 152 in_idle_period(false), |
148 begin_main_frame_on_critical_path(false), | 153 begin_main_frame_on_critical_path(false), |
149 last_gesture_was_compositor_driven(false), | 154 last_gesture_was_compositor_driven(false), |
150 default_gesture_prevented(true), | 155 default_gesture_prevented(true), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 199 |
195 scoped_refptr<TaskQueue> RendererSchedulerImpl::ControlTaskRunner() { | 200 scoped_refptr<TaskQueue> RendererSchedulerImpl::ControlTaskRunner() { |
196 helper_.CheckOnValidThread(); | 201 helper_.CheckOnValidThread(); |
197 return helper_.ControlTaskRunner(); | 202 return helper_.ControlTaskRunner(); |
198 } | 203 } |
199 | 204 |
200 scoped_refptr<TaskQueue> RendererSchedulerImpl::NewLoadingTaskRunner( | 205 scoped_refptr<TaskQueue> RendererSchedulerImpl::NewLoadingTaskRunner( |
201 const char* name) { | 206 const char* name) { |
202 helper_.CheckOnValidThread(); | 207 helper_.CheckOnValidThread(); |
203 scoped_refptr<TaskQueue> loading_task_queue(helper_.NewTaskQueue( | 208 scoped_refptr<TaskQueue> loading_task_queue(helper_.NewTaskQueue( |
204 TaskQueue::Spec(name).SetShouldMonitorQuiescence(true))); | 209 TaskQueue::Spec(name).SetShouldMonitorQuiescence(true).SetTimeDomain( |
| 210 MainThreadOnly().use_virtual_time ? GetVirtualTimeDomain() |
| 211 : nullptr))); |
205 loading_task_runners_.insert(loading_task_queue); | 212 loading_task_runners_.insert(loading_task_queue); |
206 loading_task_queue->SetQueueEnabled( | 213 loading_task_queue->SetQueueEnabled( |
207 MainThreadOnly().current_policy.loading_queue_policy.is_enabled); | 214 MainThreadOnly().current_policy.loading_queue_policy.is_enabled); |
208 loading_task_queue->SetQueuePriority( | 215 loading_task_queue->SetQueuePriority( |
209 MainThreadOnly().current_policy.loading_queue_policy.priority); | 216 MainThreadOnly().current_policy.loading_queue_policy.priority); |
210 if (MainThreadOnly().current_policy.loading_queue_policy.time_domain_type == | 217 if (MainThreadOnly().current_policy.loading_queue_policy.time_domain_type == |
211 TimeDomainType::THROTTLED) { | 218 TimeDomainType::THROTTLED) { |
212 throttling_helper_->IncreaseThrottleRefCount(loading_task_queue.get()); | 219 throttling_helper_->IncreaseThrottleRefCount(loading_task_queue.get()); |
213 } | 220 } |
214 loading_task_queue->AddTaskObserver( | 221 loading_task_queue->AddTaskObserver( |
215 &MainThreadOnly().loading_task_cost_estimator); | 222 &MainThreadOnly().loading_task_cost_estimator); |
216 return loading_task_queue; | 223 return loading_task_queue; |
217 } | 224 } |
218 | 225 |
219 scoped_refptr<TaskQueue> RendererSchedulerImpl::NewTimerTaskRunner( | 226 scoped_refptr<TaskQueue> RendererSchedulerImpl::NewTimerTaskRunner( |
220 const char* name) { | 227 const char* name) { |
221 helper_.CheckOnValidThread(); | 228 helper_.CheckOnValidThread(); |
| 229 // TODO(alexclarke): Consider using ApplyTaskQueuePolicy() for brevity. |
222 scoped_refptr<TaskQueue> timer_task_queue( | 230 scoped_refptr<TaskQueue> timer_task_queue( |
223 helper_.NewTaskQueue(TaskQueue::Spec(name) | 231 helper_.NewTaskQueue(TaskQueue::Spec(name) |
224 .SetShouldMonitorQuiescence(true) | 232 .SetShouldMonitorQuiescence(true) |
225 .SetShouldReportWhenExecutionBlocked(true))); | 233 .SetShouldReportWhenExecutionBlocked(true) |
| 234 .SetTimeDomain(MainThreadOnly().use_virtual_time |
| 235 ? GetVirtualTimeDomain() |
| 236 : nullptr))); |
226 timer_task_runners_.insert(timer_task_queue); | 237 timer_task_runners_.insert(timer_task_queue); |
227 timer_task_queue->SetQueueEnabled( | 238 timer_task_queue->SetQueueEnabled( |
228 MainThreadOnly().current_policy.timer_queue_policy.is_enabled); | 239 MainThreadOnly().current_policy.timer_queue_policy.is_enabled); |
229 timer_task_queue->SetQueuePriority( | 240 timer_task_queue->SetQueuePriority( |
230 MainThreadOnly().current_policy.timer_queue_policy.priority); | 241 MainThreadOnly().current_policy.timer_queue_policy.priority); |
231 if (MainThreadOnly().current_policy.timer_queue_policy.time_domain_type == | 242 if (MainThreadOnly().current_policy.timer_queue_policy.time_domain_type == |
232 TimeDomainType::THROTTLED) { | 243 TimeDomainType::THROTTLED) { |
233 throttling_helper_->IncreaseThrottleRefCount(timer_task_queue.get()); | 244 throttling_helper_->IncreaseThrottleRefCount(timer_task_queue.get()); |
234 } | 245 } |
235 timer_task_queue->AddTaskObserver( | 246 timer_task_queue->AddTaskObserver( |
236 &MainThreadOnly().timer_task_cost_estimator); | 247 &MainThreadOnly().timer_task_cost_estimator); |
237 return timer_task_queue; | 248 return timer_task_queue; |
238 } | 249 } |
239 | 250 |
240 scoped_refptr<TaskQueue> RendererSchedulerImpl::NewUnthrottledTaskRunner( | 251 scoped_refptr<TaskQueue> RendererSchedulerImpl::NewUnthrottledTaskRunner( |
241 const char* name) { | 252 const char* name) { |
242 helper_.CheckOnValidThread(); | 253 helper_.CheckOnValidThread(); |
243 scoped_refptr<TaskQueue> unthrottled_task_queue(helper_.NewTaskQueue( | 254 scoped_refptr<TaskQueue> unthrottled_task_queue(helper_.NewTaskQueue( |
244 TaskQueue::Spec(name).SetShouldMonitorQuiescence(true))); | 255 TaskQueue::Spec(name).SetShouldMonitorQuiescence(true).SetTimeDomain( |
| 256 MainThreadOnly().use_virtual_time ? GetVirtualTimeDomain() |
| 257 : nullptr))); |
| 258 unthrottled_task_runners_.insert(unthrottled_task_queue); |
245 return unthrottled_task_queue; | 259 return unthrottled_task_queue; |
246 } | 260 } |
247 | 261 |
248 std::unique_ptr<RenderWidgetSchedulingState> | 262 std::unique_ptr<RenderWidgetSchedulingState> |
249 RendererSchedulerImpl::NewRenderWidgetSchedulingState() { | 263 RendererSchedulerImpl::NewRenderWidgetSchedulingState() { |
250 return render_widget_scheduler_signals_.NewRenderWidgetSchedulingState(); | 264 return render_widget_scheduler_signals_.NewRenderWidgetSchedulingState(); |
251 } | 265 } |
252 | 266 |
253 void RendererSchedulerImpl::OnUnregisterTaskQueue( | 267 void RendererSchedulerImpl::OnUnregisterTaskQueue( |
254 const scoped_refptr<TaskQueue>& task_queue) { | 268 const scoped_refptr<TaskQueue>& task_queue) { |
255 if (throttling_helper_.get()) | 269 if (throttling_helper_.get()) |
256 throttling_helper_->UnregisterTaskQueue(task_queue.get()); | 270 throttling_helper_->UnregisterTaskQueue(task_queue.get()); |
257 | 271 |
258 if (loading_task_runners_.find(task_queue) != loading_task_runners_.end()) { | 272 if (loading_task_runners_.find(task_queue) != loading_task_runners_.end()) { |
259 task_queue->RemoveTaskObserver( | 273 task_queue->RemoveTaskObserver( |
260 &MainThreadOnly().loading_task_cost_estimator); | 274 &MainThreadOnly().loading_task_cost_estimator); |
261 loading_task_runners_.erase(task_queue); | 275 loading_task_runners_.erase(task_queue); |
262 } else if (timer_task_runners_.find(task_queue) != | 276 } else if (timer_task_runners_.find(task_queue) != |
263 timer_task_runners_.end()) { | 277 timer_task_runners_.end()) { |
264 task_queue->RemoveTaskObserver(&MainThreadOnly().timer_task_cost_estimator); | 278 task_queue->RemoveTaskObserver(&MainThreadOnly().timer_task_cost_estimator); |
265 timer_task_runners_.erase(task_queue); | 279 timer_task_runners_.erase(task_queue); |
| 280 } else if (unthrottled_task_runners_.find(task_queue) != |
| 281 unthrottled_task_runners_.end()) { |
| 282 unthrottled_task_runners_.erase(task_queue); |
266 } | 283 } |
267 } | 284 } |
268 | 285 |
269 bool RendererSchedulerImpl::CanExceedIdleDeadlineIfRequired() const { | 286 bool RendererSchedulerImpl::CanExceedIdleDeadlineIfRequired() const { |
270 return idle_helper_.CanExceedIdleDeadlineIfRequired(); | 287 return idle_helper_.CanExceedIdleDeadlineIfRequired(); |
271 } | 288 } |
272 | 289 |
273 void RendererSchedulerImpl::AddTaskObserver( | 290 void RendererSchedulerImpl::AddTaskObserver( |
274 base::MessageLoop::TaskObserver* task_observer) { | 291 base::MessageLoop::TaskObserver* task_observer) { |
275 helper_.AddTaskObserver(task_observer); | 292 helper_.AddTaskObserver(task_observer); |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 if (loading_tasks_seem_expensive) { | 872 if (loading_tasks_seem_expensive) { |
856 new_policy.loading_queue_policy.time_domain_type = | 873 new_policy.loading_queue_policy.time_domain_type = |
857 TimeDomainType::THROTTLED; | 874 TimeDomainType::THROTTLED; |
858 } | 875 } |
859 if (timer_tasks_seem_expensive) { | 876 if (timer_tasks_seem_expensive) { |
860 new_policy.timer_queue_policy.time_domain_type = | 877 new_policy.timer_queue_policy.time_domain_type = |
861 TimeDomainType::THROTTLED; | 878 TimeDomainType::THROTTLED; |
862 } | 879 } |
863 break; | 880 break; |
864 } | 881 } |
865 | |
866 MainThreadOnly().expensive_task_policy = expensive_task_policy; | 882 MainThreadOnly().expensive_task_policy = expensive_task_policy; |
867 | 883 |
868 if (MainThreadOnly().timer_queue_suspend_count != 0 || | 884 if (MainThreadOnly().timer_queue_suspend_count != 0 || |
869 MainThreadOnly().timer_queue_suspended_when_backgrounded) { | 885 MainThreadOnly().timer_queue_suspended_when_backgrounded) { |
870 new_policy.timer_queue_policy.is_enabled = false; | 886 new_policy.timer_queue_policy.is_enabled = false; |
| 887 // TODO(alexclarke): Figure out if we really need to do this. |
871 new_policy.timer_queue_policy.time_domain_type = TimeDomainType::REAL; | 888 new_policy.timer_queue_policy.time_domain_type = TimeDomainType::REAL; |
872 } | 889 } |
873 | 890 |
874 if (MainThreadOnly().renderer_suspended) { | 891 if (MainThreadOnly().renderer_suspended) { |
875 new_policy.loading_queue_policy.is_enabled = false; | 892 new_policy.loading_queue_policy.is_enabled = false; |
876 DCHECK(!new_policy.timer_queue_policy.is_enabled); | 893 DCHECK(!new_policy.timer_queue_policy.is_enabled); |
877 } | 894 } |
878 | 895 |
| 896 if (MainThreadOnly().use_virtual_time) { |
| 897 new_policy.compositor_queue_policy.time_domain_type = |
| 898 TimeDomainType::VIRTUAL; |
| 899 new_policy.default_queue_policy.time_domain_type = TimeDomainType::VIRTUAL; |
| 900 new_policy.loading_queue_policy.time_domain_type = TimeDomainType::VIRTUAL; |
| 901 new_policy.timer_queue_policy.time_domain_type = TimeDomainType::VIRTUAL; |
| 902 } |
| 903 |
879 // Tracing is done before the early out check, because it's quite possible we | 904 // Tracing is done before the early out check, because it's quite possible we |
880 // will otherwise miss this information in traces. | 905 // will otherwise miss this information in traces. |
881 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 906 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
882 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", | 907 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", |
883 this, AsValueLocked(now)); | 908 this, AsValueLocked(now)); |
884 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case", | 909 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case", |
885 use_case); | 910 use_case); |
886 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "rail_mode", | 911 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "rail_mode", |
887 new_policy.rail_mode); | 912 new_policy.rail_mode); |
888 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 913 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 if (old_task_queue_policy.is_enabled != new_task_queue_policy.is_enabled) { | 969 if (old_task_queue_policy.is_enabled != new_task_queue_policy.is_enabled) { |
945 throttling_helper_->SetQueueEnabled(task_queue, | 970 throttling_helper_->SetQueueEnabled(task_queue, |
946 new_task_queue_policy.is_enabled); | 971 new_task_queue_policy.is_enabled); |
947 } | 972 } |
948 | 973 |
949 if (old_task_queue_policy.priority != new_task_queue_policy.priority) | 974 if (old_task_queue_policy.priority != new_task_queue_policy.priority) |
950 task_queue->SetQueuePriority(new_task_queue_policy.priority); | 975 task_queue->SetQueuePriority(new_task_queue_policy.priority); |
951 | 976 |
952 if (old_task_queue_policy.time_domain_type != | 977 if (old_task_queue_policy.time_domain_type != |
953 new_task_queue_policy.time_domain_type) { | 978 new_task_queue_policy.time_domain_type) { |
954 if (new_task_queue_policy.time_domain_type == TimeDomainType::THROTTLED) { | 979 if (old_task_queue_policy.time_domain_type == TimeDomainType::THROTTLED) { |
| 980 throttling_helper_->DecreaseThrottleRefCount(task_queue); |
| 981 } else if (new_task_queue_policy.time_domain_type == |
| 982 TimeDomainType::THROTTLED) { |
955 throttling_helper_->IncreaseThrottleRefCount(task_queue); | 983 throttling_helper_->IncreaseThrottleRefCount(task_queue); |
956 } else if (old_task_queue_policy.time_domain_type == | 984 } else if (new_task_queue_policy.time_domain_type == |
957 TimeDomainType::THROTTLED) { | 985 TimeDomainType::VIRTUAL) { |
958 throttling_helper_->DecreaseThrottleRefCount(task_queue); | 986 DCHECK(virtual_time_domain_); |
| 987 task_queue->SetTimeDomain(virtual_time_domain_.get()); |
959 } | 988 } |
960 } | 989 } |
961 } | 990 } |
962 | 991 |
963 RendererSchedulerImpl::UseCase RendererSchedulerImpl::ComputeCurrentUseCase( | 992 RendererSchedulerImpl::UseCase RendererSchedulerImpl::ComputeCurrentUseCase( |
964 base::TimeTicks now, | 993 base::TimeTicks now, |
965 base::TimeDelta* expected_use_case_duration) const { | 994 base::TimeDelta* expected_use_case_duration) const { |
966 any_thread_lock_.AssertAcquired(); | 995 any_thread_lock_.AssertAcquired(); |
967 // Special case for flings. This is needed because we don't get notification | 996 // Special case for flings. This is needed because we don't get notification |
968 // of a fling ending (although we do for cancellation). | 997 // of a fling ending (although we do for cancellation). |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 | 1431 |
1403 void RendererSchedulerImpl::OnQueueingTimeForWindowEstimated( | 1432 void RendererSchedulerImpl::OnQueueingTimeForWindowEstimated( |
1404 base::TimeDelta queueing_time) { | 1433 base::TimeDelta queueing_time) { |
1405 UMA_HISTOGRAM_TIMES("RendererScheduler.ExpectedTaskQueueingDuration", | 1434 UMA_HISTOGRAM_TIMES("RendererScheduler.ExpectedTaskQueueingDuration", |
1406 queueing_time); | 1435 queueing_time); |
1407 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 1436 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
1408 "estimated_queueing_time_for_window", | 1437 "estimated_queueing_time_for_window", |
1409 queueing_time.InMillisecondsF()); | 1438 queueing_time.InMillisecondsF()); |
1410 } | 1439 } |
1411 | 1440 |
| 1441 AutoAdvancingVirtualTimeDomain* RendererSchedulerImpl::GetVirtualTimeDomain() { |
| 1442 if (!virtual_time_domain_) { |
| 1443 virtual_time_domain_.reset( |
| 1444 new AutoAdvancingVirtualTimeDomain(tick_clock()->NowTicks())); |
| 1445 RegisterTimeDomain(virtual_time_domain_.get()); |
| 1446 } |
| 1447 return virtual_time_domain_.get(); |
| 1448 } |
| 1449 |
| 1450 void RendererSchedulerImpl::EnableVirtualTime() { |
| 1451 MainThreadOnly().use_virtual_time = true; |
| 1452 |
| 1453 // The |unthrottled_task_runners_| are not actively managed by UpdatePolicy(). |
| 1454 AutoAdvancingVirtualTimeDomain* time_domain = GetVirtualTimeDomain(); |
| 1455 for (const scoped_refptr<TaskQueue>& task_queue : unthrottled_task_runners_) |
| 1456 task_queue->SetTimeDomain(time_domain); |
| 1457 |
| 1458 throttling_helper_->EnableVirtualTime(); |
| 1459 |
| 1460 ForceUpdatePolicy(); |
| 1461 } |
| 1462 |
1412 // static | 1463 // static |
1413 const char* RendererSchedulerImpl::UseCaseToString(UseCase use_case) { | 1464 const char* RendererSchedulerImpl::UseCaseToString(UseCase use_case) { |
1414 switch (use_case) { | 1465 switch (use_case) { |
1415 case UseCase::NONE: | 1466 case UseCase::NONE: |
1416 return "none"; | 1467 return "none"; |
1417 case UseCase::COMPOSITOR_GESTURE: | 1468 case UseCase::COMPOSITOR_GESTURE: |
1418 return "compositor_gesture"; | 1469 return "compositor_gesture"; |
1419 case UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING: | 1470 case UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING: |
1420 return "main_thread_custom_input_handling"; | 1471 return "main_thread_custom_input_handling"; |
1421 case UseCase::SYNCHRONIZED_GESTURE: | 1472 case UseCase::SYNCHRONIZED_GESTURE: |
(...skipping 21 matching lines...) Expand all Loading... |
1443 return "idle"; | 1494 return "idle"; |
1444 case v8::PERFORMANCE_LOAD: | 1495 case v8::PERFORMANCE_LOAD: |
1445 return "load"; | 1496 return "load"; |
1446 default: | 1497 default: |
1447 NOTREACHED(); | 1498 NOTREACHED(); |
1448 return nullptr; | 1499 return nullptr; |
1449 } | 1500 } |
1450 } | 1501 } |
1451 | 1502 |
1452 } // namespace scheduler | 1503 } // namespace scheduler |
OLD | NEW |