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

Unified Diff: update_engine_client.cc

Issue 3034026: AU: Provide a reboot_if_needed D-Bus API. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: reboot error code doesn't necessarily signal a problem. 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 | « update_engine.xml ('k') | utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: update_engine_client.cc
diff --git a/update_engine_client.cc b/update_engine_client.cc
index bb4beaa328b03fdd97f53bb1cf0ecfb0a15731ad..c8dda0717c4784f96441ea7f17faddf4a93afed7 100644
--- a/update_engine_client.cc
+++ b/update_engine_client.cc
@@ -22,14 +22,12 @@ using chromeos_update_engine::kUpdateEngineServiceInterface;
using chromeos_update_engine::utils::GetGErrorMessage;
using std::string;
-DEFINE_string(app_version, "",
- "Force the current app version.");
-DEFINE_bool(check_for_update, false,
- "Initiate check for updates.");
+DEFINE_string(app_version, "", "Force the current app version.");
+DEFINE_bool(check_for_update, false, "Initiate check for updates.");
DEFINE_bool(force_update, false,
"Force an update, even over an expensive network.");
-DEFINE_string(omaha_url, "",
- "The URL of the Omaha update server.");
+DEFINE_string(omaha_url, "", "The URL of the Omaha update server.");
+DEFINE_bool(reboot, false, "Initiate a reboot if needed.");
DEFINE_bool(status, false, "Print the status to stdout.");
DEFINE_bool(watch_for_updates, false,
"Listen for status updates and print them to the screen.");
@@ -158,6 +156,21 @@ bool CheckForUpdates(bool force, const string& app_version,
return true;
}
+bool RebootIfNeeded() {
+ DBusGProxy* proxy;
+ GError* error = NULL;
+
+ CHECK(GetProxy(&proxy));
+
+ gboolean rc =
+ org_chromium_UpdateEngineInterface_reboot_if_needed(proxy, &error);
+ // Reboot error code doesn't necessarily mean that a reboot
+ // failed. For example, D-Bus may be shutdown before we receive the
+ // result.
+ LOG_IF(INFO, !rc) << "Reboot error message: " << GetGErrorMessage(error);
+ return true;
+}
+
} // namespace {}
int main(int argc, char** argv) {
@@ -177,6 +190,7 @@ int main(int argc, char** argv) {
}
if (FLAGS_force_update || FLAGS_check_for_update ||
!FLAGS_app_version.empty() || !FLAGS_omaha_url.empty()) {
+ LOG_IF(WARNING, FLAGS_reboot) << "-reboot flag ignored.";
LOG(INFO) << "Initiating update check and install.";
if (FLAGS_force_update) {
LOG(INFO) << "Will not abort due to being on expensive network.";
@@ -187,10 +201,16 @@ int main(int argc, char** argv) {
return 0;
}
if (FLAGS_watch_for_updates) {
+ LOG_IF(WARNING, FLAGS_reboot) << "-reboot flag ignored.";
LOG(INFO) << "Watching for status updates.";
WatchForUpdates(); // Should never return.
return 1;
}
+ if (FLAGS_reboot) {
+ LOG(INFO) << "Requesting a reboot...";
+ CHECK(RebootIfNeeded());
+ return 0;
+ }
LOG(INFO) << "No flags specified. Exiting.";
return 0;
« no previous file with comments | « update_engine.xml ('k') | utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698