Bug 914541 - Assign higher priority for mozapptype=inputmethod. r=fabrice

This commit is contained in:
Kan-Ru Chen (陳侃如) 2013-09-24 16:10:20 +08:00
parent de5cd97ba9
commit 4f0c40f445
5 changed files with 26 additions and 4 deletions

View File

@ -612,6 +612,10 @@ pref("dom.ipc.processPriorityManager.temporaryPriorityLockMS", 5000);
// /still/ have the same niceness; we'd effectively have erased NSPR's thread // /still/ have the same niceness; we'd effectively have erased NSPR's thread
// priorities. // priorities.
// The kernel can only accept 6 (OomScoreAdjust, KillUnderMB) pairs. But it is
// okay, kernel will still kill processes with larger OomScoreAdjust first even
// its OomScoreAdjust don't have a corresponding KillUnderMB.
pref("hal.processPriorityManager.gonk.MASTER.OomScoreAdjust", 0); pref("hal.processPriorityManager.gonk.MASTER.OomScoreAdjust", 0);
pref("hal.processPriorityManager.gonk.MASTER.KillUnderMB", 4); pref("hal.processPriorityManager.gonk.MASTER.KillUnderMB", 4);
pref("hal.processPriorityManager.gonk.MASTER.Nice", 0); pref("hal.processPriorityManager.gonk.MASTER.Nice", 0);
@ -624,6 +628,9 @@ pref("hal.processPriorityManager.gonk.FOREGROUND.OomScoreAdjust", 134);
pref("hal.processPriorityManager.gonk.FOREGROUND.KillUnderMB", 6); pref("hal.processPriorityManager.gonk.FOREGROUND.KillUnderMB", 6);
pref("hal.processPriorityManager.gonk.FOREGROUND.Nice", 1); pref("hal.processPriorityManager.gonk.FOREGROUND.Nice", 1);
pref("hal.processPriorityManager.gonk.FOREGROUND_KEYBOARD.OomScoreAdjust", 200);
pref("hal.processPriorityManager.gonk.FOREGROUND_KEYBOARD.Nice", 1);
pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.OomScoreAdjust", 400); pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.OomScoreAdjust", 400);
pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.KillUnderMB", 7); pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.KillUnderMB", 7);
pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.Nice", 7); pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.Nice", 7);

View File

@ -495,14 +495,17 @@ PrivilegesForApp(mozIApplication* aApp)
ContentParent::GetInitialProcessPriority(Element* aFrameElement) ContentParent::GetInitialProcessPriority(Element* aFrameElement)
{ {
// Frames with mozapptype == critical which are expecting a system message // Frames with mozapptype == critical which are expecting a system message
// get FOREGROUND_HIGH priority. All other frames get FOREGROUND priority. // get FOREGROUND_HIGH priority.
if (!aFrameElement) { if (!aFrameElement) {
return PROCESS_PRIORITY_FOREGROUND; return PROCESS_PRIORITY_FOREGROUND;
} }
if (!aFrameElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozapptype, if (aFrameElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozapptype,
NS_LITERAL_STRING("critical"), eCaseMatters)) { NS_LITERAL_STRING("keyboard"), eCaseMatters)) {
return PROCESS_PRIORITY_FOREGROUND_KEYBOARD;
} else if (!aFrameElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozapptype,
NS_LITERAL_STRING("critical"), eCaseMatters)) {
return PROCESS_PRIORITY_FOREGROUND; return PROCESS_PRIORITY_FOREGROUND;
} }

View File

@ -855,7 +855,9 @@ ParticularProcessPriorityManager::ComputePriority()
} }
if (isVisible) { if (isVisible) {
return PROCESS_PRIORITY_FOREGROUND; return HasAppType("keyboard") ?
PROCESS_PRIORITY_FOREGROUND_KEYBOARD :
PROCESS_PRIORITY_FOREGROUND;
} }
if ((mHoldsCPUWakeLock || mHoldsHighPriorityWakeLock) && if ((mHoldsCPUWakeLock || mHoldsHighPriorityWakeLock) &&

View File

@ -868,6 +868,8 @@ ProcessPriorityToString(ProcessPriority aPriority)
return "FOREGROUND_HIGH"; return "FOREGROUND_HIGH";
case PROCESS_PRIORITY_FOREGROUND: case PROCESS_PRIORITY_FOREGROUND:
return "FOREGROUND"; return "FOREGROUND";
case PROCESS_PRIORITY_FOREGROUND_KEYBOARD:
return "FOREGROUND_KEYBOARD";
case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE: case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE:
return "BACKGROUND_PERCEIVABLE"; return "BACKGROUND_PERCEIVABLE";
case PROCESS_PRIORITY_BACKGROUND_HOMESCREEN: case PROCESS_PRIORITY_BACKGROUND_HOMESCREEN:
@ -914,6 +916,13 @@ ProcessPriorityToString(ProcessPriority aPriority,
if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) { if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
return "FOREGROUND:CPU_LOW"; return "FOREGROUND:CPU_LOW";
} }
case PROCESS_PRIORITY_FOREGROUND_KEYBOARD:
if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
return "FOREGROUND_KEYBOARD:CPU_NORMAL";
}
if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
return "FOREGROUND_KEYBOARD:CPU_LOW";
}
case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE: case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE:
if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) { if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
return "BACKGROUND_PERCEIVABLE:CPU_NORMAL"; return "BACKGROUND_PERCEIVABLE:CPU_NORMAL";

View File

@ -83,6 +83,7 @@ enum ProcessPriority {
PROCESS_PRIORITY_BACKGROUND, PROCESS_PRIORITY_BACKGROUND,
PROCESS_PRIORITY_BACKGROUND_HOMESCREEN, PROCESS_PRIORITY_BACKGROUND_HOMESCREEN,
PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE, PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE,
PROCESS_PRIORITY_FOREGROUND_KEYBOARD,
// Any priority greater than or equal to FOREGROUND is considered // Any priority greater than or equal to FOREGROUND is considered
// "foreground" for the purposes of priority testing, for example // "foreground" for the purposes of priority testing, for example
// CurrentProcessIsForeground(). // CurrentProcessIsForeground().