OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/previews/previews_data_savings.h" | 5 #include "components/previews/previews_data_savings.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "components/data_reduction_proxy/core/common/data_savings_recorder.h" | 9 #include "components/data_reduction_proxy/core/common/data_savings_recorder.h" |
10 | 10 |
11 namespace previews { | 11 namespace previews { |
12 | 12 |
13 PreviewsDataSavings::PreviewsDataSavings( | 13 PreviewsDataSavings::PreviewsDataSavings( |
14 data_reduction_proxy::DataSavingsRecorder* data_savings_recorder) | 14 data_reduction_proxy::DataSavingsRecorder* data_savings_recorder) |
15 : data_savings_recorder_(data_savings_recorder) { | 15 : data_savings_recorder_(data_savings_recorder) { |
16 DCHECK(data_savings_recorder); | 16 DCHECK(data_savings_recorder); |
17 } | 17 } |
18 | 18 |
19 PreviewsDataSavings::~PreviewsDataSavings() { | 19 PreviewsDataSavings::~PreviewsDataSavings() { |
20 DCHECK(thread_checker_.CalledOnValidThread()); | 20 DCHECK(thread_checker_.CalledOnValidThread()); |
21 } | 21 } |
22 | 22 |
23 void PreviewsDataSavings::RecordDataSavings( | 23 void PreviewsDataSavings::RecordDataSavings( |
24 const std::string& fully_qualified_domain_name, | 24 const std::string& fully_qualified_domain_name, |
25 int64_t data_used, | 25 int64_t data_used, |
26 int64_t original_size) { | 26 int64_t original_size) { |
27 DCHECK(thread_checker_.CalledOnValidThread()); | 27 DCHECK(thread_checker_.CalledOnValidThread()); |
28 | 28 |
29 data_savings_recorder_->UpdateDataSavings(fully_qualified_domain_name, | 29 // Only record savings when data saver is enabled. |
30 data_used, original_size); | 30 if (!data_savings_recorder_->UpdateDataSavings(fully_qualified_domain_name, |
31 data_used, original_size)) { | |
32 // Record metrics in KB for previews with data saver disabled. | |
33 UMA_HISTOGRAM_COUNTS("Previews.OriginalContentLength.DataSaverDisabled", | |
34 original_size >> 10); | |
35 UMA_HISTOGRAM_COUNTS("Previews.ContentLength.DataSaverDisabled", | |
36 data_used >> 10); | |
37 if (original_size >= data_used) { | |
38 UMA_HISTOGRAM_COUNTS("Previews.DataSavings.DataSaverDisabled", | |
rkaplow
2016/09/09 13:24:02
just want you to verify the default max for this m
| |
39 (original_size - data_used) >> 10); | |
40 UMA_HISTOGRAM_PERCENTAGE( | |
41 "Previews.DataSavingsPercent.DataSaverDisabled", | |
42 (original_size - data_used) * 100 / original_size); | |
43 } else { | |
44 UMA_HISTOGRAM_COUNTS("Previews.DataInflation.DataSaverDisabled", | |
45 (data_used - original_size) >> 10); | |
46 UMA_HISTOGRAM_PERCENTAGE( | |
47 "Previews.DataInflationPercent.DataSaverDisabled", | |
48 (data_used - original_size) * 100 / data_used); | |
49 } | |
50 return; | |
51 } | |
52 | |
53 // Record metrics in KB for previews with data saver enabled. | |
54 UMA_HISTOGRAM_COUNTS("Previews.OriginalContentLength.DataSaverEnabled", | |
55 original_size >> 10); | |
56 UMA_HISTOGRAM_COUNTS("Previews.ContentLength.DataSaverEnabled", | |
57 data_used >> 10); | |
58 if (original_size >= data_used) { | |
59 UMA_HISTOGRAM_COUNTS("Previews.DataSavings.DataSaverEnabled", | |
60 (original_size - data_used) >> 10); | |
61 UMA_HISTOGRAM_PERCENTAGE("Previews.DataSavingsPercent.DataSaverEnabled", | |
62 (original_size - data_used) * 100 / original_size); | |
63 } else { | |
64 UMA_HISTOGRAM_COUNTS("Previews.DataInflation.DataSaverEnabled", | |
65 (data_used - original_size) >> 10); | |
66 UMA_HISTOGRAM_PERCENTAGE("Previews.DataInflationPercent.DataSaverEnabled", | |
67 (data_used - original_size) * 100 / data_used); | |
68 } | |
31 } | 69 } |
32 | 70 |
33 } // namespace previews | 71 } // namespace previews |
OLD | NEW |