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