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

Unified Diff: omaha_request_action.cc

Issue 5993007: AU: Send a previous version event after reboot following an update. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: GetString appends to the string Created 9 years, 12 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 | « omaha_request_action.h ('k') | omaha_request_action_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: omaha_request_action.cc
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 51663150e8d647a3caff5723cdb155d3ec63f647..bb2275d2f78e58389702854bb1348b7ebd18e888 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -93,11 +93,31 @@ string GetPingBody(int ping_active_days, int ping_roll_call_days) {
string FormatRequest(const OmahaEvent* event,
const OmahaRequestParams& params,
int ping_active_days,
- int ping_roll_call_days) {
+ int ping_roll_call_days,
+ PrefsInterface* prefs) {
string body;
if (event == NULL) {
body = GetPingBody(ping_active_days, ping_roll_call_days) +
" <o:updatecheck></o:updatecheck>\n";
+ // If this is the first update check after a reboot following a previous
+ // update, generate an event containing the previous version number. If the
+ // previous version preference file doesn't exist the event is still
+ // generated with a previous version of 0.0.0.0 -- this is relevant for
+ // older clients or new installs.
+ string prev_version;
+ if (!prefs->GetString(kPrefsPreviousVersion, &prev_version)) {
+ prev_version = "0.0.0.0";
+ }
+ if (!prev_version.empty()) {
+ body += StringPrintf(
+ " <o:event eventtype=\"%d\" eventresult=\"%d\" "
+ "previousversion=\"%s\"></o:event>\n",
+ OmahaEvent::kTypeUpdateComplete,
+ OmahaEvent::kResultSuccessReboot,
+ prev_version.c_str());
+ LOG_IF(WARNING, !prefs->SetString(kPrefsPreviousVersion, ""))
+ << "Unable to reset the previous version.";
+ }
} else {
// The error code is an optional attribute so append it only if
// the result is not success.
@@ -197,7 +217,8 @@ void OmahaRequestAction::PerformAction() {
string request_post(FormatRequest(event_.get(),
params_,
ping_active_days_,
- ping_roll_call_days_));
+ ping_roll_call_days_,
+ prefs_));
http_fetcher_->SetPostData(request_post.data(), request_post.size());
LOG(INFO) << "Posting an Omaha request to " << params_.update_url;
LOG(INFO) << "Request: " << request_post;
« no previous file with comments | « omaha_request_action.h ('k') | omaha_request_action_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698