| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/url_request/url_request_test_util.h" | 5 #include "net/url_request/url_request_test_util.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/threading/worker_pool.h" | 17 #include "base/threading/worker_pool.h" |
| 18 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
| 19 #include "net/cert/cert_verifier.h" | 19 #include "net/cert/cert_verifier.h" |
| 20 #include "net/cert/ct_policy_enforcer.h" | 20 #include "net/cert/ct_policy_enforcer.h" |
| 21 #include "net/cert/multi_log_ct_verifier.h" | 21 #include "net/cert/multi_log_ct_verifier.h" |
| 22 #include "net/dns/mock_host_resolver.h" | 22 #include "net/dns/mock_host_resolver.h" |
| 23 #include "net/http/http_network_session.h" | 23 #include "net/http/http_network_session.h" |
| 24 #include "net/http/http_response_headers.h" | 24 #include "net/http/http_response_headers.h" |
| 25 #include "net/http/http_server_properties_impl.h" | 25 #include "net/http/http_server_properties_impl.h" |
| 26 #include "net/http/transport_security_state.h" | 26 #include "net/http/transport_security_state.h" |
| 27 #include "net/proxy/proxy_retry_info.h" | 27 #include "net/proxy/proxy_retry_info.h" |
| 28 #include "net/ssl/channel_id_service.h" | 28 #include "net/ssl/channel_id_service.h" |
| 29 #include "net/ssl/default_channel_id_store.h" | 29 #include "net/ssl/default_channel_id_store.h" |
| 30 #include "net/url_request/http_protocol_handler.h" |
| 30 #include "net/url_request/static_http_user_agent_settings.h" | 31 #include "net/url_request/static_http_user_agent_settings.h" |
| 31 #include "net/url_request/url_request_job.h" | 32 #include "net/url_request/url_request_job.h" |
| 32 #include "net/url_request/url_request_job_factory_impl.h" | 33 #include "net/url_request/url_request_job_factory_impl.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 34 | 35 |
| 35 namespace net { | 36 namespace net { |
| 36 | 37 |
| 37 namespace { | 38 namespace { |
| 38 | 39 |
| 39 // These constants put the NetworkDelegate events of TestNetworkDelegate | 40 // These constants put the NetworkDelegate events of TestNetworkDelegate |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 context_storage_.http_network_session(), | 140 context_storage_.http_network_session(), |
| 140 HttpCache::DefaultBackend::InMemory(0), false)); | 141 HttpCache::DefaultBackend::InMemory(0), false)); |
| 141 } | 142 } |
| 142 if (!http_user_agent_settings()) { | 143 if (!http_user_agent_settings()) { |
| 143 context_storage_.set_http_user_agent_settings( | 144 context_storage_.set_http_user_agent_settings( |
| 144 base::MakeUnique<StaticHttpUserAgentSettings>("en-us,fr", | 145 base::MakeUnique<StaticHttpUserAgentSettings>("en-us,fr", |
| 145 std::string())); | 146 std::string())); |
| 146 } | 147 } |
| 147 if (!job_factory()) { | 148 if (!job_factory()) { |
| 148 context_storage_.set_job_factory( | 149 context_storage_.set_job_factory( |
| 149 base::MakeUnique<URLRequestJobFactoryImpl>()); | 150 URLRequestJobFactoryImpl::CreateWithHttpProtocolHandlers()); |
| 150 } | 151 } |
| 151 } | 152 } |
| 152 | 153 |
| 153 TestURLRequestContextGetter::TestURLRequestContextGetter( | 154 TestURLRequestContextGetter::TestURLRequestContextGetter( |
| 154 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner) | 155 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner) |
| 155 : network_task_runner_(network_task_runner) { | 156 : network_task_runner_(network_task_runner) { |
| 156 DCHECK(network_task_runner_.get()); | 157 DCHECK(network_task_runner_.get()); |
| 157 } | 158 } |
| 158 | 159 |
| 159 TestURLRequestContextGetter::TestURLRequestContextGetter( | 160 TestURLRequestContextGetter::TestURLRequestContextGetter( |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 const URLRequest& request, | 655 const URLRequest& request, |
| 655 const GURL& target_url, | 656 const GURL& target_url, |
| 656 const GURL& referrer_url) const { | 657 const GURL& referrer_url) const { |
| 657 return cancel_request_with_policy_violating_referrer_; | 658 return cancel_request_with_policy_violating_referrer_; |
| 658 } | 659 } |
| 659 | 660 |
| 660 TestJobInterceptor::TestJobInterceptor() {} | 661 TestJobInterceptor::TestJobInterceptor() {} |
| 661 | 662 |
| 662 TestJobInterceptor::~TestJobInterceptor() {} | 663 TestJobInterceptor::~TestJobInterceptor() {} |
| 663 | 664 |
| 664 URLRequestJob* TestJobInterceptor::MaybeCreateJob( | 665 URLRequestJob* TestJobInterceptor::MaybeInterceptRequest( |
| 665 URLRequest* request, | 666 URLRequest* request, |
| 666 NetworkDelegate* network_delegate) const { | 667 NetworkDelegate* network_delegate) const { |
| 667 return main_intercept_job_.release(); | 668 return main_intercept_job_.release(); |
| 668 } | 669 } |
| 669 | 670 |
| 671 URLRequestJob* TestJobInterceptor::MaybeInterceptRedirect( |
| 672 URLRequest* request, |
| 673 NetworkDelegate* network_delegate, |
| 674 const GURL& location) const { |
| 675 return nullptr; |
| 676 } |
| 677 |
| 678 URLRequestJob* TestJobInterceptor::MaybeInterceptResponse( |
| 679 URLRequest* request, |
| 680 NetworkDelegate* network_delegate) const { |
| 681 return nullptr; |
| 682 } |
| 683 |
| 670 void TestJobInterceptor::set_main_intercept_job( | 684 void TestJobInterceptor::set_main_intercept_job( |
| 671 std::unique_ptr<URLRequestJob> job) { | 685 std::unique_ptr<URLRequestJob> job) { |
| 672 main_intercept_job_ = std::move(job); | 686 main_intercept_job_ = std::move(job); |
| 673 } | 687 } |
| 674 | 688 |
| 675 } // namespace net | 689 } // namespace net |
| OLD | NEW |