Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1123)

Unified Diff: main.cc

Issue 3167039: AU: Simplify the automatic update check code a little. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Rename to avoid confusion. Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | update_attempter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: main.cc
diff --git a/main.cc b/main.cc
index 251b10a7b72f38517b079be6d06984f55d0ad149..64c6aba6db5d949eb176c9def06b1fc6f5348bbe 100644
--- a/main.cc
+++ b/main.cc
@@ -46,45 +46,6 @@ gboolean UpdateBootFlags(void* arg) {
namespace {
-const int kTimeoutOnce = 7 * 60; // at 7 minutes
-const int kTimeoutPeriodic = 45 * 60; // every 45 minutes
-const int kTimeoutFuzz = 10 * 60; // +/- 5 minutes
-
-// Schedules an update check |seconds| from now, while adding some fuzz.
-void ScheduleUpdateCheck(int seconds,
- GSourceFunc update_function,
- UpdateAttempter* update_attempter) {
- seconds = utils::FuzzInt(seconds, kTimeoutFuzz);
- g_timeout_add_seconds(seconds, update_function, update_attempter);
-}
-
-gboolean UpdateOnce(void* arg) {
- UpdateAttempter* update_attempter = reinterpret_cast<UpdateAttempter*>(arg);
- update_attempter->Update("", "");
- return FALSE; // Don't run again.
-}
-
-gboolean UpdatePeriodically(void* arg) {
- UpdateAttempter* update_attempter = reinterpret_cast<UpdateAttempter*>(arg);
- update_attempter->Update("", "");
- ScheduleUpdateCheck(kTimeoutPeriodic, &UpdatePeriodically, update_attempter);
- return FALSE; // Don't run again.
-}
-
-void SchedulePeriodicUpdateChecks(UpdateAttempter* update_attempter) {
- if (!utils::IsOfficialBuild()) {
- LOG(WARNING) << "Non-official build: periodic update checks disabled.";
- return;
- }
- if (utils::IsRemovableDevice(utils::RootDevice(utils::BootDevice()))) {
- LOG(WARNING) << "Removable device boot: periodic update checks disabled.";
- return;
- }
- // Kick off periodic updating.
- ScheduleUpdateCheck(kTimeoutOnce, &UpdateOnce, update_attempter);
- ScheduleUpdateCheck(kTimeoutPeriodic, &UpdatePeriodically, update_attempter);
-}
-
void SetupDbusService(UpdateEngineService* service) {
DBusGConnection *bus;
DBusGProxy *proxy;
@@ -167,7 +128,7 @@ int main(int argc, char** argv) {
update_attempter.set_dbus_service(service);
chromeos_update_engine::SetupDbusService(service);
- chromeos_update_engine::SchedulePeriodicUpdateChecks(&update_attempter);
+ update_attempter.InitiatePeriodicUpdateChecks();
// Update boot flags after 45 seconds
g_timeout_add_seconds(45, &chromeos_update_engine::UpdateBootFlags, NULL);
« no previous file with comments | « no previous file | update_attempter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698