| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/data_reduction_proxy/core/browser/data_reduction_proxy_metr
ics.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metr
ics.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/prefs/testing_pref_service.h" | 13 #include "base/prefs/testing_pref_service.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/test/test_simple_task_runner.h" | 15 #include "base/test/test_simple_task_runner.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
| 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" | 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" |
| 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" | |
| 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" |
| 20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s_test_utils.h" | 20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s_test_utils.h" |
| 21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" | 21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" |
| 22 #include "net/base/load_flags.h" | 22 #include "net/base/load_flags.h" |
| 23 #include "net/base/net_log.h" | 23 #include "net/base/net_log.h" |
| 24 #include "net/proxy/proxy_server.h" | 24 #include "net/proxy/proxy_server.h" |
| 25 #include "net/proxy/proxy_service.h" | 25 #include "net/proxy/proxy_service.h" |
| 26 #include "net/socket/socket_test_util.h" | 26 #include "net/socket/socket_test_util.h" |
| 27 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
| 28 #include "net/url_request/url_request_test_util.h" | 28 #include "net/url_request/url_request_test_util.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 namespace data_reduction_proxy { | 47 namespace data_reduction_proxy { |
| 48 | 48 |
| 49 // Test UpdateContentLengthPrefs. | 49 // Test UpdateContentLengthPrefs. |
| 50 class ChromeNetworkDataSavingMetricsTest : public testing::Test { | 50 class ChromeNetworkDataSavingMetricsTest : public testing::Test { |
| 51 protected: | 51 protected: |
| 52 ChromeNetworkDataSavingMetricsTest() {} | 52 ChromeNetworkDataSavingMetricsTest() {} |
| 53 | 53 |
| 54 void SetUp() override { | 54 void SetUp() override { |
| 55 statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( | 55 statistics_prefs_.reset(new DataReductionProxyCompressionStats( |
| 56 &pref_service_, | 56 &pref_service_, |
| 57 scoped_refptr<base::TestSimpleTaskRunner>( | 57 scoped_refptr<base::TestSimpleTaskRunner>( |
| 58 new base::TestSimpleTaskRunner()), | 58 new base::TestSimpleTaskRunner()), |
| 59 base::TimeDelta())); | 59 base::TimeDelta())); |
| 60 PrefRegistrySimple* registry = pref_service_.registry(); | 60 PrefRegistrySimple* registry = pref_service_.registry(); |
| 61 registry->RegisterInt64Pref( | 61 registry->RegisterInt64Pref( |
| 62 data_reduction_proxy::prefs::kHttpReceivedContentLength, 0); | 62 data_reduction_proxy::prefs::kHttpReceivedContentLength, 0); |
| 63 registry->RegisterInt64Pref( | 63 registry->RegisterInt64Pref( |
| 64 data_reduction_proxy::prefs::kHttpOriginalContentLength, 0); | 64 data_reduction_proxy::prefs::kHttpOriginalContentLength, 0); |
| 65 | 65 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 92 data_reduction_proxy::prefs:: | 92 data_reduction_proxy::prefs:: |
| 93 kDailyContentLengthViaDataReductionProxy); | 93 kDailyContentLengthViaDataReductionProxy); |
| 94 registry->RegisterInt64Pref( | 94 registry->RegisterInt64Pref( |
| 95 data_reduction_proxy::prefs:: | 95 data_reduction_proxy::prefs:: |
| 96 kDailyHttpContentLengthLastUpdateDate, 0L); | 96 kDailyHttpContentLengthLastUpdateDate, 0L); |
| 97 registry->RegisterBooleanPref( | 97 registry->RegisterBooleanPref( |
| 98 data_reduction_proxy::prefs::kDataReductionProxyEnabled, false); | 98 data_reduction_proxy::prefs::kDataReductionProxyEnabled, false); |
| 99 } | 99 } |
| 100 | 100 |
| 101 TestingPrefServiceSimple pref_service_; | 101 TestingPrefServiceSimple pref_service_; |
| 102 scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs_; | 102 scoped_ptr<DataReductionProxyCompressionStats> statistics_prefs_; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 // The initial last update time used in test. There is no leap second a few | 105 // The initial last update time used in test. There is no leap second a few |
| 106 // days around this time used in the test. | 106 // days around this time used in the test. |
| 107 // Note: No time zone is specified. Local time will be assumed by | 107 // Note: No time zone is specified. Local time will be assumed by |
| 108 // base::Time::FromString below. | 108 // base::Time::FromString below. |
| 109 const char kLastUpdateTime[] = "Wed, 18 Sep 2013 03:45:26"; | 109 const char kLastUpdateTime[] = "Wed, 18 Sep 2013 03:45:26"; |
| 110 | 110 |
| 111 class ChromeNetworkDailyDataSavingMetricsTest | 111 class ChromeNetworkDailyDataSavingMetricsTest |
| 112 : public ChromeNetworkDataSavingMetricsTest { | 112 : public ChromeNetworkDataSavingMetricsTest { |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 } | 801 } |
| 802 | 802 |
| 803 EXPECT_EQ(test_case.expected_request_type, | 803 EXPECT_EQ(test_case.expected_request_type, |
| 804 GetDataReductionProxyRequestType( | 804 GetDataReductionProxyRequestType( |
| 805 *request, data_reduction_proxy_config, | 805 *request, data_reduction_proxy_config, |
| 806 *test_context->config())); | 806 *test_context->config())); |
| 807 } | 807 } |
| 808 } | 808 } |
| 809 | 809 |
| 810 } // namespace data_reduction_proxy | 810 } // namespace data_reduction_proxy |
| OLD | NEW |