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 "content/renderer/scheduler/renderer_scheduler_impl.h" | 5 #include "content/renderer/scheduler/renderer_scheduler_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 task_queue_manager_->TaskRunnerForQueue(CONTROL_TASK_QUEUE)), | 25 task_queue_manager_->TaskRunnerForQueue(CONTROL_TASK_QUEUE)), |
26 control_task_after_wakeup_runner_(task_queue_manager_->TaskRunnerForQueue( | 26 control_task_after_wakeup_runner_(task_queue_manager_->TaskRunnerForQueue( |
27 CONTROL_TASK_AFTER_WAKEUP_QUEUE)), | 27 CONTROL_TASK_AFTER_WAKEUP_QUEUE)), |
28 default_task_runner_( | 28 default_task_runner_( |
29 task_queue_manager_->TaskRunnerForQueue(DEFAULT_TASK_QUEUE)), | 29 task_queue_manager_->TaskRunnerForQueue(DEFAULT_TASK_QUEUE)), |
30 compositor_task_runner_( | 30 compositor_task_runner_( |
31 task_queue_manager_->TaskRunnerForQueue(COMPOSITOR_TASK_QUEUE)), | 31 task_queue_manager_->TaskRunnerForQueue(COMPOSITOR_TASK_QUEUE)), |
32 loading_task_runner_( | 32 loading_task_runner_( |
33 task_queue_manager_->TaskRunnerForQueue(LOADING_TASK_QUEUE)), | 33 task_queue_manager_->TaskRunnerForQueue(LOADING_TASK_QUEUE)), |
34 current_policy_(Policy::NORMAL), | 34 current_policy_(Policy::NORMAL), |
| 35 in_idle_period_(false), |
35 last_input_type_(blink::WebInputEvent::Undefined), | 36 last_input_type_(blink::WebInputEvent::Undefined), |
36 input_stream_state_(InputStreamState::INACTIVE), | 37 input_stream_state_(InputStreamState::INACTIVE), |
37 policy_may_need_update_(&incoming_signals_lock_), | 38 policy_may_need_update_(&incoming_signals_lock_), |
38 weak_factory_(this) { | 39 weak_factory_(this) { |
39 weak_renderer_scheduler_ptr_ = weak_factory_.GetWeakPtr(); | 40 weak_renderer_scheduler_ptr_ = weak_factory_.GetWeakPtr(); |
40 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy, | 41 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy, |
41 weak_renderer_scheduler_ptr_); | 42 weak_renderer_scheduler_ptr_); |
42 end_idle_period_closure_.Reset(base::Bind( | 43 end_idle_period_closure_.Reset(base::Bind( |
43 &RendererSchedulerImpl::EndIdlePeriod, weak_renderer_scheduler_ptr_)); | 44 &RendererSchedulerImpl::EndIdlePeriod, weak_renderer_scheduler_ptr_, |
| 45 false)); |
| 46 initiate_next_long_idle_period_closure_.Reset(base::Bind( |
| 47 &RendererSchedulerImpl::InitiateLongIdlePeriod, |
| 48 weak_renderer_scheduler_ptr_)); |
| 49 initiate_next_long_idle_period_after_wakeup_closure_.Reset(base::Bind( |
| 50 &RendererSchedulerImpl::InitiateLongIdlePeriodAfterWakeup, |
| 51 weak_renderer_scheduler_ptr_)); |
| 52 |
44 idle_task_runner_ = make_scoped_refptr(new SingleThreadIdleTaskRunner( | 53 idle_task_runner_ = make_scoped_refptr(new SingleThreadIdleTaskRunner( |
45 task_queue_manager_->TaskRunnerForQueue(IDLE_TASK_QUEUE), | 54 task_queue_manager_->TaskRunnerForQueue(IDLE_TASK_QUEUE), |
46 control_task_after_wakeup_runner_, | 55 control_task_after_wakeup_runner_, |
47 base::Bind(&RendererSchedulerImpl::CurrentIdleTaskDeadlineCallback, | 56 base::Bind(&RendererSchedulerImpl::CurrentIdleTaskDeadlineCallback, |
48 weak_renderer_scheduler_ptr_))); | 57 weak_renderer_scheduler_ptr_))); |
49 | 58 |
50 renderer_task_queue_selector_->SetQueuePriority( | 59 renderer_task_queue_selector_->SetQueuePriority( |
51 CONTROL_TASK_QUEUE, RendererTaskQueueSelector::CONTROL_PRIORITY); | 60 CONTROL_TASK_QUEUE, RendererTaskQueueSelector::CONTROL_PRIORITY); |
52 | 61 |
53 renderer_task_queue_selector_->SetQueuePriority( | 62 renderer_task_queue_selector_->SetQueuePriority( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 133 |
125 void RendererSchedulerImpl::DidCommitFrameToCompositor() { | 134 void RendererSchedulerImpl::DidCommitFrameToCompositor() { |
126 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 135 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
127 "RendererSchedulerImpl::DidCommitFrameToCompositor"); | 136 "RendererSchedulerImpl::DidCommitFrameToCompositor"); |
128 DCHECK(main_thread_checker_.CalledOnValidThread()); | 137 DCHECK(main_thread_checker_.CalledOnValidThread()); |
129 if (!task_queue_manager_) | 138 if (!task_queue_manager_) |
130 return; | 139 return; |
131 | 140 |
132 base::TimeTicks now(Now()); | 141 base::TimeTicks now(Now()); |
133 if (now < estimated_next_frame_begin_) { | 142 if (now < estimated_next_frame_begin_) { |
| 143 // TODO(rmcilroy): Consider reducing the idle period based on the runtime of |
| 144 // the next pending delayed tasks (as currently done in for long idle times) |
134 StartIdlePeriod(); | 145 StartIdlePeriod(); |
135 control_task_runner_->PostDelayedTask(FROM_HERE, | 146 control_task_runner_->PostDelayedTask(FROM_HERE, |
136 end_idle_period_closure_.callback(), | 147 end_idle_period_closure_.callback(), |
137 estimated_next_frame_begin_ - now); | 148 estimated_next_frame_begin_ - now); |
138 } | 149 } |
139 } | 150 } |
140 | 151 |
141 void RendererSchedulerImpl::BeginFrameNotExpectedSoon() { | 152 void RendererSchedulerImpl::BeginFrameNotExpectedSoon() { |
142 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 153 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
143 "RendererSchedulerImpl::BeginFrameNotExpectedSoon"); | 154 "RendererSchedulerImpl::BeginFrameNotExpectedSoon"); |
144 DCHECK(main_thread_checker_.CalledOnValidThread()); | 155 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 156 if (!task_queue_manager_) |
| 157 return; |
| 158 |
145 // TODO(skyostil): Wire up real notification of input events processing | 159 // TODO(skyostil): Wire up real notification of input events processing |
146 // instead of this approximation. | 160 // instead of this approximation. |
147 DidProcessInputEvent(base::TimeTicks()); | 161 DidProcessInputEvent(base::TimeTicks()); |
148 // TODO(rmcilroy): Implement long idle times. | 162 |
| 163 InitiateLongIdlePeriod(); |
149 } | 164 } |
150 | 165 |
151 void RendererSchedulerImpl::DidReceiveInputEventOnCompositorThread( | 166 void RendererSchedulerImpl::DidReceiveInputEventOnCompositorThread( |
152 const blink::WebInputEvent& web_input_event) { | 167 const blink::WebInputEvent& web_input_event) { |
153 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 168 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
154 "RendererSchedulerImpl::DidReceiveInputEventOnCompositorThread"); | 169 "RendererSchedulerImpl::DidReceiveInputEventOnCompositorThread"); |
155 // We regard MouseMove events with the left mouse button down as a signal | 170 // We regard MouseMove events with the left mouse button down as a signal |
156 // that the user is doing something requiring a smooth frame rate. | 171 // that the user is doing something requiring a smooth frame rate. |
157 if (web_input_event.type == blink::WebInputEvent::MouseMove && | 172 if (web_input_event.type == blink::WebInputEvent::MouseMove && |
158 (web_input_event.modifiers & blink::WebInputEvent::LeftButtonDown)) { | 173 (web_input_event.modifiers & blink::WebInputEvent::LeftButtonDown)) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 DCHECK(main_thread_checker_.CalledOnValidThread()); | 293 DCHECK(main_thread_checker_.CalledOnValidThread()); |
279 if (!task_queue_manager_) | 294 if (!task_queue_manager_) |
280 return; | 295 return; |
281 | 296 |
282 base::AutoLock lock(incoming_signals_lock_); | 297 base::AutoLock lock(incoming_signals_lock_); |
283 base::TimeTicks now; | 298 base::TimeTicks now; |
284 policy_may_need_update_.SetWhileLocked(false); | 299 policy_may_need_update_.SetWhileLocked(false); |
285 | 300 |
286 base::TimeDelta new_policy_duration; | 301 base::TimeDelta new_policy_duration; |
287 Policy new_policy = ComputeNewPolicy(&new_policy_duration); | 302 Policy new_policy = ComputeNewPolicy(&new_policy_duration); |
288 if (new_policy_duration > base::TimeDelta()) | 303 if (new_policy_duration > base::TimeDelta()) { |
| 304 current_policy_expiration_time_ = now + new_policy_duration; |
289 PostUpdatePolicyOnControlRunner(new_policy_duration); | 305 PostUpdatePolicyOnControlRunner(new_policy_duration); |
| 306 } else { |
| 307 current_policy_expiration_time_ = base::TimeTicks(); |
| 308 } |
290 | 309 |
291 if (new_policy == current_policy_) | 310 if (new_policy == current_policy_) |
292 return; | 311 return; |
293 | 312 |
294 switch (new_policy) { | 313 switch (new_policy) { |
295 case Policy::COMPOSITOR_PRIORITY: | 314 case Policy::COMPOSITOR_PRIORITY: |
296 renderer_task_queue_selector_->SetQueuePriority( | 315 renderer_task_queue_selector_->SetQueuePriority( |
297 COMPOSITOR_TASK_QUEUE, RendererTaskQueueSelector::HIGH_PRIORITY); | 316 COMPOSITOR_TASK_QUEUE, RendererTaskQueueSelector::HIGH_PRIORITY); |
298 // TODO(scheduler-dev): Add a task priority between HIGH and BEST_EFFORT | 317 // TODO(scheduler-dev): Add a task priority between HIGH and BEST_EFFORT |
299 // that still has some guarantee of running. | 318 // that still has some guarantee of running. |
(...skipping 29 matching lines...) Expand all Loading... |
329 base::TimeDelta* new_policy_duration) { | 348 base::TimeDelta* new_policy_duration) { |
330 DCHECK(main_thread_checker_.CalledOnValidThread()); | 349 DCHECK(main_thread_checker_.CalledOnValidThread()); |
331 incoming_signals_lock_.AssertAcquired(); | 350 incoming_signals_lock_.AssertAcquired(); |
332 | 351 |
333 Policy new_policy = Policy::NORMAL; | 352 Policy new_policy = Policy::NORMAL; |
334 *new_policy_duration = base::TimeDelta(); | 353 *new_policy_duration = base::TimeDelta(); |
335 | 354 |
336 if (input_stream_state_ == InputStreamState::INACTIVE) | 355 if (input_stream_state_ == InputStreamState::INACTIVE) |
337 return new_policy; | 356 return new_policy; |
338 | 357 |
339 base::TimeDelta new_priority_duration = | |
340 base::TimeDelta::FromMilliseconds(kPriorityEscalationAfterInputMillis); | |
341 Policy input_priority_policy = | 358 Policy input_priority_policy = |
342 input_stream_state_ == | 359 input_stream_state_ == |
343 InputStreamState::ACTIVE_AND_AWAITING_TOUCHSTART_RESPONSE | 360 InputStreamState::ACTIVE_AND_AWAITING_TOUCHSTART_RESPONSE |
344 ? Policy::TOUCHSTART_PRIORITY | 361 ? Policy::TOUCHSTART_PRIORITY |
345 : Policy::COMPOSITOR_PRIORITY; | 362 : Policy::COMPOSITOR_PRIORITY; |
| 363 base::TimeDelta time_left_in_policy = TimeLeftInInputEscalatedPolicy(); |
| 364 if (time_left_in_policy > base::TimeDelta()) { |
| 365 new_policy = input_priority_policy; |
| 366 *new_policy_duration = time_left_in_policy; |
| 367 } else { |
| 368 // Reset |input_stream_state_| to ensure |
| 369 // DidReceiveInputEventOnCompositorThread will post an UpdatePolicy task |
| 370 // when it's next called. |
| 371 input_stream_state_ = InputStreamState::INACTIVE; |
| 372 } |
| 373 return new_policy; |
| 374 } |
346 | 375 |
347 // If the input event is still pending, go into input prioritized policy | 376 base::TimeDelta RendererSchedulerImpl::TimeLeftInInputEscalatedPolicy() const { |
348 // and check again later. | 377 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 378 // TODO(rmcilroy): Change this to DCHECK_EQ when crbug.com/463869 is fixed. |
| 379 DCHECK(input_stream_state_ != InputStreamState::INACTIVE); |
| 380 incoming_signals_lock_.AssertAcquired(); |
| 381 |
| 382 base::TimeDelta escalated_priority_duration = |
| 383 base::TimeDelta::FromMilliseconds(kPriorityEscalationAfterInputMillis); |
| 384 base::TimeDelta time_left_in_policy; |
349 if (last_input_process_time_on_main_.is_null() && | 385 if (last_input_process_time_on_main_.is_null() && |
350 !task_queue_manager_->IsQueueEmpty(COMPOSITOR_TASK_QUEUE)) { | 386 !task_queue_manager_->IsQueueEmpty(COMPOSITOR_TASK_QUEUE)) { |
351 new_policy = input_priority_policy; | 387 // If the input event is still pending, go into input prioritized policy |
352 *new_policy_duration = new_priority_duration; | 388 // and check again later. |
| 389 time_left_in_policy = escalated_priority_duration; |
353 } else { | 390 } else { |
354 // Otherwise make sure the input prioritization policy ends on time. | 391 // Otherwise make sure the input prioritization policy ends on time. |
355 base::TimeTicks new_priority_end( | 392 base::TimeTicks new_priority_end( |
356 std::max(last_input_receipt_time_on_compositor_, | 393 std::max(last_input_receipt_time_on_compositor_, |
357 last_input_process_time_on_main_) + | 394 last_input_process_time_on_main_) + |
358 new_priority_duration); | 395 escalated_priority_duration); |
359 base::TimeDelta time_left_in_policy = new_priority_end - Now(); | 396 time_left_in_policy = new_priority_end - Now(); |
| 397 } |
| 398 return time_left_in_policy; |
| 399 } |
360 | 400 |
361 if (time_left_in_policy > base::TimeDelta()) { | 401 bool RendererSchedulerImpl::ShouldStartLongIdlePeriod( |
362 new_policy = input_priority_policy; | 402 const base::TimeTicks now, |
363 *new_policy_duration = time_left_in_policy; | 403 base::TimeDelta* next_long_idle_period_delay_out) { |
364 } else { | 404 DCHECK(main_thread_checker_.CalledOnValidThread()); |
365 // Reset |input_stream_state_| to ensure | 405 |
366 // DidReceiveInputEventOnCompositorThread will post an UpdatePolicy task | 406 MaybeUpdatePolicy(); |
367 // when it's next called. | 407 if (SchedulerPolicy() == Policy::TOUCHSTART_PRIORITY) { |
368 input_stream_state_ = InputStreamState::INACTIVE; | 408 // Don't start a long idle task in touch start priority, try again when |
369 } | 409 // the policy is scheduled to end. |
| 410 *next_long_idle_period_delay_out = current_policy_expiration_time_ - now; |
| 411 return false; |
370 } | 412 } |
371 return new_policy; | 413 |
| 414 base::TimeTicks next_pending_delayed_task = |
| 415 task_queue_manager_->NextPendingDelayedTaskRunTime(); |
| 416 |
| 417 base::TimeDelta long_idle_period_duration = |
| 418 base::TimeDelta::FromMilliseconds(kMaximumIdlePeriodMillis); |
| 419 if (!next_pending_delayed_task.is_null()) { |
| 420 // Limit the idle period duration to be before the next pending task. |
| 421 long_idle_period_duration = std::min( |
| 422 next_pending_delayed_task - now, long_idle_period_duration); |
| 423 } |
| 424 |
| 425 if (long_idle_period_duration > base::TimeDelta()) { |
| 426 *next_long_idle_period_delay_out = long_idle_period_duration; |
| 427 return true; |
| 428 } else { |
| 429 // If we can't start the idle period yet then try again after wakeup. |
| 430 *next_long_idle_period_delay_out = base::TimeDelta::FromMilliseconds( |
| 431 kRetryInitiateLongIdlePeriodDelayMillis); |
| 432 return false; |
| 433 } |
| 434 } |
| 435 |
| 436 void RendererSchedulerImpl::InitiateLongIdlePeriod() { |
| 437 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 438 "InitiateLongIdlePeriod"); |
| 439 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 440 |
| 441 // End any previous idle period. |
| 442 EndIdlePeriod(); |
| 443 |
| 444 base::TimeTicks now(Now()); |
| 445 base::TimeDelta next_long_idle_period_delay; |
| 446 if (ShouldStartLongIdlePeriod(now, &next_long_idle_period_delay)) { |
| 447 estimated_next_frame_begin_ = now + next_long_idle_period_delay; |
| 448 StartIdlePeriod(); |
| 449 } |
| 450 |
| 451 if (task_queue_manager_->IsQueueEmpty(IDLE_TASK_QUEUE)) { |
| 452 // If there are no current idle tasks then post the call to initiate the |
| 453 // next idle for execution after wakeup (at which point after-wakeup idle |
| 454 // tasks might be eligible to run or more idle tasks posted). |
| 455 control_task_after_wakeup_runner_->PostDelayedTask( |
| 456 FROM_HERE, |
| 457 initiate_next_long_idle_period_after_wakeup_closure_.callback(), |
| 458 next_long_idle_period_delay); |
| 459 } else { |
| 460 // Otherwise post on the normal control task queue. |
| 461 control_task_runner_->PostDelayedTask( |
| 462 FROM_HERE, |
| 463 initiate_next_long_idle_period_closure_.callback(), |
| 464 next_long_idle_period_delay); |
| 465 } |
| 466 } |
| 467 |
| 468 void RendererSchedulerImpl::InitiateLongIdlePeriodAfterWakeup() { |
| 469 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 470 "AfterWakeupInitiateLongIdlePeriod"); |
| 471 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 472 |
| 473 if (in_idle_period_) { |
| 474 // Since we were asleep until now, end the async idle period trace event at |
| 475 // the time when it would have ended were we awake. |
| 476 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0( |
| 477 "renderer.scheduler", "RendererSchedulerIdlePeriod", this, |
| 478 std::min(estimated_next_frame_begin_, Now()).ToInternalValue()); |
| 479 EndIdlePeriod(true); |
| 480 } |
| 481 |
| 482 // Post a task to initiate the next long idle period rather than calling it |
| 483 // directly to allow all pending PostIdleTaskAfterWakeup tasks to get enqueued |
| 484 // on the idle task queue before the next idle period starts so they are |
| 485 // eligible to be run during the new idle period. |
| 486 control_task_runner_->PostTask( |
| 487 FROM_HERE, |
| 488 initiate_next_long_idle_period_closure_.callback()); |
372 } | 489 } |
373 | 490 |
374 void RendererSchedulerImpl::StartIdlePeriod() { | 491 void RendererSchedulerImpl::StartIdlePeriod() { |
375 TRACE_EVENT_ASYNC_BEGIN0("renderer.scheduler", | 492 TRACE_EVENT_ASYNC_BEGIN0("renderer.scheduler", |
376 "RendererSchedulerIdlePeriod", this); | 493 "RendererSchedulerIdlePeriod", this); |
377 DCHECK(main_thread_checker_.CalledOnValidThread()); | 494 DCHECK(main_thread_checker_.CalledOnValidThread()); |
378 renderer_task_queue_selector_->EnableQueue( | 495 renderer_task_queue_selector_->EnableQueue( |
379 IDLE_TASK_QUEUE, RendererTaskQueueSelector::BEST_EFFORT_PRIORITY); | 496 IDLE_TASK_QUEUE, RendererTaskQueueSelector::BEST_EFFORT_PRIORITY); |
380 task_queue_manager_->PumpQueue(IDLE_TASK_QUEUE); | 497 task_queue_manager_->PumpQueue(IDLE_TASK_QUEUE); |
| 498 in_idle_period_ = true; |
381 } | 499 } |
382 | 500 |
383 void RendererSchedulerImpl::EndIdlePeriod() { | 501 void RendererSchedulerImpl::EndIdlePeriod(bool inhibit_trace_events) { |
384 bool is_tracing; | 502 DCHECK(main_thread_checker_.CalledOnValidThread()); |
385 TRACE_EVENT_CATEGORY_GROUP_ENABLED("renderer.scheduler", &is_tracing); | 503 |
386 if (is_tracing && !estimated_next_frame_begin_.is_null() && | 504 end_idle_period_closure_.Cancel(); |
387 base::TimeTicks::Now() > estimated_next_frame_begin_) { | 505 initiate_next_long_idle_period_closure_.Cancel(); |
388 TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0( | 506 initiate_next_long_idle_period_after_wakeup_closure_.Cancel(); |
389 "renderer.scheduler", | 507 |
390 "RendererSchedulerIdlePeriod", | 508 if (!in_idle_period_) |
391 this, | 509 return; |
392 "DeadlineOverrun", | 510 |
393 estimated_next_frame_begin_.ToInternalValue()); | 511 renderer_task_queue_selector_->DisableQueue(IDLE_TASK_QUEUE); |
| 512 in_idle_period_ = false; |
| 513 |
| 514 if (!inhibit_trace_events) { |
| 515 bool is_tracing; |
| 516 TRACE_EVENT_CATEGORY_GROUP_ENABLED("renderer.scheduler", &is_tracing); |
| 517 if (is_tracing && !estimated_next_frame_begin_.is_null() && |
| 518 base::TimeTicks::Now() > estimated_next_frame_begin_) { |
| 519 TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0( |
| 520 "renderer.scheduler", |
| 521 "RendererSchedulerIdlePeriod", |
| 522 this, |
| 523 "DeadlineOverrun", |
| 524 estimated_next_frame_begin_.ToInternalValue()); |
| 525 } |
| 526 TRACE_EVENT_ASYNC_END0("renderer.scheduler", |
| 527 "RendererSchedulerIdlePeriod", this); |
394 } | 528 } |
395 TRACE_EVENT_ASYNC_END0("renderer.scheduler", | |
396 "RendererSchedulerIdlePeriod", this); | |
397 DCHECK(main_thread_checker_.CalledOnValidThread()); | |
398 end_idle_period_closure_.Cancel(); | |
399 renderer_task_queue_selector_->DisableQueue(IDLE_TASK_QUEUE); | |
400 } | 529 } |
401 | 530 |
402 void RendererSchedulerImpl::SetTimeSourceForTesting( | 531 void RendererSchedulerImpl::SetTimeSourceForTesting( |
403 scoped_refptr<cc::TestNowSource> time_source) { | 532 scoped_refptr<cc::TestNowSource> time_source) { |
404 DCHECK(main_thread_checker_.CalledOnValidThread()); | 533 DCHECK(main_thread_checker_.CalledOnValidThread()); |
405 time_source_ = time_source; | 534 time_source_ = time_source; |
406 task_queue_manager_->SetTimeSourceForTesting(time_source); | 535 task_queue_manager_->SetTimeSourceForTesting(time_source); |
407 } | 536 } |
408 | 537 |
409 void RendererSchedulerImpl::SetWorkBatchSizeForTesting(size_t work_batch_size) { | 538 void RendererSchedulerImpl::SetWorkBatchSizeForTesting(size_t work_batch_size) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 RendererSchedulerImpl::AsValueLocked(base::TimeTicks optional_now) const { | 617 RendererSchedulerImpl::AsValueLocked(base::TimeTicks optional_now) const { |
489 DCHECK(main_thread_checker_.CalledOnValidThread()); | 618 DCHECK(main_thread_checker_.CalledOnValidThread()); |
490 incoming_signals_lock_.AssertAcquired(); | 619 incoming_signals_lock_.AssertAcquired(); |
491 | 620 |
492 if (optional_now.is_null()) | 621 if (optional_now.is_null()) |
493 optional_now = Now(); | 622 optional_now = Now(); |
494 scoped_refptr<base::trace_event::TracedValue> state = | 623 scoped_refptr<base::trace_event::TracedValue> state = |
495 new base::trace_event::TracedValue(); | 624 new base::trace_event::TracedValue(); |
496 | 625 |
497 state->SetString("current_policy", PolicyToString(current_policy_)); | 626 state->SetString("current_policy", PolicyToString(current_policy_)); |
| 627 state->SetBoolean("in_idle_period", in_idle_period_); |
498 state->SetString("input_stream_state", | 628 state->SetString("input_stream_state", |
499 InputStreamStateToString(input_stream_state_)); | 629 InputStreamStateToString(input_stream_state_)); |
500 state->SetDouble("now", (optional_now - base::TimeTicks()).InMillisecondsF()); | 630 state->SetDouble("now", (optional_now - base::TimeTicks()).InMillisecondsF()); |
501 state->SetDouble("last_input_receipt_time_on_compositor_", | 631 state->SetDouble("last_input_receipt_time_on_compositor_", |
502 (last_input_receipt_time_on_compositor_ - base::TimeTicks()) | 632 (last_input_receipt_time_on_compositor_ - base::TimeTicks()) |
503 .InMillisecondsF()); | 633 .InMillisecondsF()); |
504 state->SetDouble( | 634 state->SetDouble( |
505 "last_input_process_time_on_main_", | 635 "last_input_process_time_on_main_", |
506 (last_input_process_time_on_main_ - base::TimeTicks()).InMillisecondsF()); | 636 (last_input_process_time_on_main_ - base::TimeTicks()).InMillisecondsF()); |
507 state->SetDouble( | 637 state->SetDouble( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 } | 685 } |
556 | 686 |
557 void RendererSchedulerImpl::RemoveTaskObserver( | 687 void RendererSchedulerImpl::RemoveTaskObserver( |
558 base::MessageLoop::TaskObserver* task_observer) { | 688 base::MessageLoop::TaskObserver* task_observer) { |
559 DCHECK(main_thread_checker_.CalledOnValidThread()); | 689 DCHECK(main_thread_checker_.CalledOnValidThread()); |
560 if (task_queue_manager_) | 690 if (task_queue_manager_) |
561 task_queue_manager_->RemoveTaskObserver(task_observer); | 691 task_queue_manager_->RemoveTaskObserver(task_observer); |
562 } | 692 } |
563 | 693 |
564 } // namespace content | 694 } // namespace content |
OLD | NEW |