Bug 842679 - Part 2: Add PROCESS_PRIORITY_UNKNOWN to hal. r=cjones, a=tef+
authorJustin Lebar <justin.lebar@gmail.com>
Fri, 22 Feb 2013 23:24:28 -0500
changeset 118575 00c4c94a6386a96f2989bf42626144e1e28f58da
parent 118574 0e8c44051bc56e1a175c56095cf08119b08bb78c
child 118576 16f232ab6216d3910780f6b30a1d078fe6e4b512
push id25
push userryanvm@gmail.com
push dateMon, 25 Feb 2013 17:29:08 +0000
reviewerscjones, tef
bugs842679
milestone18.0
Bug 842679 - Part 2: Add PROCESS_PRIORITY_UNKNOWN to hal. r=cjones, a=tef+
hal/Hal.cpp
hal/HalTypes.h
hal/gonk/GonkHal.cpp
--- 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",