UMA log all reasons for error::UNAVAILABLE.

This change UMA logs every location in browser enterprise reporting code
where we return error::UNAVAILABLE. We do this using an enum that
closely resembles the specific error message so that we know exactly
where most of our errors are coming from.

Change-Id: I21c9bd837d3885524ab394b573cc331be85f94e2
Bug: b:341169924
Low-Coverage-Reason: TRIVIAL_CHANGE Just adding UMA log statments.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5548659
Reviewed-by: Leonid Baraz <[email protected]>
Reviewed-by: Calder Kitagawa <[email protected]>
Commit-Queue: Josh Hilke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1304733}
diff --git a/components/reporting/client/report_queue_impl.cc b/components/reporting/client/report_queue_impl.cc
index 898278c..f7be577 100644
--- a/components/reporting/client/report_queue_impl.cc
+++ b/components/reporting/client/report_queue_impl.cc
@@ -35,6 +35,7 @@
 #include "components/reporting/proto/synced/record.pb.h"
 #include "components/reporting/proto/synced/record_constants.pb.h"
 #include "components/reporting/storage/storage_module_interface.h"
+#include "components/reporting/util/reporting_errors.h"
 #include "components/reporting/util/status.h"
 #include "components/reporting/util/statusor.h"
 
@@ -318,6 +319,10 @@
             if (!self) {
               std::move(callback).Run(
                   Status(error::UNAVAILABLE, "Queue has been destructed"));
+              base::UmaHistogramEnumeration(
+                  reporting::kUmaUnavailableErrorReason,
+                  UnavailableErrorReason::REPORT_QUEUE_DESTRUCTED,
+                  UnavailableErrorReason::MAX_VALUE);
               return;
             }
             DCHECK_CALLED_ON_VALID_SEQUENCE(self->sequence_checker_);
@@ -404,6 +409,10 @@
                 if (!self) {
                   std::move(callback).Run(
                       Status(error::UNAVAILABLE, "Queue has been destructed"));
+                  base::UmaHistogramEnumeration(
+                      reporting::kUmaUnavailableErrorReason,
+                      UnavailableErrorReason::REPORT_QUEUE_DESTRUCTED,
+                      UnavailableErrorReason::MAX_VALUE);
                   return;
                 }
                 std::move(callback).Run(status);