Bug 842679 - Part 2: Add PROCESS_PRIORITY_UNKNOWN to hal. r=cjones
authorJustin Lebar <justin.lebar@gmail.com>
Fri, 22 Feb 2013 23:24:28 -0500
changeset 133115 93ccd4912321292701928ab69dd3885e1f088927
parent 133114 257c5fd48f5ac91587650c02abb5aa8d0bbcd8cf
child 133116 67bee77ac7e37ab95dfd47c35783ccef47af570c
push id2452
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 16:59:38 +0000
treeherdermozilla-beta@d4b152d29d8d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs842679
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 842679 - Part 2: Add PROCESS_PRIORITY_UNKNOWN to hal. r=cjones
hal/Hal.cpp
hal/HalTypes.h
hal/gonk/GonkHal.cpp
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -855,16 +855,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
@@ -1130,17 +1130,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",