Chromium Code Reviews| 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 idle_period_state_(IdlePeriodState::NOT_WITHIN_IDLE_PERIOD), |
| 36 last_input_type_(blink::WebInputEvent::Undefined), | 36 last_input_type_(blink::WebInputEvent::Undefined), |
| 37 input_stream_state_(InputStreamState::INACTIVE), | 37 input_stream_state_(InputStreamState::INACTIVE), |
| 38 policy_may_need_update_(&incoming_signals_lock_), | 38 policy_may_need_update_(&incoming_signals_lock_), |
| 39 weak_factory_(this) { | 39 weak_factory_(this) { |
| 40 weak_renderer_scheduler_ptr_ = weak_factory_.GetWeakPtr(); | 40 weak_renderer_scheduler_ptr_ = weak_factory_.GetWeakPtr(); |
| 41 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy, | 41 update_policy_closure_ = base::Bind(&RendererSchedulerImpl::UpdatePolicy, |
| 42 weak_renderer_scheduler_ptr_); | 42 weak_renderer_scheduler_ptr_); |
| 43 end_idle_period_closure_.Reset(base::Bind( | 43 end_idle_period_closure_.Reset(base::Bind( |
| 44 &RendererSchedulerImpl::EndIdlePeriod, weak_renderer_scheduler_ptr_)); | 44 &RendererSchedulerImpl::EndIdlePeriod, weak_renderer_scheduler_ptr_)); |
| 45 initiate_next_long_idle_period_closure_.Reset(base::Bind( | 45 initiate_next_long_idle_period_closure_.Reset(base::Bind( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 134 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 135 "RendererSchedulerImpl::DidCommitFrameToCompositor"); | 135 "RendererSchedulerImpl::DidCommitFrameToCompositor"); |
| 136 DCHECK(main_thread_checker_.CalledOnValidThread()); | 136 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 137 if (!task_queue_manager_) | 137 if (!task_queue_manager_) |
| 138 return; | 138 return; |
| 139 | 139 |
| 140 base::TimeTicks now(Now()); | 140 base::TimeTicks now(Now()); |
| 141 if (now < estimated_next_frame_begin_) { | 141 if (now < estimated_next_frame_begin_) { |
| 142 // TODO(rmcilroy): Consider reducing the idle period based on the runtime of | 142 // TODO(rmcilroy): Consider reducing the idle period based on the runtime of |
| 143 // the next pending delayed tasks (as currently done in for long idle times) | 143 // the next pending delayed tasks (as currently done in for long idle times) |
| 144 StartIdlePeriod(); | 144 StartIdlePeriod(IdlePeriodState::WITHIN_IDLE_PERIOD); |
| 145 control_task_runner_->PostDelayedTask(FROM_HERE, | 145 control_task_runner_->PostDelayedTask(FROM_HERE, |
| 146 end_idle_period_closure_.callback(), | 146 end_idle_period_closure_.callback(), |
| 147 estimated_next_frame_begin_ - now); | 147 estimated_next_frame_begin_ - now); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 void RendererSchedulerImpl::BeginFrameNotExpectedSoon() { | 151 void RendererSchedulerImpl::BeginFrameNotExpectedSoon() { |
| 152 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 152 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 153 "RendererSchedulerImpl::BeginFrameNotExpectedSoon"); | 153 "RendererSchedulerImpl::BeginFrameNotExpectedSoon"); |
| 154 DCHECK(main_thread_checker_.CalledOnValidThread()); | 154 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 // Otherwise make sure the input prioritization policy ends on time. | 390 // Otherwise make sure the input prioritization policy ends on time. |
| 391 base::TimeTicks new_priority_end( | 391 base::TimeTicks new_priority_end( |
| 392 std::max(last_input_receipt_time_on_compositor_, | 392 std::max(last_input_receipt_time_on_compositor_, |
| 393 last_input_process_time_on_main_) + | 393 last_input_process_time_on_main_) + |
| 394 escalated_priority_duration); | 394 escalated_priority_duration); |
| 395 time_left_in_policy = new_priority_end - Now(); | 395 time_left_in_policy = new_priority_end - Now(); |
| 396 } | 396 } |
| 397 return time_left_in_policy; | 397 return time_left_in_policy; |
| 398 } | 398 } |
| 399 | 399 |
| 400 bool RendererSchedulerImpl::ShouldStartLongIdlePeriod( | 400 RendererSchedulerImpl::IdlePeriodState |
| 401 RendererSchedulerImpl::ComputeNewLongIdlePeriodState( | |
| 401 const base::TimeTicks now, | 402 const base::TimeTicks now, |
| 402 base::TimeDelta* next_long_idle_period_delay_out) { | 403 base::TimeDelta* next_long_idle_period_delay_out) { |
| 403 DCHECK(main_thread_checker_.CalledOnValidThread()); | 404 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 404 | 405 |
| 405 MaybeUpdatePolicy(); | 406 MaybeUpdatePolicy(); |
| 406 if (SchedulerPolicy() == Policy::TOUCHSTART_PRIORITY) { | 407 if (SchedulerPolicy() == Policy::TOUCHSTART_PRIORITY) { |
| 407 // Don't start a long idle task in touch start priority, try again when | 408 // Don't start a long idle task in touch start priority, try again when |
| 408 // the policy is scheduled to end. | 409 // the policy is scheduled to end. |
| 409 *next_long_idle_period_delay_out = current_policy_expiration_time_ - now; | 410 *next_long_idle_period_delay_out = current_policy_expiration_time_ - now; |
| 410 return false; | 411 return IdlePeriodState::NOT_WITHIN_IDLE_PERIOD; |
| 411 } | 412 } |
| 412 | 413 |
| 413 base::TimeTicks next_pending_delayed_task = | 414 base::TimeTicks next_pending_delayed_task = |
| 414 task_queue_manager_->NextPendingDelayedTaskRunTime(); | 415 task_queue_manager_->NextPendingDelayedTaskRunTime(); |
| 415 | 416 base::TimeDelta max_long_idle_period_duration = |
| 416 base::TimeDelta long_idle_period_duration = | |
| 417 base::TimeDelta::FromMilliseconds(kMaximumIdlePeriodMillis); | 417 base::TimeDelta::FromMilliseconds(kMaximumIdlePeriodMillis); |
| 418 base::TimeDelta long_idle_period_duration; | |
| 418 if (!next_pending_delayed_task.is_null()) { | 419 if (!next_pending_delayed_task.is_null()) { |
|
picksi
2015/03/05 12:22:08
It's time for my regular "remove ! and swap if/els
rmcilroy
2015/03/05 13:25:24
Done.
| |
| 419 // Limit the idle period duration to be before the next pending task. | 420 // Limit the idle period duration to be before the next pending task. |
| 420 long_idle_period_duration = std::min( | 421 long_idle_period_duration = std::min( |
| 421 next_pending_delayed_task - now, long_idle_period_duration); | 422 next_pending_delayed_task - now, max_long_idle_period_duration); |
| 423 } else { | |
| 424 long_idle_period_duration = max_long_idle_period_duration; | |
| 422 } | 425 } |
| 423 | 426 |
| 424 if (long_idle_period_duration > base::TimeDelta()) { | 427 if (long_idle_period_duration > base::TimeDelta()) { |
| 425 *next_long_idle_period_delay_out = long_idle_period_duration; | 428 *next_long_idle_period_delay_out = long_idle_period_duration; |
| 426 return true; | 429 return long_idle_period_duration == max_long_idle_period_duration ? |
|
picksi
2015/03/05 12:22:08
It seems slightly non-intuitive to say we're "with
rmcilroy
2015/03/05 13:25:24
I renamed the states (e.g., IN_LONG_IDLE_WITH_MAX_
| |
| 430 IdlePeriodState::WITHIN_MAX_DEADLINE_IDLE_PERIOD: | |
| 431 IdlePeriodState::WITHIN_IDLE_PERIOD; | |
| 427 } else { | 432 } else { |
| 428 // If we can't start the idle period yet then try again after wakeup. | 433 // If we can't start the idle period yet then try again after wakeup. |
| 429 *next_long_idle_period_delay_out = base::TimeDelta::FromMilliseconds( | 434 *next_long_idle_period_delay_out = base::TimeDelta::FromMilliseconds( |
| 430 kRetryInitiateLongIdlePeriodDelayMillis); | 435 kRetryInitiateLongIdlePeriodDelayMillis); |
| 431 return false; | 436 return IdlePeriodState::NOT_WITHIN_IDLE_PERIOD; |
| 432 } | 437 } |
| 433 } | 438 } |
| 434 | 439 |
| 435 void RendererSchedulerImpl::InitiateLongIdlePeriod() { | 440 void RendererSchedulerImpl::InitiateLongIdlePeriod() { |
| 436 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 441 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 437 "InitiateLongIdlePeriod"); | 442 "InitiateLongIdlePeriod"); |
| 438 DCHECK(main_thread_checker_.CalledOnValidThread()); | 443 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 439 | 444 |
| 440 // End any previous idle period. | 445 // End any previous idle period. |
| 441 EndIdlePeriod(); | 446 EndIdlePeriod(); |
| 442 | 447 |
| 443 base::TimeTicks now(Now()); | 448 base::TimeTicks now(Now()); |
| 444 base::TimeDelta next_long_idle_period_delay; | 449 base::TimeDelta next_long_idle_period_delay; |
| 445 if (ShouldStartLongIdlePeriod(now, &next_long_idle_period_delay)) { | 450 IdlePeriodState new_idle_period_state = ComputeNewLongIdlePeriodState( |
| 451 now, &next_long_idle_period_delay); | |
| 452 if (new_idle_period_state != IdlePeriodState::NOT_WITHIN_IDLE_PERIOD) { | |
|
picksi
2015/03/05 12:22:08
(More "!" comments)... I find this double negative
rmcilroy
2015/03/05 13:25:24
Done.
| |
| 446 estimated_next_frame_begin_ = now + next_long_idle_period_delay; | 453 estimated_next_frame_begin_ = now + next_long_idle_period_delay; |
| 447 StartIdlePeriod(); | 454 StartIdlePeriod(new_idle_period_state); |
| 448 } | 455 } |
| 449 | 456 |
| 450 if (task_queue_manager_->IsQueueEmpty(IDLE_TASK_QUEUE)) { | 457 if (task_queue_manager_->IsQueueEmpty(IDLE_TASK_QUEUE)) { |
| 451 // If there are no current idle tasks then post the call to initiate the | 458 // If there are no current idle tasks then post the call to initiate the |
| 452 // next idle for execution after wakeup (at which point after-wakeup idle | 459 // next idle for execution after wakeup (at which point after-wakeup idle |
| 453 // tasks might be eligible to run or more idle tasks posted). | 460 // tasks might be eligible to run or more idle tasks posted). |
| 454 control_task_after_wakeup_runner_->PostDelayedTask( | 461 control_task_after_wakeup_runner_->PostDelayedTask( |
| 455 FROM_HERE, | 462 FROM_HERE, |
| 456 initiate_next_long_idle_period_after_wakeup_closure_.callback(), | 463 initiate_next_long_idle_period_after_wakeup_closure_.callback(), |
| 457 next_long_idle_period_delay); | 464 next_long_idle_period_delay); |
| 458 } else { | 465 } else { |
| 459 // Otherwise post on the normal control task queue. | 466 // Otherwise post on the normal control task queue. |
| 460 control_task_runner_->PostDelayedTask( | 467 control_task_runner_->PostDelayedTask( |
| 461 FROM_HERE, | 468 FROM_HERE, |
| 462 initiate_next_long_idle_period_closure_.callback(), | 469 initiate_next_long_idle_period_closure_.callback(), |
| 463 next_long_idle_period_delay); | 470 next_long_idle_period_delay); |
| 464 } | 471 } |
| 465 } | 472 } |
| 466 | 473 |
| 467 void RendererSchedulerImpl::InitiateLongIdlePeriodAfterWakeup() { | 474 void RendererSchedulerImpl::InitiateLongIdlePeriodAfterWakeup() { |
| 468 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 475 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 469 "AfterWakeupInitiateLongIdlePeriod"); | 476 "AfterWakeupInitiateLongIdlePeriod"); |
| 470 DCHECK(main_thread_checker_.CalledOnValidThread()); | 477 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 471 | 478 |
| 472 if (in_idle_period_) { | 479 if (idle_period_state_ != IdlePeriodState::NOT_WITHIN_IDLE_PERIOD) { |
| 473 // Since we were asleep until now, end the async idle period trace event at | 480 // Since we were asleep until now, end the async idle period trace event at |
| 474 // the time when it would have ended were we awake. | 481 // the time when it would have ended were we awake. |
| 475 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0( | 482 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0( |
| 476 "renderer.scheduler", "RendererSchedulerIdlePeriod", this, | 483 "renderer.scheduler", "RendererSchedulerIdlePeriod", this, |
| 477 std::min(estimated_next_frame_begin_, Now()).ToInternalValue()); | 484 std::min(estimated_next_frame_begin_, Now()).ToInternalValue()); |
| 478 } | 485 } |
| 479 | 486 |
| 480 // Post a task to initiate the next long idle period rather than calling it | 487 // Post a task to initiate the next long idle period rather than calling it |
| 481 // directly to allow all pending PostIdleTaskAfterWakeup tasks to get enqueued | 488 // directly to allow all pending PostIdleTaskAfterWakeup tasks to get enqueued |
| 482 // on the idle task queue before the next idle period starts so they are | 489 // on the idle task queue before the next idle period starts so they are |
| 483 // eligible to be run during the new idle period. | 490 // eligible to be run during the new idle period. |
| 484 control_task_runner_->PostTask( | 491 control_task_runner_->PostTask( |
| 485 FROM_HERE, | 492 FROM_HERE, |
| 486 initiate_next_long_idle_period_closure_.callback()); | 493 initiate_next_long_idle_period_closure_.callback()); |
| 487 } | 494 } |
| 488 | 495 |
| 489 void RendererSchedulerImpl::StartIdlePeriod() { | 496 void RendererSchedulerImpl::StartIdlePeriod(IdlePeriodState new_state) { |
| 490 TRACE_EVENT_ASYNC_BEGIN0("renderer.scheduler", | 497 TRACE_EVENT_ASYNC_BEGIN0("renderer.scheduler", |
| 491 "RendererSchedulerIdlePeriod", this); | 498 "RendererSchedulerIdlePeriod", this); |
| 492 DCHECK(main_thread_checker_.CalledOnValidThread()); | 499 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 500 // TODO(rmcilroy): Change this to DCHECK_EQ when crbug.com/463869 is fixed. | |
| 501 DCHECK(new_state != IdlePeriodState::NOT_WITHIN_IDLE_PERIOD); | |
| 502 idle_period_state_ = new_state; | |
| 493 renderer_task_queue_selector_->EnableQueue( | 503 renderer_task_queue_selector_->EnableQueue( |
| 494 IDLE_TASK_QUEUE, RendererTaskQueueSelector::BEST_EFFORT_PRIORITY); | 504 IDLE_TASK_QUEUE, RendererTaskQueueSelector::BEST_EFFORT_PRIORITY); |
| 495 task_queue_manager_->PumpQueue(IDLE_TASK_QUEUE); | 505 task_queue_manager_->PumpQueue(IDLE_TASK_QUEUE); |
| 496 in_idle_period_ = true; | |
| 497 } | 506 } |
| 498 | 507 |
| 499 void RendererSchedulerImpl::EndIdlePeriod() { | 508 void RendererSchedulerImpl::EndIdlePeriod() { |
| 500 DCHECK(main_thread_checker_.CalledOnValidThread()); | 509 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 501 | 510 |
| 502 end_idle_period_closure_.Cancel(); | 511 end_idle_period_closure_.Cancel(); |
| 503 initiate_next_long_idle_period_closure_.Cancel(); | 512 initiate_next_long_idle_period_closure_.Cancel(); |
| 504 initiate_next_long_idle_period_after_wakeup_closure_.Cancel(); | 513 initiate_next_long_idle_period_after_wakeup_closure_.Cancel(); |
| 505 | 514 |
| 506 if (!in_idle_period_) | 515 if (idle_period_state_ == IdlePeriodState::NOT_WITHIN_IDLE_PERIOD) |
|
picksi
2015/03/05 12:22:08
Is this a silent failure? Should this be a DCHECK
rmcilroy
2015/03/05 13:25:24
No, it's allowable to call EndIdlePeriod even if y
| |
| 507 return; | 516 return; |
| 508 | 517 |
| 518 idle_period_state_ = IdlePeriodState::NOT_WITHIN_IDLE_PERIOD; | |
| 509 renderer_task_queue_selector_->DisableQueue(IDLE_TASK_QUEUE); | 519 renderer_task_queue_selector_->DisableQueue(IDLE_TASK_QUEUE); |
| 510 bool is_tracing; | 520 bool is_tracing; |
| 511 TRACE_EVENT_CATEGORY_GROUP_ENABLED("renderer.scheduler", &is_tracing); | 521 TRACE_EVENT_CATEGORY_GROUP_ENABLED("renderer.scheduler", &is_tracing); |
| 512 if (is_tracing && !estimated_next_frame_begin_.is_null() && | 522 if (is_tracing && !estimated_next_frame_begin_.is_null() && |
| 513 base::TimeTicks::Now() > estimated_next_frame_begin_) { | 523 base::TimeTicks::Now() > estimated_next_frame_begin_) { |
| 514 TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0( | 524 TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0( |
| 515 "renderer.scheduler", | 525 "renderer.scheduler", |
| 516 "RendererSchedulerIdlePeriod", | 526 "RendererSchedulerIdlePeriod", |
| 517 this, | 527 this, |
| 518 "DeadlineOverrun", | 528 "DeadlineOverrun", |
| 519 estimated_next_frame_begin_.ToInternalValue()); | 529 estimated_next_frame_begin_.ToInternalValue()); |
| 520 } | 530 } |
| 521 TRACE_EVENT_ASYNC_END0("renderer.scheduler", | 531 TRACE_EVENT_ASYNC_END0("renderer.scheduler", |
| 522 "RendererSchedulerIdlePeriod", this); | 532 "RendererSchedulerIdlePeriod", this); |
| 523 } | 533 } |
| 524 | 534 |
| 535 bool RendererSchedulerImpl::CanExceedIdleDeadlineIfRequired() const { | |
| 536 return idle_period_state_ == IdlePeriodState::WITHIN_MAX_DEADLINE_IDLE_PERIOD; | |
| 537 } | |
| 538 | |
| 525 void RendererSchedulerImpl::SetTimeSourceForTesting( | 539 void RendererSchedulerImpl::SetTimeSourceForTesting( |
| 526 scoped_refptr<cc::TestNowSource> time_source) { | 540 scoped_refptr<cc::TestNowSource> time_source) { |
| 527 DCHECK(main_thread_checker_.CalledOnValidThread()); | 541 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 528 time_source_ = time_source; | 542 time_source_ = time_source; |
| 529 task_queue_manager_->SetTimeSourceForTesting(time_source); | 543 task_queue_manager_->SetTimeSourceForTesting(time_source); |
| 530 } | 544 } |
| 531 | 545 |
| 532 void RendererSchedulerImpl::SetWorkBatchSizeForTesting(size_t work_batch_size) { | 546 void RendererSchedulerImpl::SetWorkBatchSizeForTesting(size_t work_batch_size) { |
| 533 DCHECK(main_thread_checker_.CalledOnValidThread()); | 547 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 534 task_queue_manager_->SetWorkBatchSize(work_batch_size); | 548 task_queue_manager_->SetWorkBatchSize(work_batch_size); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 case InputStreamState::ACTIVE: | 614 case InputStreamState::ACTIVE: |
| 601 return "active"; | 615 return "active"; |
| 602 case InputStreamState::ACTIVE_AND_AWAITING_TOUCHSTART_RESPONSE: | 616 case InputStreamState::ACTIVE_AND_AWAITING_TOUCHSTART_RESPONSE: |
| 603 return "active_and_awaiting_touchstart_response"; | 617 return "active_and_awaiting_touchstart_response"; |
| 604 default: | 618 default: |
| 605 NOTREACHED(); | 619 NOTREACHED(); |
| 606 return nullptr; | 620 return nullptr; |
| 607 } | 621 } |
| 608 } | 622 } |
| 609 | 623 |
| 624 const char* RendererSchedulerImpl::IdlePeriodStateToString( | |
| 625 IdlePeriodState state) { | |
|
picksi
2015/03/05 12:22:08
nit: rename state to idle_period_state
rmcilroy
2015/03/05 13:25:24
Done.
| |
| 626 switch (state) { | |
| 627 case IdlePeriodState::NOT_WITHIN_IDLE_PERIOD: | |
| 628 return "not_within_idle_period"; | |
| 629 case IdlePeriodState::WITHIN_IDLE_PERIOD: | |
| 630 return "within_idle_period"; | |
| 631 case IdlePeriodState::WITHIN_MAX_DEADLINE_IDLE_PERIOD: | |
| 632 return "within_max_deadline_idle_period"; | |
| 633 default: | |
| 634 NOTREACHED(); | |
| 635 return nullptr; | |
| 636 } | |
| 637 } | |
| 638 | |
| 610 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 639 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 611 RendererSchedulerImpl::AsValueLocked(base::TimeTicks optional_now) const { | 640 RendererSchedulerImpl::AsValueLocked(base::TimeTicks optional_now) const { |
| 612 DCHECK(main_thread_checker_.CalledOnValidThread()); | 641 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 613 incoming_signals_lock_.AssertAcquired(); | 642 incoming_signals_lock_.AssertAcquired(); |
| 614 | 643 |
| 615 if (optional_now.is_null()) | 644 if (optional_now.is_null()) |
| 616 optional_now = Now(); | 645 optional_now = Now(); |
| 617 scoped_refptr<base::trace_event::TracedValue> state = | 646 scoped_refptr<base::trace_event::TracedValue> state = |
| 618 new base::trace_event::TracedValue(); | 647 new base::trace_event::TracedValue(); |
| 619 | 648 |
| 620 state->SetString("current_policy", PolicyToString(current_policy_)); | 649 state->SetString("current_policy", PolicyToString(current_policy_)); |
| 621 state->SetBoolean("in_idle_period", in_idle_period_); | 650 state->SetString("idle_period_state", |
| 651 IdlePeriodStateToString(idle_period_state_)); | |
| 622 state->SetString("input_stream_state", | 652 state->SetString("input_stream_state", |
| 623 InputStreamStateToString(input_stream_state_)); | 653 InputStreamStateToString(input_stream_state_)); |
| 624 state->SetDouble("now", (optional_now - base::TimeTicks()).InMillisecondsF()); | 654 state->SetDouble("now", (optional_now - base::TimeTicks()).InMillisecondsF()); |
| 625 state->SetDouble("last_input_receipt_time_on_compositor_", | 655 state->SetDouble("last_input_receipt_time_on_compositor_", |
| 626 (last_input_receipt_time_on_compositor_ - base::TimeTicks()) | 656 (last_input_receipt_time_on_compositor_ - base::TimeTicks()) |
| 627 .InMillisecondsF()); | 657 .InMillisecondsF()); |
| 628 state->SetDouble( | 658 state->SetDouble( |
| 629 "last_input_process_time_on_main_", | 659 "last_input_process_time_on_main_", |
| 630 (last_input_process_time_on_main_ - base::TimeTicks()).InMillisecondsF()); | 660 (last_input_process_time_on_main_ - base::TimeTicks()).InMillisecondsF()); |
| 631 state->SetDouble( | 661 state->SetDouble( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 } | 709 } |
| 680 | 710 |
| 681 void RendererSchedulerImpl::RemoveTaskObserver( | 711 void RendererSchedulerImpl::RemoveTaskObserver( |
| 682 base::MessageLoop::TaskObserver* task_observer) { | 712 base::MessageLoop::TaskObserver* task_observer) { |
| 683 DCHECK(main_thread_checker_.CalledOnValidThread()); | 713 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 684 if (task_queue_manager_) | 714 if (task_queue_manager_) |
| 685 task_queue_manager_->RemoveTaskObserver(task_observer); | 715 task_queue_manager_->RemoveTaskObserver(task_observer); |
| 686 } | 716 } |
| 687 | 717 |
| 688 } // namespace content | 718 } // namespace content |
| OLD | NEW |