Bug 842679 - Part 2: Add PROCESS_PRIORITY_UNKNOWN to hal. r=cjones, a=tef+
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -847,16 +847,18 @@ ProcessPriorityToString(ProcessPriority
case PROCESS_PRIORITY_FOREGROUND:
return "FOREGROUND";
case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE:
return "BACKGROUND_PERCEIVABLE";
case PROCESS_PRIORITY_BACKGROUND_HOMESCREEN:
return "BACKGROUND_HOMESCREEN";
case PROCESS_PRIORITY_BACKGROUND:
return "BACKGROUND";
+ case PROCESS_PRIORITY_UNKNOWN:
+ return "UNKNOWN";
default:
MOZ_ASSERT(false);
return "???";
}
}
static StaticAutoPtr<ObserverList<FMRadioOperationInformation> > sFMRadioObservers;
--- a/hal/HalTypes.h
+++ b/hal/HalTypes.h
@@ -71,17 +71,20 @@ enum SwitchState {
SWITCH_STATE_OFF,
SWITCH_STATE_HEADSET, // Headphone with microphone
SWITCH_STATE_HEADPHONE, // without microphone
NUM_SWITCH_STATE
};
typedef Observer<SwitchEvent> SwitchObserver;
+// Note that we rely on the order of this enum's entries. Higher priorities
+// should have larger int values.
enum ProcessPriority {
+ PROCESS_PRIORITY_UNKNOWN = -1,
PROCESS_PRIORITY_BACKGROUND,
PROCESS_PRIORITY_BACKGROUND_HOMESCREEN,
PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE,
// Any priority greater than or equal to FOREGROUND is considered
// "foreground" for the purposes of priority testing, for example
// CurrentProcessIsForeground().
PROCESS_PRIORITY_FOREGROUND,
PROCESS_PRIORITY_FOREGROUND_HIGH,
@@ -256,17 +259,17 @@ struct ParamTraits<mozilla::hal::SwitchD
public EnumSerializer<mozilla::hal::SwitchDevice,
mozilla::hal::SWITCH_DEVICE_UNKNOWN,
mozilla::hal::NUM_SWITCH_DEVICE> {
};
template <>
struct ParamTraits<mozilla::hal::ProcessPriority>:
public EnumSerializer<mozilla::hal::ProcessPriority,
- mozilla::hal::PROCESS_PRIORITY_BACKGROUND,
+ mozilla::hal::PROCESS_PRIORITY_UNKNOWN,
mozilla::hal::NUM_PROCESS_PRIORITY> {
};
/**
* Serializer for FMRadioOperation
*/
template <>
struct ParamTraits<mozilla::hal::FMRadioOperation>:
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -1127,17 +1127,20 @@ SetProcessPriority(int aPid, ProcessPrio
break;
case PROCESS_PRIORITY_FOREGROUND_HIGH:
priorityStr = "foregroundHigh";
break;
case PROCESS_PRIORITY_MASTER:
priorityStr = "master";
break;
default:
- MOZ_NOT_REACHED();
+ // PROCESS_PRIORITY_UNKNOWN ends up in this branch, along with invalid enum
+ // values.
+ NS_ERROR("Invalid process priority!");
+ return;
}
// Notice that you can disable oom_adj and renice by deleting the prefs
// hal.processPriorityManager{foreground,background,master}{OomAdjust,Nice}.
int32_t oomScoreAdj = 0;
nsresult rv = Preferences::GetInt(nsPrintfCString(
"hal.processPriorityManager.gonk.%sOomScoreAdjust",