зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1560931 - Fire memory-pressure-stop events on Windows r=gsvelto
I'd like to rely on always getting a stop event when the system recovers from a memory pressure situation. AIUI this already happens on Android platforms but not on Windows. This adds the stop event for Windows. Differential Revision: https://phabricator.services.mozilla.com/D35679
This commit is contained in:
Родитель
06bd14ced9
Коммит
ace8608f82
|
@ -94,6 +94,7 @@ class nsAvailableMemoryWatcher final : public nsIObserver,
|
|||
bool OngoingMemoryPressure() { return mUnderMemoryPressure; }
|
||||
void AdjustPollingInterval(const bool aLowMemory);
|
||||
void SendMemoryPressureEvent();
|
||||
void MaybeSendMemoryPressureStopEvent();
|
||||
void MaybeSaveMemoryReport();
|
||||
void Shutdown();
|
||||
|
||||
|
@ -188,6 +189,12 @@ void nsAvailableMemoryWatcher::SendMemoryPressureEvent() {
|
|||
NS_DispatchEventualMemoryPressure(state);
|
||||
}
|
||||
|
||||
void nsAvailableMemoryWatcher::MaybeSendMemoryPressureStopEvent() {
|
||||
if (OngoingMemoryPressure()) {
|
||||
NS_DispatchEventualMemoryPressure(MemPressure_Stopping);
|
||||
}
|
||||
}
|
||||
|
||||
void nsAvailableMemoryWatcher::MaybeSaveMemoryReport() {
|
||||
if (!mSavedReport && OngoingMemoryPressure()) {
|
||||
nsCOMPtr<nsICrashReporter> cr =
|
||||
|
@ -221,6 +228,11 @@ nsAvailableMemoryWatcher::Notify(nsITimer* aTimer) {
|
|||
|
||||
if (lowMemory) {
|
||||
SendMemoryPressureEvent();
|
||||
} else {
|
||||
MaybeSendMemoryPressureStopEvent();
|
||||
}
|
||||
|
||||
if (lowMemory) {
|
||||
MaybeSaveMemoryReport();
|
||||
} else {
|
||||
mSavedReport = false; // Save a new report if memory gets low again
|
||||
|
|
|
@ -55,7 +55,10 @@ enum MemoryPressureState {
|
|||
|
||||
/**
|
||||
* Return and erase the latest state of the memory pressure event set by any of
|
||||
* the corresponding dispatch function.
|
||||
* the corresponding dispatch functions.
|
||||
*
|
||||
* This is called when processing events on the main thread to check whether to
|
||||
* fire a memory pressure notification.
|
||||
*/
|
||||
MemoryPressureState NS_GetPendingMemoryPressure();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче