Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: components/scheduler/child/idle_helper.cc

Issue 1432263002: (reland) Adds TimeDomains to the TaskQueueManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix thread_hop_task DCHECK Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/task_queue.h" 11 #include "components/scheduler/base/task_queue.h"
11 #include "components/scheduler/base/task_queue_manager.h" 12 #include "components/scheduler/base/task_queue_manager.h"
12 #include "components/scheduler/child/scheduler_helper.h" 13 #include "components/scheduler/child/scheduler_helper.h"
13 #include "components/scheduler/child/scheduler_tqm_delegate.h" 14 #include "components/scheduler/child/scheduler_tqm_delegate.h"
14 15
15 namespace scheduler { 16 namespace scheduler {
16 17
17 IdleHelper::IdleHelper( 18 IdleHelper::IdleHelper(
18 SchedulerHelper* helper, 19 SchedulerHelper* helper,
19 Delegate* delegate, 20 Delegate* delegate,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 IdleHelper::IdlePeriodState IdleHelper::ComputeNewLongIdlePeriodState( 70 IdleHelper::IdlePeriodState IdleHelper::ComputeNewLongIdlePeriodState(
70 const base::TimeTicks now, 71 const base::TimeTicks now,
71 base::TimeDelta* next_long_idle_period_delay_out) { 72 base::TimeDelta* next_long_idle_period_delay_out) {
72 helper_->CheckOnValidThread(); 73 helper_->CheckOnValidThread();
73 74
74 if (!delegate_->CanEnterLongIdlePeriod(now, 75 if (!delegate_->CanEnterLongIdlePeriod(now,
75 next_long_idle_period_delay_out)) { 76 next_long_idle_period_delay_out)) {
76 return IdlePeriodState::NOT_IN_IDLE_PERIOD; 77 return IdlePeriodState::NOT_IN_IDLE_PERIOD;
77 } 78 }
78 79
79 base::TimeTicks next_pending_delayed_task = 80 base::TimeTicks next_pending_delayed_task;
80 helper_->NextPendingDelayedTaskRunTime();
81 base::TimeDelta max_long_idle_period_duration = 81 base::TimeDelta max_long_idle_period_duration =
82 base::TimeDelta::FromMilliseconds(kMaximumIdlePeriodMillis); 82 base::TimeDelta::FromMilliseconds(kMaximumIdlePeriodMillis);
83 base::TimeDelta long_idle_period_duration; 83 base::TimeDelta long_idle_period_duration;
84 if (next_pending_delayed_task.is_null()) { 84 if (helper_->real_time_domain()->NextScheduledRunTime(
85 long_idle_period_duration = max_long_idle_period_duration; 85 &next_pending_delayed_task)) {
86 } else {
87 // 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.
88 long_idle_period_duration = std::min(next_pending_delayed_task - now, 87 long_idle_period_duration = std::min(next_pending_delayed_task - now,
89 max_long_idle_period_duration); 88 max_long_idle_period_duration);
89 } else {
90 long_idle_period_duration = max_long_idle_period_duration;
90 } 91 }
91 92
92 if (long_idle_period_duration >= 93 if (long_idle_period_duration >=
93 base::TimeDelta::FromMilliseconds(kMinimumIdlePeriodDurationMillis)) { 94 base::TimeDelta::FromMilliseconds(kMinimumIdlePeriodDurationMillis)) {
94 *next_long_idle_period_delay_out = long_idle_period_duration; 95 *next_long_idle_period_delay_out = long_idle_period_duration;
95 if (idle_queue_->IsQueueEmpty()) { 96 if (idle_queue_->IsQueueEmpty()) {
96 return IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED; 97 return IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED;
97 } else if (long_idle_period_duration == max_long_idle_period_duration) { 98 } else if (long_idle_period_duration == max_long_idle_period_duration) {
98 return IdlePeriodState::IN_LONG_IDLE_PERIOD_WITH_MAX_DEADLINE; 99 return IdlePeriodState::IN_LONG_IDLE_PERIOD_WITH_MAX_DEADLINE;
99 } else { 100 } else {
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 return "in_long_idle_period_with_max_deadline"; 475 return "in_long_idle_period_with_max_deadline";
475 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED: 476 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED:
476 return "in_long_idle_period_paused"; 477 return "in_long_idle_period_paused";
477 default: 478 default:
478 NOTREACHED(); 479 NOTREACHED();
479 return nullptr; 480 return nullptr;
480 } 481 }
481 } 482 }
482 483
483 } // namespace scheduler 484 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/base/virtual_time_domain.cc ('k') | components/scheduler/child/idle_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698