update_engine: Attach session ID to HTTP header of binary download

In order for Omaha to correlate Omaha Client requests with the actual
binary download, the session ID must be attached to the HTTP header of
the binary download in the X-Goog-Update-SessionId.

Also, remove the HTTP header of X-Goog-Update-SessionId added into the
Omaha requests.

BUG=chromium:940515
TEST=unittests # new unittests

Change-Id: I0759562f2d1c8c003064ad976ca1ae6ce039b960
diff --git a/common/constants.cc b/common/constants.cc
index 5ab96b0..87bdf91 100644
--- a/common/constants.cc
+++ b/common/constants.cc
@@ -126,4 +126,10 @@
 
 const char kOmahaUpdaterVersion[] = "0.1.0.0";
 
+// X-Goog-Update headers.
+const char kXGoogleUpdateInteractivity[] = "X-Goog-Update-Interactivity";
+const char kXGoogleUpdateAppId[] = "X-Goog-Update-AppId";
+const char kXGoogleUpdateUpdater[] = "X-Goog-Update-Updater";
+const char kXGoogleUpdateSessionId[] = "X-Goog-SessionId";
+
 }  // namespace chromeos_update_engine
diff --git a/common/constants.h b/common/constants.h
index 9b4623f..d95a56a 100644
--- a/common/constants.h
+++ b/common/constants.h
@@ -110,6 +110,12 @@
 
 extern const char kOmahaUpdaterVersion[];
 
+// X-Goog-Update headers.
+extern const char kXGoogleUpdateInteractivity[];
+extern const char kXGoogleUpdateAppId[];
+extern const char kXGoogleUpdateUpdater[];
+extern const char kXGoogleUpdateSessionId[];
+
 // A download source is any combination of protocol and server (that's of
 // interest to us when looking at UMA metrics) using which we may download
 // the payload.
diff --git a/common/file_fetcher.h b/common/file_fetcher.h
index fbdfc32..bd39007 100644
--- a/common/file_fetcher.h
+++ b/common/file_fetcher.h
@@ -59,6 +59,12 @@
   void SetHeader(const std::string& header_name,
                  const std::string& header_value) override {}
 
+  bool GetHeader(const std::string& header_name,
+                 std::string* header_value) const override {
+    header_value->clear();
+    return false;
+  }
+
   // Suspend the asynchronous file read.
   void Pause() override;
 
diff --git a/common/http_fetcher.h b/common/http_fetcher.h
index 93b0e24..94f31d7 100644
--- a/common/http_fetcher.h
+++ b/common/http_fetcher.h
@@ -100,6 +100,14 @@
   virtual void SetHeader(const std::string& header_name,
                          const std::string& header_value) = 0;
 
+  // Only used for testing.
+  // If |header_name| is set, the value will be set into |header_value|.
+  // On success the boolean true will be returned, hoewever on failture to find
+  // the |header_name| in the header the return value will be false. The state
+  // in which |header_value| is left in for failures is an empty string.
+  virtual bool GetHeader(const std::string& header_name,
+                         std::string* header_value) const = 0;
+
   // If data is coming in too quickly, you can call Pause() to pause the
   // transfer. The delegate will not have ReceivedBytes() called while
   // an HttpFetcher is paused.
diff --git a/common/mock_http_fetcher.h b/common/mock_http_fetcher.h
index 492e6ce..0f04319 100644
--- a/common/mock_http_fetcher.h
+++ b/common/mock_http_fetcher.h
@@ -89,6 +89,12 @@
   void SetHeader(const std::string& header_name,
                  const std::string& header_value) override;
 
+  bool GetHeader(const std::string& header_name,
+                 std::string* header_value) const override {
+    header_value->clear();
+    return false;
+  }
+
   // Return the value of the header |header_name| or the empty string if not
   // set.
   std::string GetHeader(const std::string& header_name) const;
diff --git a/common/multi_range_http_fetcher.h b/common/multi_range_http_fetcher.h
index f57ea7f..ef32f0d 100644
--- a/common/multi_range_http_fetcher.h
+++ b/common/multi_range_http_fetcher.h
@@ -83,6 +83,11 @@
     base_fetcher_->SetHeader(header_name, header_value);
   }
 
+  bool GetHeader(const std::string& header_name,
+                 std::string* header_value) const override {
+    return base_fetcher_->GetHeader(header_name, header_value);
+  }
+
   void Pause() override { base_fetcher_->Pause(); }
 
   void Unpause() override { base_fetcher_->Unpause(); }