Add support to update_engine to poke Omaha after an update has been applied
successfully and is awaiting reboot to help ensure the number of actives
remains accurate.

BUG=chromium-os:12026
TEST=Manual test, unit tests

Change-Id: Ie3397264b0b34e8d423fb9748970f7d330122180

Review URL: http://codereview.chromium.org/6836025
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index a02387e..f75e443 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -83,7 +83,7 @@
   string ping_active = GetPingAttribute("a", ping_active_days);
   string ping_roll_call = GetPingAttribute("r", ping_roll_call_days);
   if (!ping_active.empty() || !ping_roll_call.empty()) {
-    return StringPrintf("        <o:ping%s%s></o:ping>\n",
+    return StringPrintf("        <o:ping active=\"1\"%s%s></o:ping>\n",
                         ping_active.c_str(),
                         ping_roll_call.c_str());
   }
@@ -92,13 +92,15 @@
 
 string FormatRequest(const OmahaEvent* event,
                      const OmahaRequestParams& params,
+                     bool ping_only,
                      int ping_active_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";
+    body = GetPingBody(ping_active_days, ping_roll_call_days);
+    if (!ping_only)
+      body += "        <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
@@ -173,11 +175,13 @@
 OmahaRequestAction::OmahaRequestAction(PrefsInterface* prefs,
                                        const OmahaRequestParams& params,
                                        OmahaEvent* event,
-                                       HttpFetcher* http_fetcher)
+                                       HttpFetcher* http_fetcher,
+                                       bool ping_only)
     : prefs_(prefs),
       params_(params),
       event_(event),
       http_fetcher_(http_fetcher),
+      ping_only_(ping_only),
       ping_active_days_(0),
       ping_roll_call_days_(0),
       should_skip_(false) {}
@@ -225,6 +229,7 @@
   InitPingDays();
   string request_post(FormatRequest(event_.get(),
                                     params_,
+                                    ping_only_,
                                     ping_active_days_,
                                     ping_roll_call_days_,
                                     prefs_));
@@ -373,12 +378,6 @@
         kActionCodeOmahaRequestHTTPResponseBase + code));
     return;
   }
-  if (!HasOutputPipe()) {
-    // Just set success to whether or not the http transfer succeeded,
-    // which must be true at this point in the code.
-    completer.set_code(kActionCodeSuccess);
-    return;
-  }
 
   // parse our response and fill the fields in the output object
   scoped_ptr_malloc<xmlDoc, ScopedPtrXmlDocFree> doc(
@@ -401,6 +400,13 @@
         << "Failed to update the last ping day preferences!";
   }
 
+  if (!HasOutputPipe()) {
+    // Just set success to whether or not the http transfer succeeded,
+    // which must be true at this point in the code.
+    completer.set_code(kActionCodeSuccess);
+    return;
+  }
+
   static const char* kNamespace("x");
   static const char* kUpdatecheckNodeXpath("/x:gupdate/x:app/x:updatecheck");
   static const char* kNsUrl("http://www.google.com/update2/response");