Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Unified Diff: components/previews/previews_data_savings.cc

Issue 2256603005: Adding UMA to PreviewsDataSavings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_savings_comp
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/previews/BUILD.gn ('k') | components/previews/previews_data_savings_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/previews/previews_data_savings.cc
diff --git a/components/previews/previews_data_savings.cc b/components/previews/previews_data_savings.cc
index 36cfab85087e72a5329e58fcf06442296dd59f9e..b2b6ff307df7d01dd5ae8477b5a565900f1c68d0 100644
--- a/components/previews/previews_data_savings.cc
+++ b/components/previews/previews_data_savings.cc
@@ -19,15 +19,53 @@ PreviewsDataSavings::PreviewsDataSavings(
PreviewsDataSavings::~PreviewsDataSavings() {
DCHECK(thread_checker_.CalledOnValidThread());
}
void PreviewsDataSavings::RecordDataSavings(
const std::string& fully_qualified_domain_name,
int64_t data_used,
int64_t original_size) {
DCHECK(thread_checker_.CalledOnValidThread());
- data_savings_recorder_->UpdateDataSavings(fully_qualified_domain_name,
- data_used, original_size);
+ // Only record savings when data saver is enabled.
+ if (!data_savings_recorder_->UpdateDataSavings(fully_qualified_domain_name,
+ data_used, original_size)) {
+ // Record metrics in KB for previews with data saver disabled.
+ UMA_HISTOGRAM_COUNTS("Previews.OriginalContentLength.DataSaverDisabled",
+ original_size >> 10);
+ UMA_HISTOGRAM_COUNTS("Previews.ContentLength.DataSaverDisabled",
+ data_used >> 10);
+ if (original_size >= data_used) {
+ UMA_HISTOGRAM_COUNTS("Previews.DataSavings.DataSaverDisabled",
rkaplow 2016/09/09 13:24:02 just want you to verify the default max for this m
+ (original_size - data_used) >> 10);
+ UMA_HISTOGRAM_PERCENTAGE(
+ "Previews.DataSavingsPercent.DataSaverDisabled",
+ (original_size - data_used) * 100 / original_size);
+ } else {
+ UMA_HISTOGRAM_COUNTS("Previews.DataInflation.DataSaverDisabled",
+ (data_used - original_size) >> 10);
+ UMA_HISTOGRAM_PERCENTAGE(
+ "Previews.DataInflationPercent.DataSaverDisabled",
+ (data_used - original_size) * 100 / data_used);
+ }
+ return;
+ }
+
+ // Record metrics in KB for previews with data saver enabled.
+ UMA_HISTOGRAM_COUNTS("Previews.OriginalContentLength.DataSaverEnabled",
+ original_size >> 10);
+ UMA_HISTOGRAM_COUNTS("Previews.ContentLength.DataSaverEnabled",
+ data_used >> 10);
+ if (original_size >= data_used) {
+ UMA_HISTOGRAM_COUNTS("Previews.DataSavings.DataSaverEnabled",
+ (original_size - data_used) >> 10);
+ UMA_HISTOGRAM_PERCENTAGE("Previews.DataSavingsPercent.DataSaverEnabled",
+ (original_size - data_used) * 100 / original_size);
+ } else {
+ UMA_HISTOGRAM_COUNTS("Previews.DataInflation.DataSaverEnabled",
+ (data_used - original_size) >> 10);
+ UMA_HISTOGRAM_PERCENTAGE("Previews.DataInflationPercent.DataSaverEnabled",
+ (data_used - original_size) * 100 / data_used);
+ }
}
} // namespace previews
« no previous file with comments | « components/previews/BUILD.gn ('k') | components/previews/previews_data_savings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698