Bug 808756 - Introduce a memory-pressure event that is not forwarded by the main process to its children. r=jlebar

This commit is contained in:
Gabriele Svelto 2012-11-08 02:07:57 +01:00
parent df0b99ecc4
commit 9e3fdc6388
3 changed files with 10 additions and 2 deletions

View File

@ -1043,7 +1043,8 @@ ContentParent::Observe(nsISupports* aSubject,
return NS_OK;
// listening for memory pressure event
if (!strcmp(aTopic, "memory-pressure")) {
if (!strcmp(aTopic, "memory-pressure") &&
!NS_LITERAL_STRING("low-memory-no-forward").Equals(aData)) {
unused << SendFlushMemory(nsDependentString(aData));
}
// listening for remotePrefs...

View File

@ -34,8 +34,10 @@ public:
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (os) {
// We use low-memory-no-forward because each process has its own watcher
// and thus there is no need for the main process to forward this event.
os->NotifyObservers(nullptr, "memory-pressure",
NS_LITERAL_STRING("low-memory").get());
NS_LITERAL_STRING("low-memory-no-forward").get());
}
return NS_OK;
}

View File

@ -26,6 +26,11 @@
* This will be passed as the extra data when the pressure
* observer is being asked to flush for low-memory conditions.
*
* "low-memory-no-forward"
* This will be passed as the extra data when the pressure observer
* is being asked to flush for low-memory conditions but the resulting
* notification should not be forwarded to the child processes.
*
* "heap-minimize"
* This will be passed as the extra data when the pressure
* observer is being asked to flush because of a heap minimize