зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1212833 - Delay the MemoryPressure when an application goes to background. r=gsvelto
This commit is contained in:
Родитель
6fa70576bd
Коммит
9f58a5ad3d
|
@ -693,6 +693,7 @@ 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
|
||||
|
|
|
@ -346,6 +346,7 @@ public:
|
|||
private:
|
||||
static uint32_t sBackgroundPerceivableGracePeriodMS;
|
||||
static uint32_t sBackgroundGracePeriodMS;
|
||||
static uint32_t sMemoryPressureGracePeriodMS;
|
||||
|
||||
void FireTestOnlyObserverNotification(
|
||||
const char* aTopic,
|
||||
|
@ -370,6 +371,7 @@ private:
|
|||
nsAutoCString mNameWithComma;
|
||||
|
||||
nsCOMPtr<nsITimer> mResetPriorityTimer;
|
||||
nsCOMPtr<nsITimer> mMemoryPressureTimer;
|
||||
};
|
||||
|
||||
/* static */ bool ProcessPriorityManagerImpl::sInitialized = false;
|
||||
|
@ -382,6 +384,7 @@ 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,
|
||||
|
@ -701,6 +704,8 @@ ParticularProcessPriorityManager::StaticInit()
|
|||
"dom.ipc.processPriorityManager.backgroundPerceivableGracePeriodMS");
|
||||
Preferences::AddUintVarCache(&sBackgroundGracePeriodMS,
|
||||
"dom.ipc.processPriorityManager.backgroundGracePeriodMS");
|
||||
Preferences::AddUintVarCache(&sMemoryPressureGracePeriodMS,
|
||||
"dom.ipc.processPriorityManager.memoryPressureGracePeriodMS");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1014,10 +1019,21 @@ ParticularProcessPriorityManager::ScheduleResetPriority(TimeoutPref aTimeoutPref
|
|||
NS_IMETHODIMP
|
||||
ParticularProcessPriorityManager::Notify(nsITimer* aTimer)
|
||||
{
|
||||
LOGP("Reset priority timer callback; about to ResetPriorityNow.");
|
||||
ResetPriorityNow();
|
||||
mResetPriorityTimer = nullptr;
|
||||
return NS_OK;
|
||||
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;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1142,10 +1158,18 @@ ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
|
|||
NotifyProcessPriorityChanged(this, oldPriority);
|
||||
|
||||
Unused << mContentParent->SendNotifyProcessPriorityChanged(mPriority);
|
||||
}
|
||||
|
||||
if (aPriority < PROCESS_PRIORITY_FOREGROUND) {
|
||||
Unused << mContentParent->SendFlushMemory(NS_LITERAL_STRING("lowering-priority"));
|
||||
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",
|
||||
|
|
Загрузка…
Ссылка в новой задаче