| 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 "components/scheduler/child/idle_helper.h" | 5 #include "components/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 "components/scheduler/base/real_time_domain.h" | 10 #include "components/scheduler/base/real_time_domain.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Limit the idle period duration to be before the next pending task. | 86 // Limit the idle period duration to be before the next pending task. |
| 87 long_idle_period_duration = std::min(next_pending_delayed_task - now, | 87 long_idle_period_duration = std::min(next_pending_delayed_task - now, |
| 88 max_long_idle_period_duration); | 88 max_long_idle_period_duration); |
| 89 } else { | 89 } else { |
| 90 long_idle_period_duration = max_long_idle_period_duration; | 90 long_idle_period_duration = max_long_idle_period_duration; |
| 91 } | 91 } |
| 92 | 92 |
| 93 if (long_idle_period_duration >= | 93 if (long_idle_period_duration >= |
| 94 base::TimeDelta::FromMilliseconds(kMinimumIdlePeriodDurationMillis)) { | 94 base::TimeDelta::FromMilliseconds(kMinimumIdlePeriodDurationMillis)) { |
| 95 *next_long_idle_period_delay_out = long_idle_period_duration; | 95 *next_long_idle_period_delay_out = long_idle_period_duration; |
| 96 if (idle_queue_->IsQueueEmpty()) { | 96 if (!idle_queue_->HasPendingImmediateTask()) { |
| 97 return IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED; | 97 return IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED; |
| 98 } else if (long_idle_period_duration == max_long_idle_period_duration) { | 98 } else if (long_idle_period_duration == max_long_idle_period_duration) { |
| 99 return IdlePeriodState::IN_LONG_IDLE_PERIOD_WITH_MAX_DEADLINE; | 99 return IdlePeriodState::IN_LONG_IDLE_PERIOD_WITH_MAX_DEADLINE; |
| 100 } else { | 100 } else { |
| 101 return IdlePeriodState::IN_LONG_IDLE_PERIOD; | 101 return IdlePeriodState::IN_LONG_IDLE_PERIOD; |
| 102 } | 102 } |
| 103 } else { | 103 } else { |
| 104 // If we can't start the idle period yet then try again after wakeup. | 104 // If we can't start the idle period yet then try again after wakeup. |
| 105 *next_long_idle_period_delay_out = base::TimeDelta::FromMilliseconds( | 105 *next_long_idle_period_delay_out = base::TimeDelta::FromMilliseconds( |
| 106 kRetryEnableLongIdlePeriodDelayMillis); | 106 kRetryEnableLongIdlePeriodDelayMillis); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 return "in_long_idle_period_with_max_deadline"; | 475 return "in_long_idle_period_with_max_deadline"; |
| 476 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED: | 476 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED: |
| 477 return "in_long_idle_period_paused"; | 477 return "in_long_idle_period_paused"; |
| 478 default: | 478 default: |
| 479 NOTREACHED(); | 479 NOTREACHED(); |
| 480 return nullptr; | 480 return nullptr; |
| 481 } | 481 } |
| 482 } | 482 } |
| 483 | 483 |
| 484 } // namespace scheduler | 484 } // namespace scheduler |
| OLD | NEW |