OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_test
_utils.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/prefs/testing_pref_service.h" | 8 #include "base/prefs/testing_pref_service.h" |
| 9 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
9 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_service_client.h" | 10 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_service_client.h" |
10 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" | 11 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" |
11 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator_test_utils.h" | 12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator_test_utils.h" |
12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte
rceptor.h" | 13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte
rceptor.h" |
13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_muta
ble_config_values.h" | 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_muta
ble_config_values.h" |
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" | 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" |
15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" | 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" |
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" | |
18 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event
_store.h" | 18 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event
_store.h" |
19 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 19 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.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 "net/socket/socket_test_util.h" | 21 #include "net/socket/socket_test_util.h" |
22 #include "net/url_request/url_request_context_storage.h" | 22 #include "net/url_request/url_request_context_storage.h" |
23 #include "net/url_request/url_request_intercepting_job_factory.h" | 23 #include "net/url_request/url_request_intercepting_job_factory.h" |
24 #include "net/url_request/url_request_job_factory_impl.h" | 24 #include "net/url_request/url_request_job_factory_impl.h" |
25 #include "net/url_request/url_request_test_util.h" | 25 #include "net/url_request/url_request_test_util.h" |
26 | 26 |
27 namespace { | 27 namespace { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 tick_clock_(tick_clock) { | 153 tick_clock_(tick_clock) { |
154 } | 154 } |
155 | 155 |
156 base::TimeTicks | 156 base::TimeTicks |
157 TestDataReductionProxyConfigServiceClient::TestBackoffEntry::ImplGetTimeNow() | 157 TestDataReductionProxyConfigServiceClient::TestBackoffEntry::ImplGetTimeNow() |
158 const { | 158 const { |
159 return tick_clock_->NowTicks(); | 159 return tick_clock_->NowTicks(); |
160 } | 160 } |
161 | 161 |
162 MockDataReductionProxyService::MockDataReductionProxyService( | 162 MockDataReductionProxyService::MockDataReductionProxyService( |
163 scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs, | 163 scoped_ptr<DataReductionProxyCompressionStats> compression_stats, |
164 DataReductionProxySettings* settings, | 164 DataReductionProxySettings* settings, |
165 net::URLRequestContextGetter* request_context) | 165 net::URLRequestContextGetter* request_context) |
166 : DataReductionProxyService( | 166 : DataReductionProxyService( |
167 statistics_prefs.Pass(), settings, request_context) { | 167 compression_stats.Pass(), settings, request_context) { |
168 } | 168 } |
169 | 169 |
170 MockDataReductionProxyService::~MockDataReductionProxyService() { | 170 MockDataReductionProxyService::~MockDataReductionProxyService() { |
171 } | 171 } |
172 | 172 |
173 TestDataReductionProxyIOData::TestDataReductionProxyIOData( | 173 TestDataReductionProxyIOData::TestDataReductionProxyIOData( |
174 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 174 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
175 scoped_ptr<DataReductionProxyConfig> config, | 175 scoped_ptr<DataReductionProxyConfig> config, |
176 scoped_ptr<DataReductionProxyEventStore> event_store, | 176 scoped_ptr<DataReductionProxyEventStore> event_store, |
177 scoped_ptr<DataReductionProxyRequestOptions> request_options, | 177 scoped_ptr<DataReductionProxyRequestOptions> request_options, |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 443 |
444 scoped_ptr<DataReductionProxyService> | 444 scoped_ptr<DataReductionProxyService> |
445 DataReductionProxyTestContext::CreateDataReductionProxyService() { | 445 DataReductionProxyTestContext::CreateDataReductionProxyService() { |
446 DCHECK(test_context_flags_ & | 446 DCHECK(test_context_flags_ & |
447 DataReductionProxyTestContext::SKIP_SETTINGS_INITIALIZATION); | 447 DataReductionProxyTestContext::SKIP_SETTINGS_INITIALIZATION); |
448 return CreateDataReductionProxyServiceInternal(); | 448 return CreateDataReductionProxyServiceInternal(); |
449 } | 449 } |
450 | 450 |
451 scoped_ptr<DataReductionProxyService> | 451 scoped_ptr<DataReductionProxyService> |
452 DataReductionProxyTestContext::CreateDataReductionProxyServiceInternal() { | 452 DataReductionProxyTestContext::CreateDataReductionProxyServiceInternal() { |
453 scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs = | 453 scoped_ptr<DataReductionProxyCompressionStats> compression_stats = |
454 make_scoped_ptr(new DataReductionProxyStatisticsPrefs( | 454 make_scoped_ptr(new DataReductionProxyCompressionStats( |
455 simple_pref_service_.get(), task_runner_, base::TimeDelta())); | 455 simple_pref_service_.get(), task_runner_, base::TimeDelta())); |
456 | 456 |
457 if (test_context_flags_ & DataReductionProxyTestContext::USE_MOCK_SERVICE) { | 457 if (test_context_flags_ & DataReductionProxyTestContext::USE_MOCK_SERVICE) { |
458 return make_scoped_ptr(new MockDataReductionProxyService( | 458 return make_scoped_ptr(new MockDataReductionProxyService( |
459 statistics_prefs.Pass(), settings_.get(), | 459 compression_stats.Pass(), settings_.get(), |
460 request_context_getter_.get())); | 460 request_context_getter_.get())); |
461 } else { | 461 } else { |
462 return make_scoped_ptr( | 462 return make_scoped_ptr( |
463 new DataReductionProxyService(statistics_prefs.Pass(), settings_.get(), | 463 new DataReductionProxyService(compression_stats.Pass(), settings_.get(), |
464 request_context_getter_.get())); | 464 request_context_getter_.get())); |
465 } | 465 } |
466 } | 466 } |
467 | 467 |
468 void DataReductionProxyTestContext::AttachToURLRequestContext( | 468 void DataReductionProxyTestContext::AttachToURLRequestContext( |
469 net::URLRequestContextStorage* request_context_storage) const { | 469 net::URLRequestContextStorage* request_context_storage) const { |
470 DCHECK(request_context_storage); | 470 DCHECK(request_context_storage); |
471 | 471 |
472 // |request_context_storage| takes ownership of the network delegate. | 472 // |request_context_storage| takes ownership of the network delegate. |
473 request_context_storage->set_network_delegate( | 473 request_context_storage->set_network_delegate( |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 io_data_->config_client()); | 567 io_data_->config_client()); |
568 } | 568 } |
569 | 569 |
570 DataReductionProxyBypassStats::UnreachableCallback | 570 DataReductionProxyBypassStats::UnreachableCallback |
571 DataReductionProxyTestContext::unreachable_callback() const { | 571 DataReductionProxyTestContext::unreachable_callback() const { |
572 return base::Bind(&DataReductionProxySettings::SetUnreachable, | 572 return base::Bind(&DataReductionProxySettings::SetUnreachable, |
573 base::Unretained(settings_.get())); | 573 base::Unretained(settings_.get())); |
574 } | 574 } |
575 | 575 |
576 } // namespace data_reduction_proxy | 576 } // namespace data_reduction_proxy |
OLD | NEW |