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