Bug 1627741: Expect an idle token only if we're actually using cross-process idle scheduling. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D69846

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bas Schouten 2020-04-06 17:25:06 +00:00
Родитель 9136ce65cf
Коммит 3c7916f406
2 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -148,9 +148,10 @@ TimeStamp IdlePeriodState::GetIdleToken(TimeStamp aLocalIdlePeriodHint,
MOZ_ASSERT(NS_IsMainThread(),
"Why are we touching idle state off the main thread?");
if (XRE_IsParentProcess()) {
if (!ShouldGetIdleToken()) {
return aLocalIdlePeriodHint;
}
if (mIdleToken) {
TimeStamp now = TimeStamp::Now();
if (mIdleToken < now) {
@ -170,8 +171,7 @@ void IdlePeriodState::RequestIdleToken(TimeStamp aLocalIdlePeriodHint) {
if (!mIdleSchedulerInitialized) {
mIdleSchedulerInitialized = true;
if (StaticPrefs::idle_period_cross_process_scheduling() &&
XRE_IsContentProcess()) {
if (ShouldGetIdleToken()) {
// For now cross-process idle scheduler is supported only on the main
// threads of the child processes.
mIdleScheduler = ipc::IdleSchedulerChild::GetMainThreadIdleScheduler();
@ -244,4 +244,8 @@ void IdlePeriodState::ClearIdleToken() {
}
}
bool IdlePeriodState::ShouldGetIdleToken() {
return StaticPrefs::idle_period_cross_process_scheduling() &&
XRE_IsContentProcess();
}
} // namespace mozilla

Просмотреть файл

@ -144,6 +144,10 @@ class IdlePeriodState {
TimeStamp GetIdleDeadlineInternal(bool aIsPeek,
const MutexAutoUnlock& aProofOfUnlock);
// Whether we should be getting an idle token (i.e. are a content process
// and are using cross process idle scheduling).
bool ShouldGetIdleToken();
// Set to true if we have claimed we have a ready-to-run idle task when asked.
// In that case, we will ensure that we allow at least one task to run when
// someone tries to run a task, even if we have run out of idle period at that