Modify priority tweaking to use CGroups.

This modifies the behavior of setpriority and getpriority
to use CGroups rather than niceness levels.

I've removed the unittest comparing priorities as its not
really valid any more as we are just writing numbers to files.

I've also refactored references to priority to reference cpu
shares etc.

BUG=chromium-os:36229
TEST=Unittest + doing end to end test in bgnd
CQ-DEPEND=I6a0e56073e7281268e0550919c9ec9202b18db26

Change-Id: I48c8270c2065f1e0677e5e53df3557131577b97c
Reviewed-on: https://gerrit.chromium.org/gerrit/39147
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Chris Sosa <sosa@chromium.org>
diff --git a/utils.h b/utils.h
index 555f54c..ffc2f39 100644
--- a/utils.h
+++ b/utils.h
@@ -243,21 +243,24 @@
 // Returns empty string on failure.
 const std::string BootKernelDevice(const std::string& boot_device);
 
-enum ProcessPriority {
-  kProcessPriorityHigh = -10,
-  kProcessPriorityNormal = 0,
-  kProcessPriorityLow = 10,
+// Cgroups cpu shares constants. 1024 is the default shares a standard process
+// gets and 2 is the minimum value. We set High as a value that gives the
+// update-engine 2x the cpu share of a standard process.
+enum CpuShares {
+  kCpuSharesHigh = 2048,
+  kCpuSharesNormal = 1024,
+  kCpuSharesLow = 2,
 };
 
-// Compares process priorities and returns an integer that is less
-// than, equal to or greater than 0 if |priority_lhs| is,
-// respectively, lower than, same as or higher than |priority_rhs|.
-int ComparePriorities(ProcessPriority priority_lhs,
-                      ProcessPriority priority_rhs);
+// Compares cpu shares and returns an integer that is less
+// than, equal to or greater than 0 if |shares_lhs| is,
+// respectively, lower than, same as or higher than |shares_rhs|.
+int CompareCpuShares(CpuShares shares_lhs,
+                     CpuShares shares_rhs);
 
-// Sets the current process priority to |priority|. Returns true on
+// Sets the current process shares to |shares|. Returns true on
 // success, false otherwise.
-bool SetProcessPriority(ProcessPriority priority);
+bool SetCpuShares(CpuShares shares);
 
 // Assumes data points to a Closure. Runs it and returns FALSE;
 gboolean GlibRunClosure(gpointer data);