Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics_unittest.cc |
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics_unittest.cc |
index 87df9bfe20913c4014426d3f395b20ea81fe4bd8..429174c4ea8676145b9680a64b720f0cfd701398 100644 |
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics_unittest.cc |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics_unittest.cc |
@@ -14,8 +14,8 @@ |
#include "base/strings/string_number_conversions.h" |
#include "base/test/test_simple_task_runner.h" |
#include "base/time/time.h" |
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h" |
-#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h" |
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params_test_utils.h" |
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h" |
@@ -52,10 +52,9 @@ class ChromeNetworkDataSavingMetricsTest : public testing::Test { |
ChromeNetworkDataSavingMetricsTest() {} |
void SetUp() override { |
- statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( |
- &pref_service_, |
- scoped_refptr<base::TestSimpleTaskRunner>( |
- new base::TestSimpleTaskRunner()), |
+ compression_stats_.reset(new DataReductionProxyCompressionStats( |
+ &pref_service_, scoped_refptr<base::TestSimpleTaskRunner>( |
+ new base::TestSimpleTaskRunner()), |
base::TimeDelta())); |
PrefRegistrySimple* registry = pref_service_.registry(); |
registry->RegisterInt64Pref( |
@@ -99,7 +98,7 @@ class ChromeNetworkDataSavingMetricsTest : public testing::Test { |
} |
TestingPrefServiceSimple pref_service_; |
- scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs_; |
+ scoped_ptr<DataReductionProxyCompressionStats> compression_stats_; |
}; |
// The initial last update time used in test. There is no leap second a few |
@@ -139,7 +138,7 @@ class ChromeNetworkDailyDataSavingMetricsTest |
// Create daily pref list of |kNumDaysInHistory| zero values. |
void CreatePrefList(const char* pref) { |
- base::ListValue* update = statistics_prefs_->GetList(pref); |
+ base::ListValue* update = compression_stats_->GetList(pref); |
update->Clear(); |
for (size_t i = 0; i < kNumDaysInHistory; ++i) { |
update->Insert(0, new base::StringValue(base::Int64ToString(0))); |
@@ -151,7 +150,7 @@ class ChromeNetworkDailyDataSavingMetricsTest |
// at the beginning. |
void VerifyPrefList(const char* pref, const int64* values, size_t count) { |
ASSERT_GE(kNumDaysInHistory, count); |
- base::ListValue* update = statistics_prefs_->GetList(pref); |
+ base::ListValue* update = compression_stats_->GetList(pref); |
ASSERT_EQ(kNumDaysInHistory, update->GetSize()) << "Pref: " << pref; |
for (size_t i = 0; i < count; ++i) { |
@@ -267,9 +266,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, OneResponse) { |
int64 received[] = {kReceivedLength}; |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
VerifyDailyDataSavingContentLengthPrefLists( |
original, 1, received, 1, |
original, 1, received, 1, |
@@ -282,17 +280,15 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) { |
int64 original[] = {kOriginalLength}; |
int64 received[] = {kReceivedLength}; |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- false, UNKNOWN_TYPE, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, false, UNKNOWN_TYPE, FakeNow(), |
+ compression_stats_.get()); |
VerifyDailyDataSavingContentLengthPrefLists( |
original, 1, received, 1, |
NULL, 0, NULL, 0, NULL, 0, NULL, 0); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, UNKNOWN_TYPE, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, UNKNOWN_TYPE, FakeNow(), |
+ compression_stats_.get()); |
original[0] += kOriginalLength; |
received[0] += kReceivedLength; |
int64 original_proxy_enabled[] = {kOriginalLength}; |
@@ -303,9 +299,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) { |
NULL, 0, NULL, 0); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
original[0] += kOriginalLength; |
received[0] += kReceivedLength; |
original_proxy_enabled[0] += kOriginalLength; |
@@ -318,8 +313,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) { |
original_via_proxy, 1, received_via_proxy, 1); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, UNKNOWN_TYPE, FakeNow(), |
+ compression_stats_.get()); |
original[0] += kOriginalLength; |
received[0] += kReceivedLength; |
original_proxy_enabled[0] += kOriginalLength; |
@@ -330,8 +325,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) { |
original_via_proxy, 1, received_via_proxy, 1); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- false, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, false, UNKNOWN_TYPE, FakeNow(), |
+ compression_stats_.get()); |
original[0] += kOriginalLength; |
received[0] += kReceivedLength; |
VerifyDailyDataSavingContentLengthPrefLists( |
@@ -347,10 +342,9 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { |
int64 total_received[] = {0}; |
int64 proxy_enabled_received[] = {0}; |
- UpdateContentLengthPrefsForDataReductionProxy( |
- kContentLength, kContentLength, |
- true, HTTPS, |
- FakeNow(), statistics_prefs_.get()); |
+ UpdateContentLengthPrefsForDataReductionProxy(kContentLength, kContentLength, |
+ true, HTTPS, FakeNow(), |
+ compression_stats_.get()); |
total_received[0] += kContentLength; |
proxy_enabled_received[0] += kContentLength; |
https_received[0] += kContentLength; |
@@ -363,10 +357,9 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { |
received, 0); // unknown |
// Data reduction proxy is not enabled. |
- UpdateContentLengthPrefsForDataReductionProxy( |
- kContentLength, kContentLength, |
- false, HTTPS, |
- FakeNow(), statistics_prefs_.get()); |
+ UpdateContentLengthPrefsForDataReductionProxy(kContentLength, kContentLength, |
+ false, HTTPS, FakeNow(), |
+ compression_stats_.get()); |
total_received[0] += kContentLength; |
VerifyDailyRequestTypeContentLengthPrefLists( |
total_received, 1, total_received, 1, |
@@ -376,10 +369,9 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { |
received, 0, // long bypass |
received, 0); // unknown |
- UpdateContentLengthPrefsForDataReductionProxy( |
- kContentLength, kContentLength, |
- true, HTTPS, |
- FakeNow(), statistics_prefs_.get()); |
+ UpdateContentLengthPrefsForDataReductionProxy(kContentLength, kContentLength, |
+ true, HTTPS, FakeNow(), |
+ compression_stats_.get()); |
total_received[0] += kContentLength; |
proxy_enabled_received[0] += kContentLength; |
https_received[0] += kContentLength; |
@@ -391,10 +383,9 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { |
received, 0, // long bypass |
received, 0); // unknown |
- UpdateContentLengthPrefsForDataReductionProxy( |
- kContentLength, kContentLength, |
- true, SHORT_BYPASS, |
- FakeNow(), statistics_prefs_.get()); |
+ UpdateContentLengthPrefsForDataReductionProxy(kContentLength, kContentLength, |
+ true, SHORT_BYPASS, FakeNow(), |
+ compression_stats_.get()); |
total_received[0] += kContentLength; |
proxy_enabled_received[0] += kContentLength; |
received[0] += kContentLength; |
@@ -406,10 +397,9 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { |
received, 0, // long bypass |
received, 0); // unknown |
- UpdateContentLengthPrefsForDataReductionProxy( |
- kContentLength, kContentLength, |
- true, LONG_BYPASS, |
- FakeNow(), statistics_prefs_.get()); |
+ UpdateContentLengthPrefsForDataReductionProxy(kContentLength, kContentLength, |
+ true, LONG_BYPASS, FakeNow(), |
+ compression_stats_.get()); |
total_received[0] += kContentLength; |
proxy_enabled_received[0] += kContentLength; |
VerifyDailyRequestTypeContentLengthPrefLists( |
@@ -420,10 +410,9 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { |
received, 1, // long bypass |
received, 0); // unknown |
- UpdateContentLengthPrefsForDataReductionProxy( |
- kContentLength, kContentLength, |
- true, UNKNOWN_TYPE, |
- FakeNow(), statistics_prefs_.get()); |
+ UpdateContentLengthPrefsForDataReductionProxy(kContentLength, kContentLength, |
+ true, UNKNOWN_TYPE, FakeNow(), |
+ compression_stats_.get()); |
total_received[0] += kContentLength; |
proxy_enabled_received[0] += kContentLength; |
VerifyDailyRequestTypeContentLengthPrefLists( |
@@ -440,17 +429,16 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) { |
const int64 kReceivedLength = 100; |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
// Forward one day. |
SetFakeTimeDeltaInHours(24); |
// Proxy not enabled. Not via proxy. |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- false, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, false, UNKNOWN_TYPE, FakeNow(), |
+ compression_stats_.get()); |
int64 original[] = {kOriginalLength, kOriginalLength}; |
int64 received[] = {kReceivedLength, kReceivedLength}; |
@@ -468,8 +456,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) { |
// Proxy enabled. Not via proxy. |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, UNKNOWN_TYPE, FakeNow(), |
+ compression_stats_.get()); |
original[1] += kOriginalLength; |
received[1] += kReceivedLength; |
original_with_data_reduction_proxy_enabled[1] += kOriginalLength; |
@@ -484,9 +472,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) { |
// Proxy enabled and via proxy. |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
original[1] += kOriginalLength; |
received[1] += kReceivedLength; |
original_with_data_reduction_proxy_enabled[1] += kOriginalLength; |
@@ -509,9 +496,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, PartialDayTimeChange) { |
int64 received[] = {0, kReceivedLength}; |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
VerifyDailyDataSavingContentLengthPrefLists( |
original, 2, received, 2, |
original, 2, received, 2, |
@@ -521,9 +507,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, PartialDayTimeChange) { |
// See kLastUpdateTime: "Now" in test is 03:45am. |
SetFakeTimeDeltaInHours(10); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
original[1] += kOriginalLength; |
received[1] += kReceivedLength; |
VerifyDailyDataSavingContentLengthPrefLists( |
@@ -534,9 +519,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, PartialDayTimeChange) { |
// Forward 11 more hours, comes to tomorrow. |
AddFakeTimeDeltaInHours(11); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
int64 original2[] = {kOriginalLength * 2, kOriginalLength}; |
int64 received2[] = {kReceivedLength * 2, kReceivedLength}; |
VerifyDailyDataSavingContentLengthPrefLists( |
@@ -549,17 +533,15 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) { |
const int64 kOriginalLength = 200; |
const int64 kReceivedLength = 100; |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
// Forward three days. |
SetFakeTimeDeltaInHours(3 * 24); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
int64 original[] = {kOriginalLength, 0, 0, kOriginalLength}; |
int64 received[] = {kReceivedLength, 0, 0, kReceivedLength}; |
@@ -571,9 +553,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) { |
// Forward four more days. |
AddFakeTimeDeltaInHours(4 * 24); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
int64 original2[] = { |
kOriginalLength, 0, 0, kOriginalLength, 0, 0, 0, kOriginalLength, |
}; |
@@ -588,9 +569,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) { |
// Forward |kNumDaysInHistory| more days. |
AddFakeTimeDeltaInHours(kNumDaysInHistory * 24); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
int64 original3[] = {kOriginalLength}; |
int64 received3[] = {kReceivedLength}; |
VerifyDailyDataSavingContentLengthPrefLists( |
@@ -601,9 +581,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) { |
// Forward |kNumDaysInHistory| + 1 more days. |
AddFakeTimeDeltaInHours((kNumDaysInHistory + 1)* 24); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
VerifyDailyDataSavingContentLengthPrefLists( |
original3, 1, received3, 1, |
original3, 1, received3, 1, |
@@ -617,16 +596,14 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardAndForwardOneDay) { |
int64 received[] = {kReceivedLength}; |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
// Backward one day. |
SetFakeTimeDeltaInHours(-24); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
original[0] += kOriginalLength; |
received[0] += kReceivedLength; |
VerifyDailyDataSavingContentLengthPrefLists( |
@@ -637,9 +614,8 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardAndForwardOneDay) { |
// Then, Forward one day |
AddFakeTimeDeltaInHours(24); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
int64 original2[] = {kOriginalLength * 2, kOriginalLength}; |
int64 received2[] = {kReceivedLength * 2, kReceivedLength}; |
VerifyDailyDataSavingContentLengthPrefLists( |
@@ -655,15 +631,13 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardTwoDays) { |
int64 received[] = {kReceivedLength}; |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
// Backward two days. |
SetFakeTimeDeltaInHours(-2 * 24); |
UpdateContentLengthPrefsForDataReductionProxy( |
- kReceivedLength, kOriginalLength, |
- true, VIA_DATA_REDUCTION_PROXY, |
- FakeNow(), statistics_prefs_.get()); |
+ kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
+ FakeNow(), compression_stats_.get()); |
VerifyDailyDataSavingContentLengthPrefLists( |
original, 1, received, 1, |
original, 1, received, 1, |