Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: net/url_request/url_request_test_util.cc

Issue 1888963004: Add HttpProtocolHandler and convert everything to use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-supports-scheme
Patch Set: even more rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::CreateWithDefaultProtocolHandlers());
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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 return experimental_cookie_features_enabled_; 641 return experimental_cookie_features_enabled_;
641 } 642 }
642 643
643 bool TestNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( 644 bool TestNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader(
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() {
652 http_protocol_handler_ = base::WrapUnique(new HttpProtocolHandler);
653 }
651 654
652 TestJobInterceptor::~TestJobInterceptor() {} 655 TestJobInterceptor::~TestJobInterceptor() {}
653 656
654 URLRequestJob* TestJobInterceptor::MaybeCreateJob( 657 URLRequestJob* TestJobInterceptor::MaybeCreateJob(
655 URLRequest* request, 658 URLRequest* request,
656 NetworkDelegate* network_delegate) const { 659 NetworkDelegate* network_delegate) const {
657 return main_intercept_job_.release(); 660 URLRequestJob* job = main_intercept_job_.release();
661 if (job)
662 return job;
663 return http_protocol_handler_->MaybeCreateJob(request, network_delegate);
mmenke 2016/04/21 20:58:01 How hard would it be to make TestJobInterceptor a
mgersh 2016/04/22 20:27:15 It's enough work that I'd rather not bundle it wit
mmenke 2016/04/22 20:41:04 Unconditionally calling directly into our own priv
mgersh 2016/04/27 16:13:52 Okay, I changed it to an interceptor here.
658 } 664 }
659 665
660 void TestJobInterceptor::set_main_intercept_job( 666 void TestJobInterceptor::set_main_intercept_job(
661 std::unique_ptr<URLRequestJob> job) { 667 std::unique_ptr<URLRequestJob> job) {
662 main_intercept_job_ = std::move(job); 668 main_intercept_job_ = std::move(job);
663 } 669 }
664 670
665 } // namespace net 671 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698