update_engine: Make the ChromeOS/AOSP Omaha Client transmit sessionid.

As per Omaha's protocol specification, ChromeOS/AOSP
needs to transmit the 'sessionid` attribute in the request.
The format of the 'sessionid' attribute is sent as GUID version 4.

The sessionid is kept throughout the entirety of the update flow.
1. When the <updatecheck> (pings/download/updates) is done, the pings
   to Omaha will send empty sessionids.
2. If there is a schedule error/issue and a new update is scheduled, a
   new sessionid will be applied.
3. During errors/issues, the same sessionid will be used.
4. All new <updatechecks> will start with a fresh sessionid.

BUG=chromium:940515
TEST=cros_workon_make --board=octopus update_engine --test
TEST=/usr/bin/update_engine_client --check_for_update # after bouncing update-engine + check /var/log/update_engine.log. 'sessionid'
attribute will be in the omaha request.

Change-Id: If4d29b630e3ab1b547606ef1c5fb06cc7a9cd61f
Reviewed-on: https://chromium-review.googlesource.com/1658422
Tested-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Ready: Jae Hoon Kim <kimjae@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index f24cd42..40e52f0 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -111,6 +111,7 @@
 constexpr char kXGoogleUpdateInteractivity[] = "X-Goog-Update-Interactivity";
 constexpr char kXGoogleUpdateAppId[] = "X-Goog-Update-AppId";
 constexpr char kXGoogleUpdateUpdater[] = "X-Goog-Update-Updater";
+constexpr char kXGoogleUpdateSessionId[] = "X-Goog-Update-SessionId";
 
 // updatecheck attributes (without the underscore prefix).
 constexpr char kAttrEol[] = "eol";
@@ -285,7 +286,8 @@
     SystemState* system_state,
     OmahaEvent* event,
     std::unique_ptr<HttpFetcher> http_fetcher,
-    bool ping_only)
+    bool ping_only,
+    const string& session_id)
     : system_state_(system_state),
       params_(system_state->request_params()),
       event_(event),
@@ -293,7 +295,8 @@
       policy_provider_(std::make_unique<policy::PolicyProvider>()),
       ping_only_(ping_only),
       ping_active_days_(0),
-      ping_roll_call_days_(0) {
+      ping_roll_call_days_(0),
+      session_id_(session_id) {
   policy_provider_->Reload();
 }
 
@@ -429,7 +432,8 @@
                                        ping_active_days_,
                                        ping_roll_call_days_,
                                        GetInstallDate(system_state_),
-                                       system_state_->prefs());
+                                       system_state_->prefs(),
+                                       session_id_);
   string request_post = omaha_request.GetRequest();
 
   // Set X-Goog-Update headers.
@@ -440,6 +444,7 @@
       kXGoogleUpdateUpdater,
       base::StringPrintf(
           "%s-%s", constants::kOmahaUpdaterID, kOmahaUpdaterVersion));
+  http_fetcher_->SetHeader(kXGoogleUpdateSessionId, session_id_);
 
   http_fetcher_->SetPostData(
       request_post.data(), request_post.size(), kHttpContentTypeTextXml);