Bug 1181518 - Change the reason for memory-pressure fired during priority change. r=gsvelto

This commit is contained in:
Kan-Ru Chen 2015-07-14 16:32:05 +08:00
parent 0aa4e0e235
commit f5063cfb8c
3 changed files with 10 additions and 3 deletions

View File

@ -1095,7 +1095,7 @@ ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
}
if (aPriority < PROCESS_PRIORITY_FOREGROUND) {
unused << mContentParent->SendFlushMemory(NS_LITERAL_STRING("low-memory"));
unused << mContentParent->SendFlushMemory(NS_LITERAL_STRING("lowering-priority"));
}
FireTestOnlyObserverNotification("process-priority-set",

View File

@ -986,7 +986,8 @@ PuppetWidget::MemoryPressureObserver::Observe(nsISupports* aSubject,
return NS_OK;
}
if (strcmp("memory-pressure", aTopic) == 0) {
if (strcmp("memory-pressure", aTopic) == 0 &&
!NS_LITERAL_STRING("lowering-priority").Equals(aData)) {
if (!mWidget->mVisible && mWidget->mLayerManager &&
XRE_IsContentProcess()) {
mWidget->mLayerManager->ClearCachedResources();

View File

@ -18,7 +18,7 @@
* example, because the client maintains a large memory cache that
* could be released when memory is tight) should register with the
* observer service (see nsIObserverService) using the topic
* "memory-pressure". There are three specific types of notications
* "memory-pressure". There are specific types of notications
* that can occur. These types will be passed as the |aData|
* parameter of the of the "memory-pressure" notification:
*
@ -45,6 +45,12 @@
* This will be passed as the extra data when the pressure
* observer has been asked to flush because a malloc() or
* realloc() has failed.
*
* "lowering-priority"
* This will be passed as the extra data when the priority of a child
* process is lowered. The pressure observers could take the chance to
* clear caches that could be easily regenerated. This type of
* notification only appears in child processes.
*/
[scriptable, uuid(1e004834-6d8f-425a-bc9c-a2812ed43bb7)]