AU: Implement exponential back off for 500 and 503 HTTP response codes.
Also refactors the automatic update checks into a separate
scheduler class and adds unit tests for them.
update_check_scheduler.cc 59 / 59: 100.0%
update_check_scheduler.h 1 / 1: 100.0%
Note: because the unit tests for this CL use the
UpdateAttempter class, the CL brings in several untested
modules into the test report reducing the overall test
coverage to ~82%.
BUG=2394
TEST=unit tests, gmerged on device and inspected logs
Change-Id: I078b1727b5338f6fc34e51f5e04a375518d63cef
Review URL: http://codereview.chromium.org/3215006
diff --git a/main.cc b/main.cc
index 64c6aba..f027033 100644
--- a/main.cc
+++ b/main.cc
@@ -6,20 +6,20 @@
#include <tr1/memory>
#include <vector>
+#include <base/at_exit.h>
+#include <base/command_line.h>
+#include <base/logging.h>
+#include <base/string_util.h>
#include <gflags/gflags.h>
#include <glib.h>
+#include <metrics/metrics_library.h>
-#include "base/at_exit.h"
-#include "base/command_line.h"
-#include "base/logging.h"
-#include "base/string_util.h"
-#include "metrics/metrics_library.h"
#include "update_engine/dbus_constants.h"
#include "update_engine/dbus_service.h"
#include "update_engine/prefs.h"
#include "update_engine/subprocess.h"
#include "update_engine/update_attempter.h"
-#include "update_engine/utils.h"
+#include "update_engine/update_check_scheduler.h"
extern "C" {
#include "update_engine/update_engine.dbusserver.h"
@@ -128,7 +128,9 @@
update_attempter.set_dbus_service(service);
chromeos_update_engine::SetupDbusService(service);
- update_attempter.InitiatePeriodicUpdateChecks();
+ // Schedule periodic update checks.
+ chromeos_update_engine::UpdateCheckScheduler scheduler(&update_attempter);
+ scheduler.Run();
// Update boot flags after 45 seconds
g_timeout_add_seconds(45, &chromeos_update_engine::UpdateBootFlags, NULL);