Send UMA Stats for update engine error codes.

With the latest addition of new optional security checks for the update
manifest and operations checked in, we now want to track the number of
failures, if any, over time to help us decide when it is safe to make
the new security checks mandatory. This CL adds the UMA metric for
reporting the new (as well as the old) error codes to UMA for the first
time.

There's no change to the existing errors that are being sent to Omaha.
Due to UMA restrictions, some Omaha codes will be aggregated when being
sent to UMA.

BUG=chromium-os:34299
TEST=Unit tests pass, tested on real ZGB, all stats show up in
     chrome://histograms correctly for both dev mode and normal mode.
Change-Id: I3ce4645636311cedbb33f601e775951966c0a545
Reviewed-on: https://gerrit.chromium.org/gerrit/36408
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
diff --git a/system_state.h b/system_state.h
index a7fc68c..7d7ac09 100644
--- a/system_state.h
+++ b/system_state.h
@@ -5,6 +5,7 @@
 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_
 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_
 
+#include "metrics/metrics_library.h"
 #include <policy/device_policy.h>
 #include <policy/libpolicy.h>
 
@@ -33,6 +34,10 @@
 
   // Gets the connection manager object.
   virtual ConnectionManager* GetConnectionManager() = 0;
+
+  // Sets or gets the Metrics Library interface for reporting UMA stats.
+  virtual void set_metrics_lib(MetricsLibraryInterface* metrics_lib) = 0;
+  virtual MetricsLibraryInterface* metrics_lib() = 0;
 };
 
 // A real implementation of the SystemStateInterface which is
@@ -50,6 +55,9 @@
 
   virtual ConnectionManager* GetConnectionManager();
 
+  virtual void set_metrics_lib(MetricsLibraryInterface* metrics_lib);
+  virtual MetricsLibraryInterface* metrics_lib();
+
 private:
   // The latest device policy object from the policy provider.
   const policy::DevicePolicy* device_policy_;
@@ -57,6 +65,9 @@
   // The connection manager object that makes download
   // decisions depending on the current type of connection.
   ConnectionManager connection_manager_;
+
+  // The Metrics Library interface for reporting UMA stats.
+  MetricsLibraryInterface* metrics_lib_;
 };
 
 }  // namespace chromeos_update_engine