metrics: Add UpdateEngine.Rollback.Result metric.

Add a metric to track if rollback succeeds or fails. The main use case
for this metric is to record how often rollback actually happens.

Right now we only track success/failure but if we see a lot of
failures in the future, we could add a new metric, for example

 UpdateEngine.Rollback.FailureErrorCode

to convey more detail.

BUG=None
TEST=New unit test + unit tests pass.

Change-Id: I5c32d8585dc8e4b6d38c540d2f754ede5b2ad50b
Reviewed-on: https://chromium-review.googlesource.com/195203
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
diff --git a/metrics.h b/metrics.h
index b5dd5f1..99d1e5e 100644
--- a/metrics.h
+++ b/metrics.h
@@ -56,6 +56,9 @@
 extern const char kMetricSuccessfulUpdateUpdatesAbandonedCount[];
 extern const char kMetricSuccessfulUpdateUrlSwitchCount[];
 
+// UpdateEngine.Rollback.* metric.
+extern const char kMetricRollbackResult[];
+
 // UpdateEngine.* metrics.
 extern const char kMetricFailedUpdateCount[];
 extern const char kMetricInstallDateProvisioningSource[];
@@ -158,6 +161,23 @@
   kUnset = -1
 };
 
+// Possible ways a rollback can end.
+//
+// This is used in the UpdateEngine.Rollback histogram.
+enum class RollbackResult {
+  kFailed,
+  kSuccess,
+
+  kNumConstants
+};
+
+// Helper function to report metrics related to rollback. The
+// following metrics are reported:
+//
+//  |kMetricRollbackResult|
+void ReportRollbackMetrics(SystemState *system_state,
+                           RollbackResult result);
+
 // Helper function to report metrics reported once a day. The
 // following metrics are reported:
 //