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_netw
ork_delegate.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/testing_pref_service.h" | 11 #include "base/prefs/testing_pref_service.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/test/histogram_tester.h" | 13 #include "base/test/histogram_tester.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" | 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" |
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metr
ics.h" | 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metr
ics.h" |
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ
est_options.h" | 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ
est_options.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_heade
rs_test_utils.h" | 20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs_test_utils.h" |
21 #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_param
s_test_utils.h" |
22 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" | 22 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" |
23 #include "net/base/capturing_net_log.h" | 23 #include "net/base/capturing_net_log.h" |
24 #include "net/base/host_port_pair.h" | 24 #include "net/base/host_port_pair.h" |
25 #include "net/base/load_flags.h" | 25 #include "net/base/load_flags.h" |
26 #include "net/base/net_log.h" | 26 #include "net/base/net_log.h" |
27 #include "net/http/http_response_headers.h" | 27 #include "net/http/http_response_headers.h" |
28 #include "net/proxy/proxy_config.h" | 28 #include "net/proxy/proxy_config.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 144 } |
145 | 145 |
146 TestingPrefServiceSimple* pref_service() const { | 146 TestingPrefServiceSimple* pref_service() const { |
147 return test_context_->pref_service(); | 147 return test_context_->pref_service(); |
148 } | 148 } |
149 | 149 |
150 TestDataReductionProxyConfig* config() { | 150 TestDataReductionProxyConfig* config() { |
151 return test_context_->config(); | 151 return test_context_->config(); |
152 } | 152 } |
153 | 153 |
154 DataReductionProxyStatisticsPrefs* statistics_prefs() const { | 154 DataReductionProxyCompressionStats* compression_stats() const { |
155 return test_context_->data_reduction_proxy_service()->statistics_prefs(); | 155 return test_context_->data_reduction_proxy_service()->compression_stats(); |
156 } | 156 } |
157 | 157 |
158 scoped_ptr<DataReductionProxyNetworkDelegate> | 158 scoped_ptr<DataReductionProxyNetworkDelegate> |
159 data_reduction_proxy_network_delegate_; | 159 data_reduction_proxy_network_delegate_; |
160 | 160 |
161 private: | 161 private: |
162 net::TestURLRequestContext context_; | 162 net::TestURLRequestContext context_; |
163 net::TestDelegate delegate_; | 163 net::TestDelegate delegate_; |
164 // |test_job_interceptor_| is owned by |test_job_factory_|. | 164 // |test_job_interceptor_| is owned by |test_job_factory_|. |
165 net::TestJobInterceptor* test_job_interceptor_; | 165 net::TestJobInterceptor* test_job_interceptor_; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 data_reduction_proxy_network_delegate_->data_reduction_proxy_io_data_ = | 418 data_reduction_proxy_network_delegate_->data_reduction_proxy_io_data_ = |
419 io_data(); | 419 io_data(); |
420 | 420 |
421 data_reduction_proxy_network_delegate_->UpdateContentLengthPrefs( | 421 data_reduction_proxy_network_delegate_->UpdateContentLengthPrefs( |
422 kReceivedLength, kOriginalLength, | 422 kReceivedLength, kOriginalLength, |
423 pref_service()->GetBoolean( | 423 pref_service()->GetBoolean( |
424 data_reduction_proxy::prefs::kDataReductionProxyEnabled), | 424 data_reduction_proxy::prefs::kDataReductionProxyEnabled), |
425 UNKNOWN_TYPE); | 425 UNKNOWN_TYPE); |
426 | 426 |
427 EXPECT_EQ(kReceivedLength, | 427 EXPECT_EQ(kReceivedLength, |
428 statistics_prefs()->GetInt64( | 428 compression_stats()->GetInt64( |
429 data_reduction_proxy::prefs::kHttpReceivedContentLength)); | 429 data_reduction_proxy::prefs::kHttpReceivedContentLength)); |
430 EXPECT_FALSE(pref_service()->GetBoolean( | 430 EXPECT_FALSE(pref_service()->GetBoolean( |
431 data_reduction_proxy::prefs::kDataReductionProxyEnabled)); | 431 data_reduction_proxy::prefs::kDataReductionProxyEnabled)); |
432 EXPECT_EQ(kOriginalLength, | 432 EXPECT_EQ(kOriginalLength, |
433 statistics_prefs()->GetInt64( | 433 compression_stats()->GetInt64( |
434 data_reduction_proxy::prefs::kHttpOriginalContentLength)); | 434 data_reduction_proxy::prefs::kHttpOriginalContentLength)); |
435 | 435 |
436 // Record the same numbers again, and total lengths should be doubled. | 436 // Record the same numbers again, and total lengths should be doubled. |
437 data_reduction_proxy_network_delegate_->UpdateContentLengthPrefs( | 437 data_reduction_proxy_network_delegate_->UpdateContentLengthPrefs( |
438 kReceivedLength, kOriginalLength, | 438 kReceivedLength, kOriginalLength, |
439 pref_service()->GetBoolean( | 439 pref_service()->GetBoolean( |
440 data_reduction_proxy::prefs::kDataReductionProxyEnabled), | 440 data_reduction_proxy::prefs::kDataReductionProxyEnabled), |
441 UNKNOWN_TYPE); | 441 UNKNOWN_TYPE); |
442 | 442 |
443 EXPECT_EQ(kReceivedLength * 2, | 443 EXPECT_EQ(kReceivedLength * 2, |
444 statistics_prefs()->GetInt64( | 444 compression_stats()->GetInt64( |
445 data_reduction_proxy::prefs::kHttpReceivedContentLength)); | 445 data_reduction_proxy::prefs::kHttpReceivedContentLength)); |
446 EXPECT_FALSE(pref_service()->GetBoolean( | 446 EXPECT_FALSE(pref_service()->GetBoolean( |
447 data_reduction_proxy::prefs::kDataReductionProxyEnabled)); | 447 data_reduction_proxy::prefs::kDataReductionProxyEnabled)); |
448 EXPECT_EQ(kOriginalLength * 2, | 448 EXPECT_EQ(kOriginalLength * 2, |
449 statistics_prefs()->GetInt64( | 449 compression_stats()->GetInt64( |
450 data_reduction_proxy::prefs::kHttpOriginalContentLength)); | 450 data_reduction_proxy::prefs::kHttpOriginalContentLength)); |
451 } | 451 } |
452 | 452 |
453 } // namespace data_reduction_proxy | 453 } // namespace data_reduction_proxy |
OLD | NEW |