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

Unified Diff: main.cc

Issue 3041044: Don't schedule periodic update checks for non-official builds. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Fix persistent storage on stack bug. Created 10 years, 5 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 | utils.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 bdd216c9790009d87aac21ed688f39b81ad46a3b..9e7a1effe283f23a9cdc666c0eafd17ad9959157 100644
--- a/main.cc
+++ b/main.cc
@@ -16,6 +16,7 @@
#include "update_engine/dbus_service.h"
#include "update_engine/prefs.h"
#include "update_engine/update_attempter.h"
+#include "update_engine/utils.h"
extern "C" {
#include "update_engine/update_engine.dbusserver.h"
@@ -34,15 +35,28 @@ namespace chromeos_update_engine {
namespace {
-struct PeriodicallyUpdateArgs {
- UpdateAttempter* update_attempter;
- gboolean should_repeat;
-};
+gboolean UpdateOnce(void* arg) {
+ UpdateAttempter* update_attempter = reinterpret_cast<UpdateAttempter*>(arg);
+ update_attempter->Update("", "");
+ return FALSE;
+}
-gboolean PeriodicallyUpdate(void* arg) {
- PeriodicallyUpdateArgs* args = reinterpret_cast<PeriodicallyUpdateArgs*>(arg);
- args->update_attempter->Update("", "");
- return args->should_repeat;
+gboolean UpdatePeriodically(void* arg) {
+ UpdateAttempter* update_attempter = reinterpret_cast<UpdateAttempter*>(arg);
+ update_attempter->Update("", "");
+ return TRUE;
+}
+
+void SchedulePeriodicUpdateChecks(UpdateAttempter* update_attempter) {
+ if (!utils::IsOfficialBuild()) {
+ LOG(WARNING) << "No periodic update checks on non-official builds.";
+ return;
+ }
+
+ // Kick off periodic updating. First, update after 2 minutes. Also, update
+ // every 30 minutes.
+ g_timeout_add(2 * 60 * 1000, &UpdateOnce, update_attempter);
+ g_timeout_add(30 * 60 * 1000, &UpdatePeriodically, update_attempter);
}
void SetupDbusService(UpdateEngineService* service) {
@@ -126,19 +140,7 @@ int main(int argc, char** argv) {
update_attempter.set_dbus_service(service);
chromeos_update_engine::SetupDbusService(service);
- // Kick off periodic updating. First, update after 2 minutes. Also, update
- // every 30 minutes.
- chromeos_update_engine::PeriodicallyUpdateArgs two_min_args =
- {&update_attempter, FALSE};
- g_timeout_add(2 * 60 * 1000,
- &chromeos_update_engine::PeriodicallyUpdate,
- &two_min_args);
-
- chromeos_update_engine::PeriodicallyUpdateArgs thirty_min_args =
- {&update_attempter, TRUE};
- g_timeout_add(30 * 60 * 1000,
- &chromeos_update_engine::PeriodicallyUpdate,
- &thirty_min_args);
+ chromeos_update_engine::SchedulePeriodicUpdateChecks(&update_attempter);
// Run the main loop until exit time:
g_main_loop_run(loop);
« no previous file with comments | « no previous file | utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698