Chromium Code Reviews| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "net/base/cache_type.h" | 16 #include "net/base/cache_type.h" |
| 17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 18 #include "net/base/network_delegate_impl.h" | 18 #include "net/base/network_delegate_impl.h" |
| 19 #include "net/base/sdch_manager.h" | 19 #include "net/base/sdch_manager.h" |
| 20 #include "net/cert/cert_verifier.h" | 20 #include "net/cert/cert_verifier.h" |
| 21 #include "net/cookies/cookie_monster.h" | 21 #include "net/cookies/cookie_monster.h" |
| 22 #include "net/dns/host_resolver.h" | 22 #include "net/dns/host_resolver.h" |
| 23 #include "net/ftp/ftp_network_layer.h" | 23 #include "net/ftp/ftp_network_layer.h" |
| 24 #include "net/http/http_auth_handler_factory.h" | 24 #include "net/http/http_auth_handler_factory.h" |
| 25 #include "net/http/http_cache.h" | 25 #include "net/http/http_cache.h" |
| 26 #include "net/http/http_network_layer.h" | 26 #include "net/http/http_network_layer.h" |
| 27 #include "net/http/http_network_session.h" | |
| 28 #include "net/http/http_server_properties_impl.h" | 27 #include "net/http/http_server_properties_impl.h" |
| 29 #include "net/http/http_server_properties_manager.h" | 28 #include "net/http/http_server_properties_manager.h" |
| 30 #include "net/http/transport_security_persister.h" | 29 #include "net/http/transport_security_persister.h" |
| 31 #include "net/http/transport_security_state.h" | 30 #include "net/http/transport_security_state.h" |
| 32 #include "net/ssl/channel_id_service.h" | 31 #include "net/ssl/channel_id_service.h" |
| 33 #include "net/ssl/default_channel_id_store.h" | 32 #include "net/ssl/default_channel_id_store.h" |
| 34 #include "net/ssl/ssl_config_service_defaults.h" | 33 #include "net/ssl/ssl_config_service_defaults.h" |
| 35 #include "net/url_request/data_protocol_handler.h" | 34 #include "net/url_request/data_protocol_handler.h" |
| 36 #include "net/url_request/static_http_user_agent_settings.h" | 35 #include "net/url_request/static_http_user_agent_settings.h" |
| 37 #include "net/url_request/url_request_backoff_manager.h" | 36 #include "net/url_request/url_request_backoff_manager.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 ftp_enabled_(false), | 205 ftp_enabled_(false), |
| 207 #endif | 206 #endif |
| 208 http_cache_enabled_(true), | 207 http_cache_enabled_(true), |
| 209 throttling_enabled_(false), | 208 throttling_enabled_(false), |
| 210 backoff_enabled_(false), | 209 backoff_enabled_(false), |
| 211 sdch_enabled_(false) { | 210 sdch_enabled_(false) { |
| 212 } | 211 } |
| 213 | 212 |
| 214 URLRequestContextBuilder::~URLRequestContextBuilder() {} | 213 URLRequestContextBuilder::~URLRequestContextBuilder() {} |
| 215 | 214 |
| 215 // static | |
|
mmenke
2015/08/18 18:30:32
nit: Remove static (No longer in Google style gui
wjmaclean
2015/08/18 18:55:37
Done.
| |
| 216 void URLRequestContextBuilder::SetHttpNetworkSessionComponents( | |
| 217 const URLRequestContext* context, | |
| 218 HttpNetworkSession::Params* params) { | |
| 219 params->host_resolver = context->host_resolver(); | |
| 220 params->cert_verifier = context->cert_verifier(); | |
| 221 params->transport_security_state = context->transport_security_state(); | |
| 222 params->cert_transparency_verifier = context->cert_transparency_verifier(); | |
| 223 params->proxy_service = context->proxy_service(); | |
| 224 params->ssl_config_service = context->ssl_config_service(); | |
| 225 params->http_auth_handler_factory = context->http_auth_handler_factory(); | |
| 226 params->network_delegate = context->network_delegate(); | |
| 227 params->http_server_properties = context->http_server_properties(); | |
| 228 params->net_log = context->net_log(); | |
| 229 params->channel_id_service = context->channel_id_service(); | |
| 230 } | |
| 231 | |
| 216 void URLRequestContextBuilder::EnableHttpCache(const HttpCacheParams& params) { | 232 void URLRequestContextBuilder::EnableHttpCache(const HttpCacheParams& params) { |
| 217 http_cache_enabled_ = true; | 233 http_cache_enabled_ = true; |
| 218 http_cache_params_ = params; | 234 http_cache_params_ = params; |
| 219 } | 235 } |
| 220 | 236 |
| 221 void URLRequestContextBuilder::DisableHttpCache() { | 237 void URLRequestContextBuilder::DisableHttpCache() { |
| 222 http_cache_enabled_ = false; | 238 http_cache_enabled_ = false; |
| 223 http_cache_params_ = HttpCacheParams(); | 239 http_cache_params_ = HttpCacheParams(); |
| 224 } | 240 } |
| 225 | 241 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 | 361 |
| 346 storage->set_cert_verifier(CertVerifier::CreateDefault()); | 362 storage->set_cert_verifier(CertVerifier::CreateDefault()); |
| 347 | 363 |
| 348 if (throttling_enabled_) | 364 if (throttling_enabled_) |
| 349 storage->set_throttler_manager(new URLRequestThrottlerManager()); | 365 storage->set_throttler_manager(new URLRequestThrottlerManager()); |
| 350 | 366 |
| 351 if (backoff_enabled_) | 367 if (backoff_enabled_) |
| 352 storage->set_backoff_manager(new URLRequestBackoffManager()); | 368 storage->set_backoff_manager(new URLRequestBackoffManager()); |
| 353 | 369 |
| 354 HttpNetworkSession::Params network_session_params; | 370 HttpNetworkSession::Params network_session_params; |
| 355 network_session_params.host_resolver = context->host_resolver(); | 371 SetHttpNetworkSessionComponents(context, &network_session_params); |
| 356 network_session_params.cert_verifier = context->cert_verifier(); | |
| 357 network_session_params.transport_security_state = | |
| 358 context->transport_security_state(); | |
| 359 network_session_params.proxy_service = context->proxy_service(); | |
| 360 network_session_params.ssl_config_service = | |
| 361 context->ssl_config_service(); | |
| 362 network_session_params.http_auth_handler_factory = | |
| 363 context->http_auth_handler_factory(); | |
| 364 network_session_params.network_delegate = network_delegate; | |
| 365 network_session_params.http_server_properties = | |
| 366 context->http_server_properties(); | |
| 367 network_session_params.net_log = context->net_log(); | |
| 368 | 372 |
| 369 network_session_params.ignore_certificate_errors = | 373 network_session_params.ignore_certificate_errors = |
| 370 http_network_session_params_.ignore_certificate_errors; | 374 http_network_session_params_.ignore_certificate_errors; |
| 371 network_session_params.host_mapping_rules = | 375 network_session_params.host_mapping_rules = |
| 372 http_network_session_params_.host_mapping_rules; | 376 http_network_session_params_.host_mapping_rules; |
| 373 network_session_params.testing_fixed_http_port = | 377 network_session_params.testing_fixed_http_port = |
| 374 http_network_session_params_.testing_fixed_http_port; | 378 http_network_session_params_.testing_fixed_http_port; |
| 375 network_session_params.testing_fixed_https_port = | 379 network_session_params.testing_fixed_https_port = |
| 376 http_network_session_params_.testing_fixed_https_port; | 380 http_network_session_params_.testing_fixed_https_port; |
| 377 network_session_params.use_alternate_protocols = | 381 network_session_params.use_alternate_protocols = |
| 378 http_network_session_params_.use_alternate_protocols; | 382 http_network_session_params_.use_alternate_protocols; |
| 379 network_session_params.trusted_spdy_proxy = | 383 network_session_params.trusted_spdy_proxy = |
| 380 http_network_session_params_.trusted_spdy_proxy; | 384 http_network_session_params_.trusted_spdy_proxy; |
| 381 network_session_params.next_protos = http_network_session_params_.next_protos; | 385 network_session_params.next_protos = http_network_session_params_.next_protos; |
| 382 network_session_params.enable_quic = http_network_session_params_.enable_quic; | 386 network_session_params.enable_quic = http_network_session_params_.enable_quic; |
| 383 network_session_params.enable_insecure_quic = | 387 network_session_params.enable_insecure_quic = |
| 384 http_network_session_params_.enable_insecure_quic; | 388 http_network_session_params_.enable_insecure_quic; |
| 385 network_session_params.quic_connection_options = | 389 network_session_params.quic_connection_options = |
| 386 http_network_session_params_.quic_connection_options; | 390 http_network_session_params_.quic_connection_options; |
| 387 | 391 |
| 388 HttpTransactionFactory* http_transaction_factory = NULL; | 392 HttpTransactionFactory* http_transaction_factory = NULL; |
| 389 if (http_cache_enabled_) { | 393 if (http_cache_enabled_) { |
| 390 network_session_params.channel_id_service = | |
| 391 context->channel_id_service(); | |
| 392 HttpCache::BackendFactory* http_cache_backend = NULL; | 394 HttpCache::BackendFactory* http_cache_backend = NULL; |
| 393 if (http_cache_params_.type == HttpCacheParams::DISK) { | 395 if (http_cache_params_.type == HttpCacheParams::DISK) { |
| 394 http_cache_backend = new HttpCache::DefaultBackend( | 396 http_cache_backend = new HttpCache::DefaultBackend( |
| 395 DISK_CACHE, CACHE_BACKEND_DEFAULT, http_cache_params_.path, | 397 DISK_CACHE, CACHE_BACKEND_DEFAULT, http_cache_params_.path, |
| 396 http_cache_params_.max_size, context->GetFileTaskRunner()); | 398 http_cache_params_.max_size, context->GetFileTaskRunner()); |
| 397 } else { | 399 } else { |
| 398 http_cache_backend = | 400 http_cache_backend = |
| 399 HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size); | 401 HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size); |
| 400 } | 402 } |
| 401 | 403 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 } | 443 } |
| 442 url_request_interceptors_.weak_clear(); | 444 url_request_interceptors_.weak_clear(); |
| 443 } | 445 } |
| 444 storage->set_job_factory(top_job_factory.release()); | 446 storage->set_job_factory(top_job_factory.release()); |
| 445 // TODO(willchan): Support sdch. | 447 // TODO(willchan): Support sdch. |
| 446 | 448 |
| 447 return context; | 449 return context; |
| 448 } | 450 } |
| 449 | 451 |
| 450 } // namespace net | 452 } // namespace net |
| OLD | NEW |