1311425 - Make requestIdleCallback aware of timeouts.

Prepare for handling several sources of idleness.

Make idle callbacks aware of nsITimers.

Add pref for how far into the timer queue.

1311425 - Avoid expiration timers when scheduling idle runnables.

review comment fix to ensure low priority timers aren't taken into account when calling NS_GetTimerDeadlineHintOnCurrentThread.
This commit is contained in:
win7-7 2024-04-27 19:21:20 +03:00 committed by wuggy
commit 5499c5f9a3
12 changed files with 188 additions and 60 deletions

View file

@ -43,6 +43,14 @@ GetTimerLog()
return sTimerLog;
}
TimeStamp
NS_GetTimerDeadlineHintOnCurrentThread(TimeStamp aDefault, uint32_t aSearchBound)
{
return gThread
? gThread->FindNextFireTimeForCurrentThread(aDefault, aSearchBound)
: TimeStamp();
}
// This module prints info about which timers are firing, which is useful for
// wakeups for the purposes of power profiling. Set the following environment
// variable before starting the browser.
@ -502,7 +510,7 @@ nsTimerImpl::Fire(int32_t aGeneration)
// Repeating timer has not been re-init or canceled; reschedule
mCallbackDuringFire.swap(mCallback);
TimeDuration delay = TimeDuration::FromMilliseconds(mDelay);
if (mType == nsITimer::TYPE_REPEATING_SLACK) {
if (IsSlack()) {
mTimeout = TimeStamp::Now() + delay;
} else {
mTimeout = mTimeout + delay;
@ -536,10 +544,12 @@ nsTimerImpl::LogFiring(const Callback& aCallback, uint8_t aType, uint32_t aDelay
{
const char* typeStr;
switch (aType) {
case nsITimer::TYPE_ONE_SHOT: typeStr = "ONE_SHOT"; break;
case nsITimer::TYPE_REPEATING_SLACK: typeStr = "SLACK "; break;
case nsITimer::TYPE_ONE_SHOT: typeStr = "ONE_SHOT "; break;
case nsITimer::TYPE_ONE_SHOT_LOW_PRIORITY: typeStr = "ONE_LOW "; break;
case nsITimer::TYPE_REPEATING_SLACK: typeStr = "SLACK "; break;
case nsITimer::TYPE_REPEATING_SLACK_LOW_PRIORITY: typeStr = "SLACK_LOW "; break;
case nsITimer::TYPE_REPEATING_PRECISE: /* fall through */
case nsITimer::TYPE_REPEATING_PRECISE_CAN_SKIP: typeStr = "PRECISE "; break;
case nsITimer::TYPE_REPEATING_PRECISE_CAN_SKIP: typeStr = "PRECISE "; break;
default: MOZ_CRASH("bad type");
}