| 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" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 const int kStageResponseStarted = 1 << 6; | 45 const int kStageResponseStarted = 1 << 6; |
| 46 const int kStageCompletedSuccess = 1 << 7; | 46 const int kStageCompletedSuccess = 1 << 7; |
| 47 const int kStageCompletedError = 1 << 8; | 47 const int kStageCompletedError = 1 << 8; |
| 48 const int kStageURLRequestDestroyed = 1 << 9; | 48 const int kStageURLRequestDestroyed = 1 << 9; |
| 49 const int kStageDestruction = 1 << 10; | 49 const int kStageDestruction = 1 << 10; |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 TestURLRequestContext::TestURLRequestContext() | 53 TestURLRequestContext::TestURLRequestContext() |
| 54 : initialized_(false), | 54 : initialized_(false), |
| 55 client_socket_factory_(nullptr), | 55 client_socket_factory_(NULL), |
| 56 proxy_delegate_(nullptr), | |
| 57 context_storage_(this) { | 56 context_storage_(this) { |
| 58 Init(); | 57 Init(); |
| 59 } | 58 } |
| 60 | 59 |
| 61 TestURLRequestContext::TestURLRequestContext(bool delay_initialization) | 60 TestURLRequestContext::TestURLRequestContext(bool delay_initialization) |
| 62 : initialized_(false), | 61 : initialized_(false), |
| 63 client_socket_factory_(nullptr), | 62 client_socket_factory_(NULL), |
| 64 proxy_delegate_(nullptr), | |
| 65 context_storage_(this) { | 63 context_storage_(this) { |
| 66 if (!delay_initialization) | 64 if (!delay_initialization) |
| 67 Init(); | 65 Init(); |
| 68 } | 66 } |
| 69 | 67 |
| 70 TestURLRequestContext::~TestURLRequestContext() { | 68 TestURLRequestContext::~TestURLRequestContext() { |
| 71 DCHECK(initialized_); | 69 DCHECK(initialized_); |
| 72 AssertNoURLRequests(); | 70 AssertNoURLRequests(); |
| 73 } | 71 } |
| 74 | 72 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 94 } | 92 } |
| 95 if (!http_server_properties()) { | 93 if (!http_server_properties()) { |
| 96 context_storage_.set_http_server_properties( | 94 context_storage_.set_http_server_properties( |
| 97 scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); | 95 scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); |
| 98 } | 96 } |
| 99 if (http_transaction_factory()) { | 97 if (http_transaction_factory()) { |
| 100 // Make sure we haven't been passed an object we're not going to use. | 98 // Make sure we haven't been passed an object we're not going to use. |
| 101 EXPECT_FALSE(client_socket_factory_); | 99 EXPECT_FALSE(client_socket_factory_); |
| 102 } else { | 100 } else { |
| 103 HttpNetworkSession::Params params; | 101 HttpNetworkSession::Params params; |
| 104 | |
| 105 if (http_network_session_params_) | 102 if (http_network_session_params_) |
| 106 params = *http_network_session_params_; | 103 params = *http_network_session_params_; |
| 107 params.client_socket_factory = client_socket_factory(); | 104 params.client_socket_factory = client_socket_factory(); |
| 108 params.proxy_delegate = proxy_delegate(); | |
| 109 params.host_resolver = host_resolver(); | 105 params.host_resolver = host_resolver(); |
| 110 params.cert_verifier = cert_verifier(); | 106 params.cert_verifier = cert_verifier(); |
| 111 params.transport_security_state = transport_security_state(); | 107 params.transport_security_state = transport_security_state(); |
| 112 params.proxy_service = proxy_service(); | 108 params.proxy_service = proxy_service(); |
| 113 params.ssl_config_service = ssl_config_service(); | 109 params.ssl_config_service = ssl_config_service(); |
| 114 params.http_auth_handler_factory = http_auth_handler_factory(); | 110 params.http_auth_handler_factory = http_auth_handler_factory(); |
| 115 params.network_delegate = network_delegate(); | 111 params.network_delegate = network_delegate(); |
| 116 params.http_server_properties = http_server_properties(); | 112 params.http_server_properties = http_server_properties(); |
| 117 params.net_log = net_log(); | 113 params.net_log = net_log(); |
| 118 params.channel_id_service = channel_id_service(); | 114 params.channel_id_service = channel_id_service(); |
| 119 context_storage_.set_http_network_session( | 115 context_storage_.set_http_network_session( |
| 120 make_scoped_ptr(new HttpNetworkSession(params))); | 116 make_scoped_ptr(new HttpNetworkSession(params))); |
| 121 context_storage_.set_http_transaction_factory(make_scoped_ptr( | 117 context_storage_.set_http_transaction_factory(make_scoped_ptr( |
| 122 new HttpCache(context_storage_.http_network_session(), | 118 new HttpCache(context_storage_.http_network_session(), |
| 123 HttpCache::DefaultBackend::InMemory(0), false))); | 119 HttpCache::DefaultBackend::InMemory(0), false))); |
| 124 } | 120 } |
| 125 // In-memory cookie store. | 121 // In-memory cookie store. |
| 126 if (!cookie_store()) | 122 if (!cookie_store()) |
| 127 context_storage_.set_cookie_store(new CookieMonster(nullptr, nullptr)); | 123 context_storage_.set_cookie_store(new CookieMonster(NULL, NULL)); |
| 128 // In-memory Channel ID service. | 124 // In-memory Channel ID service. |
| 129 if (!channel_id_service()) { | 125 if (!channel_id_service()) { |
| 130 context_storage_.set_channel_id_service(make_scoped_ptr( | 126 context_storage_.set_channel_id_service(make_scoped_ptr( |
| 131 new ChannelIDService(new DefaultChannelIDStore(nullptr), | 127 new ChannelIDService(new DefaultChannelIDStore(NULL), |
| 132 base::WorkerPool::GetTaskRunner(true)))); | 128 base::WorkerPool::GetTaskRunner(true)))); |
| 133 } | 129 } |
| 134 if (!http_user_agent_settings()) { | 130 if (!http_user_agent_settings()) { |
| 135 context_storage_.set_http_user_agent_settings(make_scoped_ptr( | 131 context_storage_.set_http_user_agent_settings(make_scoped_ptr( |
| 136 new StaticHttpUserAgentSettings("en-us,fr", std::string()))); | 132 new StaticHttpUserAgentSettings("en-us,fr", std::string()))); |
| 137 } | 133 } |
| 138 if (!job_factory()) { | 134 if (!job_factory()) { |
| 139 context_storage_.set_job_factory( | 135 context_storage_.set_job_factory( |
| 140 make_scoped_ptr(new URLRequestJobFactoryImpl())); | 136 make_scoped_ptr(new URLRequestJobFactoryImpl())); |
| 141 } | 137 } |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 URLRequest* request, | 649 URLRequest* request, |
| 654 NetworkDelegate* network_delegate) const { | 650 NetworkDelegate* network_delegate) const { |
| 655 return main_intercept_job_.release(); | 651 return main_intercept_job_.release(); |
| 656 } | 652 } |
| 657 | 653 |
| 658 void TestJobInterceptor::set_main_intercept_job(scoped_ptr<URLRequestJob> job) { | 654 void TestJobInterceptor::set_main_intercept_job(scoped_ptr<URLRequestJob> job) { |
| 659 main_intercept_job_ = std::move(job); | 655 main_intercept_job_ = std::move(job); |
| 660 } | 656 } |
| 661 | 657 |
| 662 } // namespace net | 658 } // namespace net |
| OLD | NEW |