Add UMA metrics for detecting and reporting update certificate changes.

LibcurlHttpFetcher checks if the update server certificate has changed
since last update, and stores an eventual report in prefs. UpdateCheckScheduler
submits to UMA reports from the previous update.

BUG=chromium-os:19842
TEST=Included unittest for the new class and tested locally on an Alex device,
since we need to verify against the actual server certificates.

Change-Id: I5bee5d648982cd7618db09b67d5bff377eaa1fc1
Reviewed-on: http://gerrit.chromium.org/gerrit/7565
Reviewed-by: Bruno Pontes Soares Rocha <bpontes@chromium.org>
Tested-by: Bruno Pontes Soares Rocha <bpontes@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
diff --git a/libcurl_http_fetcher.h b/libcurl_http_fetcher.h
index 177664b..b436de6 100644
--- a/libcurl_http_fetcher.h
+++ b/libcurl_http_fetcher.h
@@ -7,10 +7,13 @@
 
 #include <map>
 #include <string>
+
+#include <base/basictypes.h>
+#include <base/logging.h>
 #include <curl/curl.h>
 #include <glib.h>
-#include "base/basictypes.h"
-#include "base/logging.h"
+
+#include "update_engine/certificate_checker.h"
 #include "update_engine/http_fetcher.h"
 
 // This is a concrete implementation of HttpFetcher that uses libcurl to do the
@@ -42,7 +45,8 @@
         forced_official_build_(false),
         in_write_callback_(false),
         sent_byte_(false),
-        terminate_requested_(false) {}
+        terminate_requested_(false),
+        check_certificate_(CertificateChecker::kNone) {}
 
   // Cleans up all internal state. Does not notify delegate
   ~LibcurlHttpFetcher();
@@ -90,6 +94,11 @@
     forced_official_build_ = is_official;
   }
 
+  void set_check_certificate(
+      CertificateChecker::ServerToCheck check_certificate) {
+    check_certificate_ = check_certificate;
+  }
+
  private:
   // Callback for when proxy resolution has completed. This begins the
   // transfer.
@@ -223,6 +232,11 @@
   // if we get a terminate request, queue it until we can handle it.
   bool terminate_requested_;
 
+  // Represents which server certificate to be checked against this
+  // connection's certificate. If no certificate check needs to be performed,
+  // this should be kNone.
+  CertificateChecker::ServerToCheck check_certificate_;
+
   DISALLOW_COPY_AND_ASSIGN(LibcurlHttpFetcher);
 };