Bug 1234176 - Do not send memory pressure events to applications sent into the background. r=dhylands

This commit is contained in:
Gabriele Svelto 2015-12-29 11:17:13 +01:00
parent c22a6229cd
commit a9d408188f
2 changed files with 5 additions and 34 deletions

View File

@ -692,7 +692,6 @@ pref("layout.css.scroll-snap.enabled", true);
pref("dom.ipc.processPriorityManager.enabled", true);
pref("dom.ipc.processPriorityManager.backgroundGracePeriodMS", 1000);
pref("dom.ipc.processPriorityManager.backgroundPerceivableGracePeriodMS", 5000);
pref("dom.ipc.processPriorityManager.memoryPressureGracePeriodMS", 3000);
pref("dom.ipc.processPriorityManager.temporaryPriorityLockMS", 5000);
// Number of different background/foreground levels for background/foreground

View File

@ -344,7 +344,6 @@ public:
private:
static uint32_t sBackgroundPerceivableGracePeriodMS;
static uint32_t sBackgroundGracePeriodMS;
static uint32_t sMemoryPressureGracePeriodMS;
void FireTestOnlyObserverNotification(
const char* aTopic,
@ -369,7 +368,6 @@ private:
nsAutoCString mNameWithComma;
nsCOMPtr<nsITimer> mResetPriorityTimer;
nsCOMPtr<nsITimer> mMemoryPressureTimer;
};
/* static */ bool ProcessPriorityManagerImpl::sInitialized = false;
@ -382,7 +380,6 @@ private:
ProcessPriorityManagerImpl::sSingleton;
/* static */ uint32_t ParticularProcessPriorityManager::sBackgroundPerceivableGracePeriodMS = 0;
/* static */ uint32_t ParticularProcessPriorityManager::sBackgroundGracePeriodMS = 0;
/* static */ uint32_t ParticularProcessPriorityManager::sMemoryPressureGracePeriodMS = 0;
NS_IMPL_ISUPPORTS(ProcessPriorityManagerImpl,
nsIObserver,
@ -702,8 +699,6 @@ ParticularProcessPriorityManager::StaticInit()
"dom.ipc.processPriorityManager.backgroundPerceivableGracePeriodMS");
Preferences::AddUintVarCache(&sBackgroundGracePeriodMS,
"dom.ipc.processPriorityManager.backgroundGracePeriodMS");
Preferences::AddUintVarCache(&sMemoryPressureGracePeriodMS,
"dom.ipc.processPriorityManager.memoryPressureGracePeriodMS");
}
void
@ -1010,28 +1005,17 @@ ParticularProcessPriorityManager::ScheduleResetPriority(TimeoutPref aTimeoutPref
}
LOGP("Scheduling reset timer to fire in %dms.", timeout);
mResetPriorityTimer = do_CreateInstance("@mozilla.org/timer;1");
mResetPriorityTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
mResetPriorityTimer->InitWithCallback(this, timeout, nsITimer::TYPE_ONE_SHOT);
}
NS_IMETHODIMP
ParticularProcessPriorityManager::Notify(nsITimer* aTimer)
{
if (mResetPriorityTimer == aTimer) {
LOGP("Reset priority timer callback; about to ResetPriorityNow.");
ResetPriorityNow();
mResetPriorityTimer = nullptr;
return NS_OK;
}
if (mContentParent && mMemoryPressureTimer == aTimer) {
Unused << mContentParent->SendFlushMemory(NS_LITERAL_STRING("lowering-priority"));
mMemoryPressureTimer = nullptr;
return NS_OK;
}
NS_WARNING("Unexpected timer!");
return NS_ERROR_INVALID_POINTER;
LOGP("Reset priority timer callback; about to ResetPriorityNow.");
ResetPriorityNow();
mResetPriorityTimer = nullptr;
return NS_OK;
}
bool
@ -1156,18 +1140,6 @@ ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
NotifyProcessPriorityChanged(this, oldPriority);
Unused << mContentParent->SendNotifyProcessPriorityChanged(mPriority);
if (mMemoryPressureTimer) {
mMemoryPressureTimer->Cancel();
mMemoryPressureTimer = nullptr;
}
if (aPriority < PROCESS_PRIORITY_FOREGROUND) {
mMemoryPressureTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
mMemoryPressureTimer->InitWithCallback(this,
sMemoryPressureGracePeriodMS,
nsITimer::TYPE_ONE_SHOT);
}
}
FireTestOnlyObserverNotification("process-priority-set",