| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "platform/scheduler/child/idle_helper.h" | 5 #include "platform/scheduler/child/idle_helper.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "base/trace_event/trace_event_argument.h" | 9 #include "base/trace_event/trace_event_argument.h" |
| 10 #include "platform/scheduler/base/real_time_domain.h" | 10 #include "platform/scheduler/base/real_time_domain.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 167 } |
| 168 | 168 |
| 169 void IdleHelper::StartIdlePeriod(IdlePeriodState new_state, | 169 void IdleHelper::StartIdlePeriod(IdlePeriodState new_state, |
| 170 base::TimeTicks now, | 170 base::TimeTicks now, |
| 171 base::TimeTicks idle_period_deadline) { | 171 base::TimeTicks idle_period_deadline) { |
| 172 DCHECK(!is_shutdown_); | 172 DCHECK(!is_shutdown_); |
| 173 DCHECK_GT(idle_period_deadline, now); | 173 DCHECK_GT(idle_period_deadline, now); |
| 174 helper_->CheckOnValidThread(); | 174 helper_->CheckOnValidThread(); |
| 175 DCHECK(IsInIdlePeriod(new_state)); | 175 DCHECK(IsInIdlePeriod(new_state)); |
| 176 | 176 |
| 177 // Allow any ready delayed idle tasks to run. |
| 178 idle_task_runner_->EnqueueReadyDelayedIdleTasks(); |
| 179 |
| 177 base::TimeDelta idle_period_duration(idle_period_deadline - now); | 180 base::TimeDelta idle_period_duration(idle_period_deadline - now); |
| 178 if (idle_period_duration < | 181 if (idle_period_duration < |
| 179 base::TimeDelta::FromMilliseconds(kMinimumIdlePeriodDurationMillis)) { | 182 base::TimeDelta::FromMilliseconds(kMinimumIdlePeriodDurationMillis)) { |
| 180 TRACE_EVENT1(disabled_by_default_tracing_category_, | 183 TRACE_EVENT1(disabled_by_default_tracing_category_, |
| 181 "NotStartingIdlePeriodBecauseDeadlineIsTooClose", | 184 "NotStartingIdlePeriodBecauseDeadlineIsTooClose", |
| 182 "idle_period_duration_ms", | 185 "idle_period_duration_ms", |
| 183 idle_period_duration.InMillisecondsF()); | 186 idle_period_duration.InMillisecondsF()); |
| 184 return; | 187 return; |
| 185 } | 188 } |
| 186 | 189 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 void IdleHelper::DidProcessIdleTask() { | 317 void IdleHelper::DidProcessIdleTask() { |
| 315 helper_->CheckOnValidThread(); | 318 helper_->CheckOnValidThread(); |
| 316 if (is_shutdown_) | 319 if (is_shutdown_) |
| 317 return; | 320 return; |
| 318 state_.TraceIdleIdleTaskEnd(); | 321 state_.TraceIdleIdleTaskEnd(); |
| 319 if (IsInLongIdlePeriod(state_.idle_period_state())) { | 322 if (IsInLongIdlePeriod(state_.idle_period_state())) { |
| 320 UpdateLongIdlePeriodStateAfterIdleTask(); | 323 UpdateLongIdlePeriodStateAfterIdleTask(); |
| 321 } | 324 } |
| 322 } | 325 } |
| 323 | 326 |
| 327 base::TimeTicks IdleHelper::NowTicks() { |
| 328 return helper_->scheduler_tqm_delegate()->NowTicks(); |
| 329 } |
| 330 |
| 324 // static | 331 // static |
| 325 bool IdleHelper::IsInIdlePeriod(IdlePeriodState state) { | 332 bool IdleHelper::IsInIdlePeriod(IdlePeriodState state) { |
| 326 return state != IdlePeriodState::NOT_IN_IDLE_PERIOD; | 333 return state != IdlePeriodState::NOT_IN_IDLE_PERIOD; |
| 327 } | 334 } |
| 328 | 335 |
| 329 // static | 336 // static |
| 330 bool IdleHelper::IsInLongIdlePeriod(IdlePeriodState state) { | 337 bool IdleHelper::IsInLongIdlePeriod(IdlePeriodState state) { |
| 331 return state == IdlePeriodState::IN_LONG_IDLE_PERIOD || | 338 return state == IdlePeriodState::IN_LONG_IDLE_PERIOD || |
| 332 state == IdlePeriodState::IN_LONG_IDLE_PERIOD_WITH_MAX_DEADLINE || | 339 state == IdlePeriodState::IN_LONG_IDLE_PERIOD_WITH_MAX_DEADLINE || |
| 333 state == IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED; | 340 state == IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED: | 501 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED: |
| 495 return "in_long_idle_period_paused"; | 502 return "in_long_idle_period_paused"; |
| 496 default: | 503 default: |
| 497 NOTREACHED(); | 504 NOTREACHED(); |
| 498 return nullptr; | 505 return nullptr; |
| 499 } | 506 } |
| 500 } | 507 } |
| 501 | 508 |
| 502 } // namespace scheduler | 509 } // namespace scheduler |
| 503 } // namespace blink | 510 } // namespace blink |
| OLD | NEW |