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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/child/idle_helper.cc

Issue 2808843003: [scheduler] Change TaskQueue observer call mechanism. (Closed)
Patch Set: Fix compilation Created 3 years, 7 months 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 "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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // Limit the idle period duration to be before the next pending task. 89 // Limit the idle period duration to be before the next pending task.
90 long_idle_period_duration = std::min(next_pending_delayed_task - now, 90 long_idle_period_duration = std::min(next_pending_delayed_task - now,
91 max_long_idle_period_duration); 91 max_long_idle_period_duration);
92 } else { 92 } else {
93 long_idle_period_duration = max_long_idle_period_duration; 93 long_idle_period_duration = max_long_idle_period_duration;
94 } 94 }
95 95
96 if (long_idle_period_duration >= 96 if (long_idle_period_duration >=
97 base::TimeDelta::FromMilliseconds(kMinimumIdlePeriodDurationMillis)) { 97 base::TimeDelta::FromMilliseconds(kMinimumIdlePeriodDurationMillis)) {
98 *next_long_idle_period_delay_out = long_idle_period_duration; 98 *next_long_idle_period_delay_out = long_idle_period_duration;
99 if (!idle_queue_->HasPendingImmediateWork()) { 99 if (!idle_queue_->HasTaskToRunImmediately()) {
100 return IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED; 100 return IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED;
101 } else if (long_idle_period_duration == max_long_idle_period_duration) { 101 } else if (long_idle_period_duration == max_long_idle_period_duration) {
102 return IdlePeriodState::IN_LONG_IDLE_PERIOD_WITH_MAX_DEADLINE; 102 return IdlePeriodState::IN_LONG_IDLE_PERIOD_WITH_MAX_DEADLINE;
103 } else { 103 } else {
104 return IdlePeriodState::IN_LONG_IDLE_PERIOD; 104 return IdlePeriodState::IN_LONG_IDLE_PERIOD;
105 } 105 }
106 } else { 106 } else {
107 // If we can't start the idle period yet then try again after wake-up. 107 // If we can't start the idle period yet then try again after wake-up.
108 *next_long_idle_period_delay_out = base::TimeDelta::FromMilliseconds( 108 *next_long_idle_period_delay_out = base::TimeDelta::FromMilliseconds(
109 kRetryEnableLongIdlePeriodDelayMillis); 109 kRetryEnableLongIdlePeriodDelayMillis);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 } 242 }
243 243
244 void IdleHelper::UpdateLongIdlePeriodStateAfterIdleTask() { 244 void IdleHelper::UpdateLongIdlePeriodStateAfterIdleTask() {
245 helper_->CheckOnValidThread(); 245 helper_->CheckOnValidThread();
246 DCHECK(!is_shutdown_); 246 DCHECK(!is_shutdown_);
247 DCHECK(IsInLongIdlePeriod(state_.idle_period_state())); 247 DCHECK(IsInLongIdlePeriod(state_.idle_period_state()));
248 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 248 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
249 "UpdateLongIdlePeriodStateAfterIdleTask"); 249 "UpdateLongIdlePeriodStateAfterIdleTask");
250 250
251 if (!idle_queue_->HasPendingImmediateWork()) { 251 if (!idle_queue_->HasTaskToRunImmediately()) {
252 // If there are no more idle tasks then pause long idle period ticks until a 252 // If there are no more idle tasks then pause long idle period ticks until a
253 // new idle task is posted. 253 // new idle task is posted.
254 state_.UpdateState(IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED, 254 state_.UpdateState(IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED,
255 state_.idle_period_deadline(), base::TimeTicks()); 255 state_.idle_period_deadline(), base::TimeTicks());
256 } else if (idle_queue_->BlockedByFence()) { 256 } else if (idle_queue_->BlockedByFence()) {
257 // If there is still idle work to do then just start the next idle period. 257 // If there is still idle work to do then just start the next idle period.
258 base::TimeDelta next_long_idle_period_delay; 258 base::TimeDelta next_long_idle_period_delay;
259 if (state_.idle_period_state() == 259 if (state_.idle_period_state() ==
260 IdlePeriodState::IN_LONG_IDLE_PERIOD_WITH_MAX_DEADLINE) { 260 IdlePeriodState::IN_LONG_IDLE_PERIOD_WITH_MAX_DEADLINE) {
261 // If we are in a max deadline long idle period then start the next 261 // If we are in a max deadline long idle period then start the next
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED: 504 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED:
505 return "in_long_idle_period_paused"; 505 return "in_long_idle_period_paused";
506 default: 506 default:
507 NOTREACHED(); 507 NOTREACHED();
508 return nullptr; 508 return nullptr;
509 } 509 }
510 } 510 }
511 511
512 } // namespace scheduler 512 } // namespace scheduler
513 } // namespace blink 513 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698