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_context_builder.h" | 5 #include "net/url_request/url_request_context_builder.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 URLRequestContextBuilder::HostResolverParams::HostResolverParams() | 174 URLRequestContextBuilder::HostResolverParams::HostResolverParams() |
175 : parallelism(HostResolver::kDefaultParallelism), | 175 : parallelism(HostResolver::kDefaultParallelism), |
176 retry_attempts(HostResolver::kDefaultRetryAttempts) {} | 176 retry_attempts(HostResolver::kDefaultRetryAttempts) {} |
177 URLRequestContextBuilder::HostResolverParams::~HostResolverParams() {} | 177 URLRequestContextBuilder::HostResolverParams::~HostResolverParams() {} |
178 | 178 |
179 URLRequestContextBuilder::HttpCacheParams::HttpCacheParams() | 179 URLRequestContextBuilder::HttpCacheParams::HttpCacheParams() |
180 : type(IN_MEMORY), | 180 : type(IN_MEMORY), |
181 max_size(0) {} | 181 max_size(0) {} |
182 URLRequestContextBuilder::HttpCacheParams::~HttpCacheParams() {} | 182 URLRequestContextBuilder::HttpCacheParams::~HttpCacheParams() {} |
183 | 183 |
184 URLRequestContextBuilder::HttpNetworkSessionParams::HttpNetworkSessionParams() | |
185 : ignore_certificate_errors(false), | |
186 host_mapping_rules(NULL), | |
187 http_pipelining_enabled(false), | |
188 testing_fixed_http_port(0), | |
189 testing_fixed_https_port(0), | |
190 trusted_spdy_proxy() {} | |
191 | |
192 URLRequestContextBuilder::HttpNetworkSessionParams::~HttpNetworkSessionParams() | |
193 {} | |
194 | |
184 URLRequestContextBuilder::URLRequestContextBuilder() | 195 URLRequestContextBuilder::URLRequestContextBuilder() |
185 : ftp_enabled_(false), | 196 : ftp_enabled_(false), |
186 http_cache_enabled_(true) {} | 197 http_cache_enabled_(true) {} |
187 URLRequestContextBuilder::~URLRequestContextBuilder() {} | 198 URLRequestContextBuilder::~URLRequestContextBuilder() {} |
188 | 199 |
200 | |
201 | |
mmenke
2012/08/23 18:11:28
Remove extra linebreaks.
| |
189 #if defined(OS_LINUX) | 202 #if defined(OS_LINUX) |
190 void URLRequestContextBuilder::set_proxy_config_service( | 203 void URLRequestContextBuilder::set_proxy_config_service( |
191 ProxyConfigService* proxy_config_service) { | 204 ProxyConfigService* proxy_config_service) { |
192 proxy_config_service_.reset(proxy_config_service); | 205 proxy_config_service_.reset(proxy_config_service); |
193 } | 206 } |
194 #endif // defined(OS_LINUX) | 207 #endif // defined(OS_LINUX) |
195 | 208 |
196 URLRequestContext* URLRequestContextBuilder::Build() { | 209 URLRequestContext* URLRequestContextBuilder::Build() { |
197 BasicURLRequestContext* context = new BasicURLRequestContext; | 210 BasicURLRequestContext* context = new BasicURLRequestContext; |
198 URLRequestContextStorage* storage = context->storage(); | 211 URLRequestContextStorage* storage = context->storage(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 4, // TODO(willchan): Find a better constant somewhere. | 243 4, // TODO(willchan): Find a better constant somewhere. |
231 context->net_log())); | 244 context->net_log())); |
232 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults); | 245 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults); |
233 storage->set_http_auth_handler_factory( | 246 storage->set_http_auth_handler_factory( |
234 net::HttpAuthHandlerRegistryFactory::CreateDefault(host_resolver)); | 247 net::HttpAuthHandlerRegistryFactory::CreateDefault(host_resolver)); |
235 storage->set_cookie_store(new CookieMonster(NULL, NULL)); | 248 storage->set_cookie_store(new CookieMonster(NULL, NULL)); |
236 storage->set_transport_security_state(new net::TransportSecurityState()); | 249 storage->set_transport_security_state(new net::TransportSecurityState()); |
237 storage->set_http_server_properties(new net::HttpServerPropertiesImpl); | 250 storage->set_http_server_properties(new net::HttpServerPropertiesImpl); |
238 storage->set_cert_verifier(CertVerifier::CreateDefault()); | 251 storage->set_cert_verifier(CertVerifier::CreateDefault()); |
239 | 252 |
253 net::HttpNetworkSession::Params network_session_params; | |
254 network_session_params.host_resolver = host_resolver; | |
255 network_session_params.cert_verifier = context->cert_verifier(); | |
256 network_session_params.transport_security_state = | |
257 context->transport_security_state(); | |
258 network_session_params.proxy_service = context->proxy_service(); | |
259 network_session_params.ssl_config_service = | |
260 context->ssl_config_service(); | |
261 network_session_params.http_auth_handler_factory = | |
262 context->http_auth_handler_factory(); | |
263 network_session_params.network_delegate = | |
264 context->network_delegate(); | |
265 network_session_params.http_server_properties = | |
266 context->http_server_properties(); | |
267 network_session_params.net_log = context->net_log(); | |
268 network_session_params.ignore_certificate_errors = | |
269 http_network_session_params_.ignore_certificate_errors; | |
270 network_session_params.host_mapping_rules = | |
271 http_network_session_params_.host_mapping_rules; | |
272 network_session_params.http_pipelining_enabled = | |
273 http_network_session_params_.http_pipelining_enabled; | |
274 network_session_params.testing_fixed_http_port = | |
275 http_network_session_params_.testing_fixed_http_port; | |
276 network_session_params.testing_fixed_https_port = | |
277 http_network_session_params_.testing_fixed_https_port; | |
278 network_session_params.trusted_spdy_proxy = | |
279 http_network_session_params_.trusted_spdy_proxy; | |
280 | |
240 HttpTransactionFactory* http_transaction_factory = NULL; | 281 HttpTransactionFactory* http_transaction_factory = NULL; |
241 if (http_cache_enabled_) { | 282 if (http_cache_enabled_) { |
283 network_session_params.server_bound_cert_service = | |
284 context->server_bound_cert_service(); | |
242 HttpCache::BackendFactory* http_cache_backend = NULL; | 285 HttpCache::BackendFactory* http_cache_backend = NULL; |
243 if (http_cache_params_.type == HttpCacheParams::DISK) { | 286 if (http_cache_params_.type == HttpCacheParams::DISK) { |
244 context->StartCacheThread(); | 287 context->StartCacheThread(); |
245 http_cache_backend = | 288 http_cache_backend = |
246 new HttpCache::DefaultBackend(DISK_CACHE, | 289 new HttpCache::DefaultBackend(DISK_CACHE, |
247 http_cache_params_.path, | 290 http_cache_params_.path, |
248 http_cache_params_.max_size, | 291 http_cache_params_.max_size, |
249 context->cache_message_loop_proxy()); | 292 context->cache_message_loop_proxy()); |
250 } else { | 293 } else { |
251 http_cache_backend = | 294 http_cache_backend = |
252 HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size); | 295 HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size); |
253 } | 296 } |
297 | |
254 http_transaction_factory = new HttpCache( | 298 http_transaction_factory = new HttpCache( |
255 context->host_resolver(), | 299 network_session_params, http_cache_backend); |
256 context->cert_verifier(), | |
257 context->server_bound_cert_service(), | |
258 context->transport_security_state(), | |
259 context->proxy_service(), | |
260 "", | |
261 context->ssl_config_service(), | |
262 context->http_auth_handler_factory(), | |
263 context->network_delegate(), | |
264 context->http_server_properties(), | |
265 context->net_log(), | |
266 http_cache_backend, | |
267 "" /* trusted_spdy_proxy */ ); | |
268 } else { | 300 } else { |
269 HttpNetworkSession::Params session_params; | |
270 session_params.host_resolver = context->host_resolver(); | |
271 session_params.cert_verifier = context->cert_verifier(); | |
272 session_params.transport_security_state = | |
273 context->transport_security_state(); | |
274 session_params.proxy_service = context->proxy_service(); | |
275 session_params.ssl_config_service = context->ssl_config_service(); | |
276 session_params.http_auth_handler_factory = | |
277 context->http_auth_handler_factory(); | |
278 session_params.network_delegate = context->network_delegate(); | |
279 session_params.http_server_properties = | |
280 context->http_server_properties(); | |
281 session_params.net_log = context->net_log(); | |
282 scoped_refptr<net::HttpNetworkSession> network_session( | 301 scoped_refptr<net::HttpNetworkSession> network_session( |
283 new net::HttpNetworkSession(session_params)); | 302 new net::HttpNetworkSession(network_session_params)); |
284 | 303 |
285 http_transaction_factory = new HttpNetworkLayer(network_session); | 304 http_transaction_factory = new HttpNetworkLayer(network_session); |
286 } | 305 } |
287 storage->set_http_transaction_factory(http_transaction_factory); | 306 storage->set_http_transaction_factory(http_transaction_factory); |
288 | 307 |
289 // TODO(willchan): Support sdch. | 308 // TODO(willchan): Support sdch. |
290 | 309 |
291 return context; | 310 return context; |
292 } | 311 } |
293 | 312 |
294 } // namespace net | 313 } // namespace net |
OLD | NEW |