diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_cache.cc | 66 | ||||
-rw-r--r-- | net/http/http_cache.h | 16 | ||||
-rw-r--r-- | net/http/http_network_session.cc | 7 | ||||
-rw-r--r-- | net/http/http_network_session.h | 9 | ||||
-rw-r--r-- | net/http/http_pipelined_network_transaction_unittest.cc | 12 | ||||
-rw-r--r-- | net/http/http_stream_factory.cc | 35 | ||||
-rw-r--r-- | net/http/http_stream_factory.h | 39 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl.cc | 4 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl.h | 1 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl_job.cc | 6 | ||||
-rw-r--r-- | net/socket/client_socket_pool_manager.cc | 10 | ||||
-rw-r--r-- | net/socket_stream/socket_stream.cc | 9 | ||||
-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 |
16 files changed, 131 insertions, 190 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index 8579471..f7dfc2d 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -38,39 +38,6 @@ namespace net { -namespace { - -HttpNetworkSession* CreateNetworkSession( - HostResolver* host_resolver, - CertVerifier* cert_verifier, - ServerBoundCertService* server_bound_cert_service, - TransportSecurityState* transport_security_state, - ProxyService* proxy_service, - const std::string& ssl_session_cache_shard, - SSLConfigService* ssl_config_service, - HttpAuthHandlerFactory* http_auth_handler_factory, - NetworkDelegate* network_delegate, - HttpServerProperties* http_server_properties, - NetLog* net_log, - const std::string& trusted_spdy_proxy) { - HttpNetworkSession::Params params; - params.host_resolver = host_resolver; - params.cert_verifier = cert_verifier; - params.server_bound_cert_service = server_bound_cert_service; - params.transport_security_state = transport_security_state; - params.proxy_service = proxy_service; - params.ssl_session_cache_shard = ssl_session_cache_shard; - params.ssl_config_service = ssl_config_service; - params.http_auth_handler_factory = http_auth_handler_factory; - params.network_delegate = network_delegate; - params.http_server_properties = http_server_properties; - params.net_log = net_log; - params.trusted_spdy_proxy = trusted_spdy_proxy; - return new HttpNetworkSession(params); -} - -} // namespace - HttpCache::DefaultBackend::DefaultBackend(CacheType type, const FilePath& path, int max_bytes, @@ -275,38 +242,13 @@ void HttpCache::MetadataWriter::OnIOComplete(int result) { //----------------------------------------------------------------------------- -HttpCache::HttpCache(HostResolver* host_resolver, - CertVerifier* cert_verifier, - ServerBoundCertService* server_bound_cert_service, - TransportSecurityState* transport_security_state, - ProxyService* proxy_service, - const std::string& ssl_session_cache_shard, - SSLConfigService* ssl_config_service, - HttpAuthHandlerFactory* http_auth_handler_factory, - NetworkDelegate* network_delegate, - HttpServerProperties* http_server_properties, - NetLog* net_log, - BackendFactory* backend_factory, - const std::string& trusted_spdy_proxy) - : net_log_(net_log), +HttpCache::HttpCache(const net::HttpNetworkSession::Params& params, + BackendFactory* backend_factory) + : net_log_(params.net_log), backend_factory_(backend_factory), building_backend_(false), mode_(NORMAL), - network_layer_( - new HttpNetworkLayer( - CreateNetworkSession( - host_resolver, - cert_verifier, - server_bound_cert_service, - transport_security_state, - proxy_service, - ssl_session_cache_shard, - ssl_config_service, - http_auth_handler_factory, - network_delegate, - http_server_properties, - net_log, - trusted_spdy_proxy))) { + network_layer_(new HttpNetworkLayer(new HttpNetworkSession(params))) { } diff --git a/net/http/http_cache.h b/net/http/http_cache.h index 4ff00b5..60e5875 100644 --- a/net/http/http_cache.h +++ b/net/http/http_cache.h @@ -30,6 +30,7 @@ #include "net/base/completion_callback.h" #include "net/base/load_states.h" #include "net/base/net_export.h" +#include "net/http/http_network_session.h" #include "net/http/http_transaction_factory.h" class GURL; @@ -118,19 +119,8 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory, // The disk cache is initialized lazily (by CreateTransaction) in this case. // The HttpCache takes ownership of the |backend_factory|. - HttpCache(HostResolver* host_resolver, - CertVerifier* cert_verifier, - ServerBoundCertService* server_bound_cert_service, - TransportSecurityState* transport_security_state, - ProxyService* proxy_service, - const std::string& ssl_session_cache_shard, - SSLConfigService* ssl_config_service, - HttpAuthHandlerFactory* http_auth_handler_factory, - NetworkDelegate* network_delegate, - HttpServerProperties* http_server_properties, - NetLog* net_log, - BackendFactory* backend_factory, - const std::string& trusted_spdy_proxy); + HttpCache(const net::HttpNetworkSession::Params& params, + BackendFactory* backend_factory); // The disk cache is initialized lazily (by CreateTransaction) in this case. // Provide an existing HttpNetworkSession, the cache can construct a diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc index 124c570..c54325cf 100644 --- a/net/http/http_network_session.cc +++ b/net/http/http_network_session.cc @@ -58,7 +58,12 @@ HttpNetworkSession::Params::Params() network_delegate(NULL), http_server_properties(NULL), net_log(NULL), - force_http_pipelining(false) {} + host_mapping_rules(NULL), + force_http_pipelining(false), + ignore_certificate_errors(false), + http_pipelining_enabled(false), + testing_fixed_http_port(0), + testing_fixed_https_port(0) {} // TODO(mbelshe): Move the socket factories into HttpStreamFactory. HttpNetworkSession::HttpNetworkSession(const Params& params) diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index 3a9d72c..47abaec 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -61,7 +61,12 @@ class NET_EXPORT HttpNetworkSession NetworkDelegate* network_delegate; HttpServerProperties* http_server_properties; NetLog* net_log; + HostMappingRules* host_mapping_rules; bool force_http_pipelining; + bool ignore_certificate_errors; + bool http_pipelining_enabled; + uint16 testing_fixed_http_port; + uint16 testing_fixed_https_port; std::string trusted_spdy_proxy; }; @@ -130,6 +135,10 @@ class NET_EXPORT HttpNetworkSession // Returns the original Params used to construct this session. const Params& params() const { return params_; } + void set_http_pipelining_enabled(bool enable) { + params_.http_pipelining_enabled = enable; + } + private: friend class base::RefCounted<HttpNetworkSession>; friend class HttpNetworkSessionPeer; diff --git a/net/http/http_pipelined_network_transaction_unittest.cc b/net/http/http_pipelined_network_transaction_unittest.cc index ecdb07a4..d5d87d0 100644 --- a/net/http/http_pipelined_network_transaction_unittest.cc +++ b/net/http/http_pipelined_network_transaction_unittest.cc @@ -72,16 +72,6 @@ class HttpPipelinedNetworkTransactionTest : public testing::Test { pool_(1, 1, &histograms_, &factory_) { } - virtual void SetUp() OVERRIDE { - default_pipelining_enabled_ = HttpStreamFactory::http_pipelining_enabled(); - HttpStreamFactory::set_http_pipelining_enabled(true); - } - - virtual void TearDown() OVERRIDE { - MessageLoop::current()->RunAllPending(); - HttpStreamFactory::set_http_pipelining_enabled(default_pipelining_enabled_); - } - void Initialize(bool force_http_pipelining) { // Normally, this code could just go in SetUp(). For a few of these tests, // we change the default number of sockets per group. That needs to be done @@ -99,6 +89,7 @@ class HttpPipelinedNetworkTransactionTest : public testing::Test { session_params.http_auth_handler_factory = auth_handler_factory_.get(); session_params.http_server_properties = &http_server_properties_; session_params.force_http_pipelining = force_http_pipelining; + session_params.http_pipelining_enabled = true; session_ = new HttpNetworkSession(session_params); } @@ -231,7 +222,6 @@ class HttpPipelinedNetworkTransactionTest : public testing::Test { ScopedVector<DeterministicSocketData> data_vector_; TestCompletionCallback callback_; ScopedVector<HttpRequestInfo> request_info_vector_; - bool default_pipelining_enabled_; SimpleProxyConfigService* proxy_config_service_; scoped_ptr<ProxyService> proxy_service_; diff --git a/net/http/http_stream_factory.cc b/net/http/http_stream_factory.cc index ca3b294..a92f9fc 100644 --- a/net/http/http_stream_factory.cc +++ b/net/http/http_stream_factory.cc @@ -17,8 +17,6 @@ namespace net { // with |ResetStaticSettingsToInit|. This is critical for unit test isolation. // static -const HostMappingRules* HttpStreamFactory::host_mapping_rules_ = NULL; -// static std::vector<std::string>* HttpStreamFactory::next_protos_ = NULL; // static bool HttpStreamFactory::enabled_protocols_[NUM_ALTERNATE_PROTOCOLS]; @@ -32,31 +30,20 @@ bool HttpStreamFactory::force_spdy_over_ssl_ = true; bool HttpStreamFactory::force_spdy_always_ = false; // static std::list<HostPortPair>* HttpStreamFactory::forced_spdy_exclusions_ = NULL; -// static -bool HttpStreamFactory::ignore_certificate_errors_ = false; -// static -bool HttpStreamFactory::http_pipelining_enabled_ = false; -// static -uint16 HttpStreamFactory::testing_fixed_http_port_ = 0; -// static -uint16 HttpStreamFactory::testing_fixed_https_port_ = 0; HttpStreamFactory::~HttpStreamFactory() {} // static void HttpStreamFactory::ResetStaticSettingsToInit() { // WARNING: These must match the initializers above. - delete host_mapping_rules_; delete next_protos_; delete forced_spdy_exclusions_; - host_mapping_rules_ = NULL; next_protos_ = NULL; spdy_enabled_ = true; use_alternate_protocols_ = false; force_spdy_over_ssl_ = true; force_spdy_always_ = false; forced_spdy_exclusions_ = NULL; - ignore_certificate_errors_ = false; for (int i = 0; i < NUM_ALTERNATE_PROTOCOLS; ++i) enabled_protocols_[i] = false; } @@ -100,7 +87,9 @@ void HttpStreamFactory::ProcessAlternateProtocol( } HostPortPair host_port(http_host_port_pair); - host_mapping_rules().RewriteHost(&host_port); + const HostMappingRules* mapping_rules = GetHostMappingRules(); + if (mapping_rules) + mapping_rules->RewriteHost(&host_port); if (http_server_properties->HasAlternateProtocol(host_port)) { const PortAlternateProtocolPair existing_alternate = @@ -115,7 +104,8 @@ void HttpStreamFactory::ProcessAlternateProtocol( GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, HostPortPair* endpoint) { - if (host_mapping_rules().RewriteHost(endpoint)) { + const HostMappingRules* mapping_rules = GetHostMappingRules(); + if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { url_canon::Replacements<char> replacements; const std::string port_str = base::IntToString(endpoint->port()); replacements.SetPort(port_str.c_str(), @@ -202,21 +192,6 @@ void HttpStreamFactory::SetNextProtos(const std::vector<std::string>& value) { enabled_protocols_[NPN_SPDY_1] = false; } -// static -void HttpStreamFactory::SetHostMappingRules(const std::string& rules) { - HostMappingRules* host_mapping_rules = new HostMappingRules; - host_mapping_rules->SetRulesFromString(rules); - delete host_mapping_rules_; - host_mapping_rules_ = host_mapping_rules; -} - HttpStreamFactory::HttpStreamFactory() {} -// static -const HostMappingRules& HttpStreamFactory::host_mapping_rules() { - if (!host_mapping_rules_) - host_mapping_rules_ = new HostMappingRules; - return *host_mapping_rules_; -} - } // namespace net diff --git a/net/http/http_stream_factory.h b/net/http/http_stream_factory.h index df9cecf..7371010 100644 --- a/net/http/http_stream_factory.h +++ b/net/http/http_stream_factory.h @@ -163,6 +163,8 @@ class NET_EXPORT HttpStreamFactory { const std::string& alternate_protocol_str, const HostPortPair& http_host_port_pair); + GURL ApplyHostMappingRules(const GURL& url, HostPortPair* endpoint); + // Virtual interface methods. // Request a stream. @@ -185,13 +187,13 @@ class NET_EXPORT HttpStreamFactory { // returns an empty Value. virtual base::Value* PipelineInfoToValue() const = 0; + virtual const HostMappingRules* GetHostMappingRules() const = 0; + // Static settings // Reset all static settings to initialized values. Used to init test suite. static void ResetStaticSettingsToInit(); - static GURL ApplyHostMappingRules(const GURL& url, HostPortPair* endpoint); - // Turns spdy on or off. static void set_spdy_enabled(bool value) { spdy_enabled_ = value; @@ -245,39 +247,10 @@ class NET_EXPORT HttpStreamFactory { return *next_protos_; } - // Sets the HttpStreamFactoryImpl into a mode where it can ignore certificate - // errors. This is for testing. - static void set_ignore_certificate_errors(bool value) { - ignore_certificate_errors_ = value; - } - static bool ignore_certificate_errors() { - return ignore_certificate_errors_; - } - - static void SetHostMappingRules(const std::string& rules); - - static void set_http_pipelining_enabled(bool value) { - http_pipelining_enabled_ = value; - } - static bool http_pipelining_enabled() { return http_pipelining_enabled_; } - - static void set_testing_fixed_http_port(int port) { - testing_fixed_http_port_ = port; - } - static uint16 testing_fixed_http_port() { return testing_fixed_http_port_; } - - static void set_testing_fixed_https_port(int port) { - testing_fixed_https_port_ = port; - } - static uint16 testing_fixed_https_port() { return testing_fixed_https_port_; } - protected: HttpStreamFactory(); private: - static const HostMappingRules& host_mapping_rules(); - - static const HostMappingRules* host_mapping_rules_; static std::vector<std::string>* next_protos_; static bool enabled_protocols_[NUM_ALTERNATE_PROTOCOLS]; static bool spdy_enabled_; @@ -285,10 +258,6 @@ class NET_EXPORT HttpStreamFactory { static bool force_spdy_over_ssl_; static bool force_spdy_always_; static std::list<HostPortPair>* forced_spdy_exclusions_; - static bool ignore_certificate_errors_; - static bool http_pipelining_enabled_; - static uint16 testing_fixed_http_port_; - static uint16 testing_fixed_https_port_; DISALLOW_COPY_AND_ASSIGN(HttpStreamFactory); }; diff --git a/net/http/http_stream_factory_impl.cc b/net/http/http_stream_factory_impl.cc index 75e7365..5896a93 100644 --- a/net/http/http_stream_factory_impl.cc +++ b/net/http/http_stream_factory_impl.cc @@ -123,6 +123,10 @@ base::Value* HttpStreamFactoryImpl::PipelineInfoToValue() const { return http_pipelined_host_pool_.PipelineInfoToValue(); } +const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { + return session_->params().host_mapping_rules; +} + bool HttpStreamFactoryImpl::GetAlternateProtocolRequestFor( const GURL& original_url, GURL* alternate_url) const { diff --git a/net/http/http_stream_factory_impl.h b/net/http/http_stream_factory_impl.h index 2542298..213d96a 100644 --- a/net/http/http_stream_factory_impl.h +++ b/net/http/http_stream_factory_impl.h @@ -43,6 +43,7 @@ class NET_EXPORT_PRIVATE HttpStreamFactoryImpl : const SSLConfig& server_ssl_config, const SSLConfig& proxy_ssl_config) OVERRIDE; virtual base::Value* PipelineInfoToValue() const OVERRIDE; + virtual const HostMappingRules* GetHostMappingRules() const OVERRIDE; // HttpPipelinedHostPool::Delegate interface virtual void OnHttpPipelinedHostHasAdditionalCapacity( diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc index cdab39b..ddd5ae6 100644 --- a/net/http/http_stream_factory_impl_job.cc +++ b/net/http/http_stream_factory_impl_job.cc @@ -561,7 +561,7 @@ int HttpStreamFactoryImpl::Job::StartInternal() { int HttpStreamFactoryImpl::Job::DoStart() { int port = request_info_.url.EffectiveIntPort(); origin_ = HostPortPair(request_info_.url.HostNoBrackets(), port); - origin_url_ = HttpStreamFactory::ApplyHostMappingRules( + origin_url_ = stream_factory_->ApplyHostMappingRules( request_info_.url, &origin_); http_pipelining_key_.reset(new HttpPipelinedHost::Key(origin_)); @@ -1206,7 +1206,7 @@ int HttpStreamFactoryImpl::Job::HandleCertificateError(int error) { server_ssl_config_.allowed_bad_certs.push_back(bad_cert); int load_flags = request_info_.load_flags; - if (HttpStreamFactory::ignore_certificate_errors()) + if (session_->params().ignore_certificate_errors) load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; if (ssl_socket->IgnoreCertError(error, load_flags)) return OK; @@ -1268,7 +1268,7 @@ bool HttpStreamFactoryImpl::Job::IsRequestEligibleForPipelining() { if (session_->force_http_pipelining()) { return true; } - if (!HttpStreamFactory::http_pipelining_enabled()) { + if (!session_->params().http_pipelining_enabled) { return false; } if (using_ssl_) { diff --git a/net/socket/client_socket_pool_manager.cc b/net/socket/client_socket_pool_manager.cc index d5591b7..5884e08 100644 --- a/net/socket/client_socket_pool_manager.cc +++ b/net/socket/client_socket_pool_manager.cc @@ -93,10 +93,10 @@ int InitSocketPoolHelper(const GURL& request_url, HostPortPair(request_url.HostNoBrackets(), request_url.EffectiveIntPort()); - if (!using_ssl && HttpStreamFactory::testing_fixed_http_port() != 0) { - origin_host_port.set_port(HttpStreamFactory::testing_fixed_http_port()); - } else if (using_ssl && HttpStreamFactory::testing_fixed_https_port() != 0) { - origin_host_port.set_port(HttpStreamFactory::testing_fixed_https_port()); + if (!using_ssl && session->params().testing_fixed_http_port != 0) { + origin_host_port.set_port(session->params().testing_fixed_http_port); + } else if (using_ssl && session->params().testing_fixed_https_port != 0) { + origin_host_port.set_port(session->params().testing_fixed_https_port); } bool disable_resolver_cache = @@ -105,7 +105,7 @@ int InitSocketPoolHelper(const GURL& request_url, request_load_flags & LOAD_DISABLE_CACHE; int load_flags = request_load_flags; - if (HttpStreamFactory::ignore_certificate_errors()) + if (session->params().ignore_certificate_errors) load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; // Build the string used to uniquely identify connections of this type. diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc index f656cb8..41d77ed 100644 --- a/net/socket_stream/socket_stream.cc +++ b/net/socket_stream/socket_stream.cc @@ -1301,9 +1301,12 @@ int SocketStream::HandleCertificateError(int result) { SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(socket_.get()); DCHECK(ssl_socket); - if (HttpStreamFactory::ignore_certificate_errors() && - ssl_socket->IgnoreCertError(result, LOAD_IGNORE_ALL_CERT_ERRORS)) - return OK; + if (SSLClientSocket::IgnoreCertError(result, LOAD_IGNORE_ALL_CERT_ERRORS)) { + const HttpNetworkSession::Params* session_params = + context_->GetNetworkSessionParams(); + if (session_params && session_params->ignore_certificate_errors) + return OK; + } if (!delegate_) return result; 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) |