| 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 "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 11 #include "base/threading/worker_pool.h" | 11 #include "base/threading/worker_pool.h" |
| 12 #include "net/base/cert_verifier.h" | 12 #include "net/base/cert_verifier.h" |
| 13 #include "net/base/default_server_bound_cert_store.h" | 13 #include "net/base/default_server_bound_cert_store.h" |
| 14 #include "net/base/host_port_pair.h" | 14 #include "net/base/host_port_pair.h" |
| 15 #include "net/base/mock_host_resolver.h" | 15 #include "net/base/mock_host_resolver.h" |
| 16 #include "net/base/server_bound_cert_service.h" | 16 #include "net/base/server_bound_cert_service.h" |
| 17 #include "net/http/http_network_session.h" | 17 #include "net/http/http_network_session.h" |
| 18 #include "net/http/http_server_properties_impl.h" | 18 #include "net/http/http_server_properties_impl.h" |
| 19 #include "net/url_request/static_http_user_agent_settings.h" |
| 19 #include "net/url_request/url_request_job_factory_impl.h" | 20 #include "net/url_request/url_request_job_factory_impl.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 // These constants put the net::NetworkDelegate events of TestNetworkDelegate | 25 // These constants put the net::NetworkDelegate events of TestNetworkDelegate |
| 25 // into an order. They are used in conjunction with | 26 // into an order. They are used in conjunction with |
| 26 // |TestNetworkDelegate::next_states_| to check that we do not send | 27 // |TestNetworkDelegate::next_states_| to check that we do not send |
| 27 // events in the wrong order. | 28 // events in the wrong order. |
| 28 const int kStageBeforeURLRequest = 1 << 0; | 29 const int kStageBeforeURLRequest = 1 << 0; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // In-memory cookie store. | 107 // In-memory cookie store. |
| 107 if (!cookie_store()) | 108 if (!cookie_store()) |
| 108 context_storage_.set_cookie_store(new net::CookieMonster(NULL, NULL)); | 109 context_storage_.set_cookie_store(new net::CookieMonster(NULL, NULL)); |
| 109 // In-memory origin bound cert service. | 110 // In-memory origin bound cert service. |
| 110 if (!server_bound_cert_service()) { | 111 if (!server_bound_cert_service()) { |
| 111 context_storage_.set_server_bound_cert_service( | 112 context_storage_.set_server_bound_cert_service( |
| 112 new net::ServerBoundCertService( | 113 new net::ServerBoundCertService( |
| 113 new net::DefaultServerBoundCertStore(NULL), | 114 new net::DefaultServerBoundCertStore(NULL), |
| 114 base::WorkerPool::GetTaskRunner(true))); | 115 base::WorkerPool::GetTaskRunner(true))); |
| 115 } | 116 } |
| 116 if (accept_language().empty()) | 117 if (!http_user_agent_settings()) { |
| 117 set_accept_language("en-us,fr"); | 118 context_storage_.set_http_user_agent_settings( |
| 118 if (accept_charset().empty()) | 119 new net::StaticHttpUserAgentSettings( |
| 119 set_accept_charset("iso-8859-1,*,utf-8"); | 120 "en-us,fr", "iso-8859-1,*,utf-8", EmptyString())); |
| 121 } |
| 120 if (!job_factory()) | 122 if (!job_factory()) |
| 121 context_storage_.set_job_factory(new net::URLRequestJobFactoryImpl); | 123 context_storage_.set_job_factory(new net::URLRequestJobFactoryImpl); |
| 122 } | 124 } |
| 123 | 125 |
| 124 TestURLRequest::TestURLRequest(const GURL& url, | 126 TestURLRequest::TestURLRequest(const GURL& url, |
| 125 Delegate* delegate, | 127 Delegate* delegate, |
| 126 TestURLRequestContext* context) | 128 TestURLRequestContext* context) |
| 127 : net::URLRequest(url, delegate, context) { | 129 : net::URLRequest(url, delegate, context) { |
| 128 } | 130 } |
| 129 | 131 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 557 |
| 556 net::URLRequestJob* TestJobInterceptor::MaybeInterceptResponse( | 558 net::URLRequestJob* TestJobInterceptor::MaybeInterceptResponse( |
| 557 net::URLRequest* request, | 559 net::URLRequest* request, |
| 558 net::NetworkDelegate* network_delegate) const { | 560 net::NetworkDelegate* network_delegate) const { |
| 559 return NULL; | 561 return NULL; |
| 560 } | 562 } |
| 561 | 563 |
| 562 void TestJobInterceptor::set_main_intercept_job(net::URLRequestJob* job) { | 564 void TestJobInterceptor::set_main_intercept_job(net::URLRequestJob* job) { |
| 563 main_intercept_job_ = job; | 565 main_intercept_job_ = job; |
| 564 } | 566 } |
| OLD | NEW |