AU: Nice for 2 hours, then normal priority.
The intent is to improve system responsiveness during an update.
BUG=8182
TEST=unit tests; tested on device while watching video and having
two gmail tabs open -- update completed in about 10 minutes.
Change-Id: I2a04a136cedd703260aa53e24d9358bdbbe007fa
Review URL: http://codereview.chromium.org/4191002
diff --git a/update_attempter.cc b/update_attempter.cc
index 7c32475..5b7f988 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -472,7 +472,7 @@
LOG(ERROR) << "Process priority timeout source hasn't been destroyed.";
CleanupPriorityManagement();
}
- const int kPriorityTimeout = 10 * 60; // 10 minutes
+ const int kPriorityTimeout = 2 * 60 * 60; // 2 hours
manage_priority_source_ = g_timeout_source_new_seconds(kPriorityTimeout);
g_source_set_callback(manage_priority_source_,
StaticManagePriorityCallback,
@@ -495,16 +495,9 @@
}
bool UpdateAttempter::ManagePriorityCallback() {
- // If the current process priority is below normal, set it to normal
- // and let GLib invoke this callback again.
- if (utils::ComparePriorities(priority_, utils::kProcessPriorityNormal) < 0) {
- SetPriority(utils::kProcessPriorityNormal);
- return true;
- }
- // Set the priority to high and let GLib destroy the timeout source.
- SetPriority(utils::kProcessPriorityHigh);
+ SetPriority(utils::kProcessPriorityNormal);
manage_priority_source_ = NULL;
- return false;
+ return false; // Destroy the timeout source.
}
void UpdateAttempter::DisableDeltaUpdateIfNeeded() {
diff --git a/update_attempter.h b/update_attempter.h
index db05c7b..3a4ff49 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -134,18 +134,15 @@
// returns.
void SetPriority(utils::ProcessPriority priority);
- // Set the process priority to low and sets up timeout events to increase the
- // priority gradually to high.
+ // Sets the process priority to low and sets up timeout events to increase it.
void SetupPriorityManagement();
// Resets the process priority to normal and destroys any scheduled timeout
// sources.
void CleanupPriorityManagement();
- // The process priority timeout source callback increases the current priority
- // by one step (low goes to normal, normal goes to high). Returns true if the
- // callback must be invoked again after a timeout, or false if GLib can
- // destroy this timeout source.
+ // The process priority timeout source callback sets the current priority to
+ // normal. Returns false so that GLib destroys the timeout source.
static gboolean StaticManagePriorityCallback(gpointer data);
bool ManagePriorityCallback();