Report Enum metrics from CertificateChecker.

The certificate checker was reporting a "user action" whenever an
update check HTTPS connection or HTTPS payload download had an invalid
HTTPS certificate or a valid one that was changed since the last
connection to the same server.

This patch sends an Enum metric for every HTTPS connection to check for
and update or download the payload with one of the three options: an
invalid certificate, a valid one already seen or a valid but different
certificate.

This patch also moves these metrics to the metrics.{h,cc} module, where
all the other metrics are reported, using an observer pattern in the
CertificateChecker, needed to remove the dependency on the metrics
library from the libpayload_consumer.

Bug: 25818567
TEST=FEATURES=test emerge-link update_engine; mma;

Change-Id: Ia1b6eb799e13b439b520ba14549d8973e18bcbfa
diff --git a/update_attempter.h b/update_attempter.h
index c0e8de0..500f48f 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -32,6 +32,7 @@
 #include "update_engine/chrome_browser_proxy_resolver.h"
 #include "update_engine/client_library/include/update_engine/update_status.h"
 #include "update_engine/common/action_processor.h"
+#include "update_engine/common/certificate_checker.h"
 #include "update_engine/libcros_proxy.h"
 #include "update_engine/omaha_request_params.h"
 #include "update_engine/omaha_response_handler_action.h"
@@ -52,7 +53,8 @@
 class UpdateEngineAdaptor;
 
 class UpdateAttempter : public ActionProcessorDelegate,
-                        public DownloadActionDelegate {
+                        public DownloadActionDelegate,
+                        public CertificateChecker::Observer {
  public:
   using UpdateStatus = update_engine::UpdateStatus;
   static const int kMaxDeltaUpdateFailures;
@@ -233,6 +235,11 @@
   FRIEND_TEST(UpdateAttempterTest, ReportDailyMetrics);
   FRIEND_TEST(UpdateAttempterTest, BootTimeInUpdateMarkerFile);
 
+  // CertificateChecker::Observer method.
+  // Report metrics about the certificate being checked.
+  void CertificateChecked(ServerToCheck server_to_check,
+                          CertificateCheckResult result) override;
+
   // Checks if it's more than 24 hours since daily metrics were last
   // reported and, if so, reports daily metrics. Returns |true| if
   // metrics were reported, |false| otherwise.
@@ -439,6 +446,9 @@
   DirectProxyResolver direct_proxy_resolver_;
   ChromeBrowserProxyResolver chrome_proxy_resolver_;
 
+  // OpenSSLWrapper used for checking certificates.
+  OpenSSLWrapper openssl_wrapper_;
+
   // Originally, both of these flags are false. Once UpdateBootFlags is called,
   // |update_boot_flags_running_| is set to true. As soon as UpdateBootFlags
   // completes its asynchronous run, |update_boot_flags_running_| is reset to