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/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.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_verifier.h" | 20 #include "net/cert/ct_verifier.h" |
21 #include "net/dns/mock_host_resolver.h" | 21 #include "net/dns/mock_host_resolver.h" |
22 #include "net/http/http_network_session.h" | 22 #include "net/http/http_network_session.h" |
23 #include "net/http/http_response_headers.h" | 23 #include "net/http/http_response_headers.h" |
24 #include "net/http/http_server_properties_impl.h" | 24 #include "net/http/http_server_properties_impl.h" |
25 #include "net/http/transport_security_state.h" | 25 #include "net/http/transport_security_state.h" |
26 #include "net/ssl/channel_id_service.h" | 26 #include "net/ssl/channel_id_service.h" |
27 #include "net/ssl/default_channel_id_store.h" | 27 #include "net/ssl/default_channel_id_store.h" |
| 28 #include "net/url_request/http_protocol_handler.h" |
28 #include "net/url_request/static_http_user_agent_settings.h" | 29 #include "net/url_request/static_http_user_agent_settings.h" |
29 #include "net/url_request/url_request_job.h" | 30 #include "net/url_request/url_request_job.h" |
30 #include "net/url_request/url_request_job_factory_impl.h" | 31 #include "net/url_request/url_request_job_factory_impl.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
32 | 33 |
33 namespace net { | 34 namespace net { |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 // These constants put the NetworkDelegate events of TestNetworkDelegate | 38 // These constants put the NetworkDelegate events of TestNetworkDelegate |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 context_storage_.set_http_transaction_factory(base::WrapUnique( | 133 context_storage_.set_http_transaction_factory(base::WrapUnique( |
133 new HttpCache(context_storage_.http_network_session(), | 134 new HttpCache(context_storage_.http_network_session(), |
134 HttpCache::DefaultBackend::InMemory(0), false))); | 135 HttpCache::DefaultBackend::InMemory(0), false))); |
135 } | 136 } |
136 if (!http_user_agent_settings()) { | 137 if (!http_user_agent_settings()) { |
137 context_storage_.set_http_user_agent_settings(base::WrapUnique( | 138 context_storage_.set_http_user_agent_settings(base::WrapUnique( |
138 new StaticHttpUserAgentSettings("en-us,fr", std::string()))); | 139 new StaticHttpUserAgentSettings("en-us,fr", std::string()))); |
139 } | 140 } |
140 if (!job_factory()) { | 141 if (!job_factory()) { |
141 context_storage_.set_job_factory( | 142 context_storage_.set_job_factory( |
142 base::WrapUnique(new URLRequestJobFactoryImpl())); | 143 URLRequestJobFactoryImpl::CreateWithHttpProtocolHandlers()); |
143 } | 144 } |
144 } | 145 } |
145 | 146 |
146 TestURLRequestContextGetter::TestURLRequestContextGetter( | 147 TestURLRequestContextGetter::TestURLRequestContextGetter( |
147 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner) | 148 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner) |
148 : network_task_runner_(network_task_runner) { | 149 : network_task_runner_(network_task_runner) { |
149 DCHECK(network_task_runner_.get()); | 150 DCHECK(network_task_runner_.get()); |
150 } | 151 } |
151 | 152 |
152 TestURLRequestContextGetter::TestURLRequestContextGetter( | 153 TestURLRequestContextGetter::TestURLRequestContextGetter( |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 const URLRequest& request, | 645 const URLRequest& request, |
645 const GURL& target_url, | 646 const GURL& target_url, |
646 const GURL& referrer_url) const { | 647 const GURL& referrer_url) const { |
647 return cancel_request_with_policy_violating_referrer_; | 648 return cancel_request_with_policy_violating_referrer_; |
648 } | 649 } |
649 | 650 |
650 TestJobInterceptor::TestJobInterceptor() {} | 651 TestJobInterceptor::TestJobInterceptor() {} |
651 | 652 |
652 TestJobInterceptor::~TestJobInterceptor() {} | 653 TestJobInterceptor::~TestJobInterceptor() {} |
653 | 654 |
654 URLRequestJob* TestJobInterceptor::MaybeCreateJob( | 655 URLRequestJob* TestJobInterceptor::MaybeInterceptRequest( |
655 URLRequest* request, | 656 URLRequest* request, |
656 NetworkDelegate* network_delegate) const { | 657 NetworkDelegate* network_delegate) const { |
657 return main_intercept_job_.release(); | 658 return main_intercept_job_.release(); |
658 } | 659 } |
659 | 660 |
| 661 URLRequestJob* TestJobInterceptor::MaybeInterceptRedirect( |
| 662 URLRequest* request, |
| 663 NetworkDelegate* network_delegate, |
| 664 const GURL& location) const { |
| 665 return nullptr; |
| 666 } |
| 667 |
| 668 URLRequestJob* TestJobInterceptor::MaybeInterceptResponse( |
| 669 URLRequest* request, |
| 670 NetworkDelegate* network_delegate) const { |
| 671 return nullptr; |
| 672 } |
| 673 |
660 void TestJobInterceptor::set_main_intercept_job( | 674 void TestJobInterceptor::set_main_intercept_job( |
661 std::unique_ptr<URLRequestJob> job) { | 675 std::unique_ptr<URLRequestJob> job) { |
662 main_intercept_job_ = std::move(job); | 676 main_intercept_job_ = std::move(job); |
663 } | 677 } |
664 | 678 |
665 } // namespace net | 679 } // namespace net |
OLD | NEW |