Index: components/offline_pages/core/background/request_coordinator.cc |
diff --git a/components/offline_pages/core/background/request_coordinator.cc b/components/offline_pages/core/background/request_coordinator.cc |
index 5370b1c6c61b7adfeb28e57e3b8873ac0500ea2f..8060d6af4ab0678672c381b76ee821aabf821870 100644 |
--- a/components/offline_pages/core/background/request_coordinator.cc |
+++ b/components/offline_pages/core/background/request_coordinator.cc |
@@ -44,7 +44,7 @@ std::string AddHistogramSuffix(const ClientId& client_id, |
return adjusted_histogram_name; |
} |
-// Records the final request status UMA for an offlining request. This should |
+// Records the request status UMA for an offlining request. This should |
// only be called once per Offliner::LoadAndSave request. |
void RecordOfflinerResultUMA(const ClientId& client_id, |
const base::Time& request_creation_time, |
@@ -73,6 +73,27 @@ void RecordOfflinerResultUMA(const ClientId& client_id, |
} |
} |
+// Records final request status UMA for an offlining request. This should only |
+// be called once per Offliner::LoadAndSave request. Every Offliner::LoadAndSave |
+// request should also call this once. |
+void RecordSavePageResultUMA( |
+ const ClientId& client_id, |
+ RequestNotifier::BackgroundSavePageResult request_status) { |
+ // The histogram below is an expansion of the UMA_HISTOGRAM_ENUMERATION |
+ // macro adapted to allow for a dynamically suffixed histogram name. |
+ // Note: The factory creates and owns the histogram. |
+ base::HistogramBase* histogram = base::LinearHistogram::FactoryGet( |
+ AddHistogramSuffix(client_id, |
+ "OfflinePages.Background.FinalSavePageResult"), |
+ 1, |
+ static_cast<int>(RequestNotifier::BackgroundSavePageResult::STATUS_COUNT), |
+ static_cast<int>( |
+ RequestNotifier::BackgroundSavePageResult::STATUS_COUNT) + |
+ 1, |
+ base::HistogramBase::kUmaTargetedHistogramFlag); |
+ histogram->Add(static_cast<int>(request_status)); |
+} |
+ |
void RecordStartTimeUMA(const SavePageRequest& request) { |
std::string histogram_name("OfflinePages.Background.TimeToStart"); |
if (base::SysInfo::IsLowEndDevice()) { |
@@ -1079,6 +1100,7 @@ void RequestCoordinator::NotifyAdded(const SavePageRequest& request) { |
void RequestCoordinator::NotifyCompleted( |
const SavePageRequest& request, |
RequestNotifier::BackgroundSavePageResult status) { |
+ RecordSavePageResultUMA(request.client_id(), status); |
for (Observer& observer : observers_) |
observer.OnCompleted(request, status); |
} |