diff options
Diffstat (limited to 'net/url_request')
-rw-r--r-- | net/url_request/url_request_context.cc | 11 | ||||
-rw-r--r-- | net/url_request/url_request_context.h | 4 | ||||
-rw-r--r-- | net/url_request/url_request_context_builder.cc | 71 | ||||
-rw-r--r-- | net/url_request/url_request_context_builder.h | 21 |
4 files changed, 80 insertions, 27 deletions
diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc index 5b7af63..b9ee75f 100644 --- a/net/url_request/url_request_context.cc +++ b/net/url_request/url_request_context.cc @@ -65,6 +65,17 @@ void URLRequestContext::CopyFrom(const URLRequestContext* other) { set_throttler_manager(other->throttler_manager_); } +const HttpNetworkSession::Params* URLRequestContext::GetNetworkSessionParams( + ) const { + HttpTransactionFactory* transaction_factory = http_transaction_factory(); + if (!transaction_factory) + return NULL; + HttpNetworkSession* network_session = transaction_factory->GetSession(); + if (!network_session) + return NULL; + return &network_session->params(); +} + URLRequest* URLRequestContext::CreateRequest( const GURL& url, URLRequest::Delegate* delegate) const { return new URLRequest(url, delegate, this, network_delegate_); diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h index 8e8e3cc..cea9de5 100644 --- a/net/url_request/url_request_context.h +++ b/net/url_request/url_request_context.h @@ -20,6 +20,7 @@ #include "net/base/net_log.h" #include "net/base/ssl_config_service.h" #include "net/base/transport_security_state.h" +#include "net/http/http_network_session.h" #include "net/http/http_server_properties.h" #include "net/ftp/ftp_auth_cache.h" #include "net/url_request/url_request.h" @@ -52,6 +53,9 @@ class NET_EXPORT URLRequestContext // Copies the state from |other| into this context. void CopyFrom(const URLRequestContext* other); + // May return NULL if this context doesn't have an associated network session. + const HttpNetworkSession::Params* GetNetworkSessionParams() const; + URLRequest* CreateRequest( const GURL& url, URLRequest::Delegate* delegate) const; diff --git a/net/url_request/url_request_context_builder.cc b/net/url_request/url_request_context_builder.cc index 415cb11..3228bfb 100644 --- a/net/url_request/url_request_context_builder.cc +++ b/net/url_request/url_request_context_builder.cc @@ -181,6 +181,17 @@ URLRequestContextBuilder::HttpCacheParams::HttpCacheParams() max_size(0) {} URLRequestContextBuilder::HttpCacheParams::~HttpCacheParams() {} +URLRequestContextBuilder::HttpNetworkSessionParams::HttpNetworkSessionParams() + : ignore_certificate_errors(false), + host_mapping_rules(NULL), + http_pipelining_enabled(false), + testing_fixed_http_port(0), + testing_fixed_https_port(0), + trusted_spdy_proxy() {} + +URLRequestContextBuilder::HttpNetworkSessionParams::~HttpNetworkSessionParams() +{} + URLRequestContextBuilder::URLRequestContextBuilder() : ftp_enabled_(false), http_cache_enabled_(true) {} @@ -237,8 +248,38 @@ URLRequestContext* URLRequestContextBuilder::Build() { storage->set_http_server_properties(new net::HttpServerPropertiesImpl); storage->set_cert_verifier(CertVerifier::CreateDefault()); + net::HttpNetworkSession::Params network_session_params; + network_session_params.host_resolver = host_resolver; + network_session_params.cert_verifier = context->cert_verifier(); + network_session_params.transport_security_state = + context->transport_security_state(); + network_session_params.proxy_service = context->proxy_service(); + network_session_params.ssl_config_service = + context->ssl_config_service(); + network_session_params.http_auth_handler_factory = + context->http_auth_handler_factory(); + network_session_params.network_delegate = + context->network_delegate(); + network_session_params.http_server_properties = + context->http_server_properties(); + network_session_params.net_log = context->net_log(); + network_session_params.ignore_certificate_errors = + http_network_session_params_.ignore_certificate_errors; + network_session_params.host_mapping_rules = + http_network_session_params_.host_mapping_rules; + network_session_params.http_pipelining_enabled = + http_network_session_params_.http_pipelining_enabled; + network_session_params.testing_fixed_http_port = + http_network_session_params_.testing_fixed_http_port; + network_session_params.testing_fixed_https_port = + http_network_session_params_.testing_fixed_https_port; + network_session_params.trusted_spdy_proxy = + http_network_session_params_.trusted_spdy_proxy; + HttpTransactionFactory* http_transaction_factory = NULL; if (http_cache_enabled_) { + network_session_params.server_bound_cert_service = + context->server_bound_cert_service(); HttpCache::BackendFactory* http_cache_backend = NULL; if (http_cache_params_.type == HttpCacheParams::DISK) { context->StartCacheThread(); @@ -251,36 +292,12 @@ URLRequestContext* URLRequestContextBuilder::Build() { http_cache_backend = HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size); } + http_transaction_factory = new HttpCache( - context->host_resolver(), - context->cert_verifier(), - context->server_bound_cert_service(), - context->transport_security_state(), - context->proxy_service(), - "", - context->ssl_config_service(), - context->http_auth_handler_factory(), - context->network_delegate(), - context->http_server_properties(), - context->net_log(), - http_cache_backend, - "" /* trusted_spdy_proxy */ ); + network_session_params, http_cache_backend); } else { - HttpNetworkSession::Params session_params; - session_params.host_resolver = context->host_resolver(); - session_params.cert_verifier = context->cert_verifier(); - session_params.transport_security_state = - context->transport_security_state(); - session_params.proxy_service = context->proxy_service(); - session_params.ssl_config_service = context->ssl_config_service(); - session_params.http_auth_handler_factory = - context->http_auth_handler_factory(); - session_params.network_delegate = context->network_delegate(); - session_params.http_server_properties = - context->http_server_properties(); - session_params.net_log = context->net_log(); scoped_refptr<net::HttpNetworkSession> network_session( - new net::HttpNetworkSession(session_params)); + new net::HttpNetworkSession(network_session_params)); http_transaction_factory = new HttpNetworkLayer(network_session); } diff --git a/net/url_request/url_request_context_builder.h b/net/url_request/url_request_context_builder.h index 7d19236..ddbca53 100644 --- a/net/url_request/url_request_context_builder.h +++ b/net/url_request/url_request_context_builder.h @@ -25,6 +25,7 @@ namespace net { +class HostMappingRules; class ProxyConfigService; class URLRequestContext; @@ -62,6 +63,19 @@ class NET_EXPORT URLRequestContextBuilder { FilePath path; }; + struct NET_EXPORT HttpNetworkSessionParams { + HttpNetworkSessionParams(); + ~HttpNetworkSessionParams(); + + // These fields mirror those in net::HttpNetworkSession::Params; + bool ignore_certificate_errors; + HostMappingRules* host_mapping_rules; + bool http_pipelining_enabled; + uint16 testing_fixed_http_port; + uint16 testing_fixed_https_port; + std::string trusted_spdy_proxy; + }; + URLRequestContextBuilder(); ~URLRequestContextBuilder(); @@ -90,6 +104,12 @@ class NET_EXPORT URLRequestContextBuilder { void EnableHttpCache(const HttpCacheParams& params); void DisableHttpCache(); + // Override default net::HttpNetworkSession::Params settings. + void set_http_network_session_params( + const HttpNetworkSessionParams& http_network_session_params) { + http_network_session_params_ = http_network_session_params; + } + URLRequestContext* Build(); private: @@ -98,6 +118,7 @@ class NET_EXPORT URLRequestContextBuilder { HostResolverParams host_resolver_params_; bool http_cache_enabled_; HttpCacheParams http_cache_params_; + HttpNetworkSessionParams http_network_session_params_; #if defined(OS_LINUX) scoped_ptr<ProxyConfigService> proxy_config_service_; #endif // defined(OS_LINUX) |