summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 06:33:58 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 06:33:58 +0000
commit57cb0f76bceab5f05f3d14a23e764795b476f3d3 (patch)
treea8c549a7c8e18f1e581cfba2ee78bca33699abf9 /chrome/browser/net
parentd8397a8c9673136fe1deae24367b989e97f54bfb (diff)
downloadchromium_src-57cb0f76bceab5f05f3d14a23e764795b476f3d3.zip
chromium_src-57cb0f76bceab5f05f3d14a23e764795b476f3d3.tar.gz
chromium_src-57cb0f76bceab5f05f3d14a23e764795b476f3d3.tar.bz2
Simplify HttpCache/HttpNetworkLayer/HttpNetworkSession interaction.
Eliminate lazy initialization of HttpNetworkSession in HttpNetworkLayer. * This eliminates the need to update parameters for HttpNetworkLayer, it just takes a HttpNetworkSession. * It is OK to eliminate lazy initialization since these variables are cheap. BUG=none TEST=none Review URL: http://codereview.chromium.org/6402002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72931 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc53
-rw-r--r--chrome/browser/net/connection_tester.cc24
-rw-r--r--chrome/browser/net/connection_tester_unittest.cc15
3 files changed, 40 insertions, 52 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index d3850df..dc6853a 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -281,17 +281,17 @@ ChromeURLRequestContext* FactoryForOriginal::Create() {
net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend(
net::DISK_CACHE, disk_cache_path_, cache_size_,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
- net::HttpCache* cache =
- new net::HttpCache(context->host_resolver(),
- context->cert_verifier(),
- context->dnsrr_resolver(),
- context->dns_cert_checker(),
- context->proxy_service(),
- context->ssl_config_service(),
- context->http_auth_handler_factory(),
- &io_thread_globals->network_delegate,
- io_thread()->net_log(),
- backend);
+ net::HttpCache* cache = new net::HttpCache(
+ context->host_resolver(),
+ context->cert_verifier(),
+ context->dnsrr_resolver(),
+ context->dns_cert_checker(),
+ context->proxy_service(),
+ context->ssl_config_service(),
+ context->http_auth_handler_factory(),
+ &io_thread_globals->network_delegate,
+ io_thread()->net_log(),
+ backend);
bool record_mode = chrome::kRecordModeEnabled &&
command_line.HasSwitch(switches::kRecordMode);
@@ -491,35 +491,8 @@ ChromeURLRequestContext* FactoryForMedia::Create() {
net::HttpCache* main_cache =
main_context->http_transaction_factory()->GetCache();
- net::HttpCache* cache;
- if (main_cache) {
- // Try to reuse HttpNetworkSession in the main context, assuming that
- // HttpTransactionFactory (network_layer()) of HttpCache is implemented
- // by HttpNetworkLayer so we can reuse HttpNetworkSession within it. This
- // assumption will be invalid if the original HttpCache is constructed with
- // HttpCache(HttpTransactionFactory*, BackendFactory*) constructor.
- net::HttpNetworkLayer* main_network_layer =
- static_cast<net::HttpNetworkLayer*>(main_cache->network_layer());
- cache = new net::HttpCache(main_network_layer->GetSession(), backend);
- // TODO(eroman): Since this is poaching the session from the main
- // context, it should hold a reference to that context preventing the
- // session from getting deleted.
- } else {
- // If original HttpCache doesn't exist, simply construct one with a whole
- // new set of network stack.
- cache = new net::HttpCache(
- io_thread_globals->host_resolver.get(),
- io_thread_globals->cert_verifier.get(),
- io_thread_globals->dnsrr_resolver.get(),
- NULL /* dns_cert_checker */,
- main_context->proxy_service(),
- main_context->ssl_config_service(),
- io_thread_globals->http_auth_handler_factory.get(),
- &io_thread_globals->network_delegate,
- io_thread()->net_log(),
- backend);
- }
-
+ net::HttpNetworkSession* network_session = main_cache->GetSession();
+ net::HttpCache* cache = new net::HttpCache(network_session, backend);
context->set_http_transaction_factory(cache);
context->set_net_log(io_thread()->net_log());
diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc
index d68a169..f0f7efe 100644
--- a/chrome/browser/net/connection_tester.cc
+++ b/chrome/browser/net/connection_tester.cc
@@ -25,9 +25,11 @@
#include "net/ftp/ftp_network_layer.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_cache.h"
-#include "net/http/http_network_layer.h"
+#include "net/http/http_network_session.h"
#include "net/proxy/proxy_config_service_fixed.h"
#include "net/proxy/proxy_script_fetcher_impl.h"
+#include "net/socket/client_socket_factory.h"
+#include "net/spdy/spdy_session_pool.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
@@ -67,12 +69,22 @@ class ExperimentURLRequestContext : public net::URLRequestContext {
ssl_config_service_ = new net::SSLConfigServiceDefaults;
http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault(
host_resolver_);
+ scoped_refptr<net::HttpNetworkSession> network_session(
+ new net::HttpNetworkSession(
+ host_resolver_,
+ cert_verifier_,
+ dnsrr_resolver_,
+ NULL /* dns_cert_checker */,
+ NULL /* ssl_host_info_factory */,
+ proxy_service_,
+ net::ClientSocketFactory::GetDefaultFactory(),
+ ssl_config_service_,
+ new net::SpdySessionPool(NULL),
+ http_auth_handler_factory_,
+ NULL /* network_delegate */,
+ NULL /* net_log */));
http_transaction_factory_ = new net::HttpCache(
- net::HttpNetworkLayer::CreateFactory(host_resolver_, cert_verifier_,
- dnsrr_resolver_, NULL /* dns_cert_checker */,
- NULL /* ssl_host_info_factory */, proxy_service_,
- ssl_config_service_, http_auth_handler_factory_, NULL, NULL),
- NULL /* net_log */,
+ network_session,
net::HttpCache::DefaultBackend::InMemory(0));
// In-memory cookie store.
cookie_store_ = new net::CookieMonster(NULL, NULL);
diff --git a/chrome/browser/net/connection_tester_unittest.cc b/chrome/browser/net/connection_tester_unittest.cc
index 8eecd81..f08daf4 100644
--- a/chrome/browser/net/connection_tester_unittest.cc
+++ b/chrome/browser/net/connection_tester_unittest.cc
@@ -14,6 +14,7 @@
#include "net/ftp/ftp_network_layer.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_network_layer.h"
+#include "net/http/http_network_session.h"
#include "net/proxy/proxy_config_service_fixed.h"
#include "net/socket/client_socket_factory.h"
#include "net/spdy/spdy_session_pool.h"
@@ -117,20 +118,22 @@ class ConnectionTesterTest : public PlatformTest {
proxy_service_ = net::ProxyService::CreateDirect();
proxy_script_fetcher_context_->set_proxy_service(proxy_service_);
ssl_config_service_ = net::SSLConfigService::CreateSystemSSLConfigService();
- http_transaction_factory_.reset(
- new net::HttpNetworkLayer(
- client_socket_factory_,
+ scoped_refptr<net::HttpNetworkSession> network_session(
+ new net::HttpNetworkSession(
&host_resolver_,
&cert_verifier_,
&dnsrr_resolver_,
- NULL /* DNS cert provenance checker */,
+ NULL /* dns_cert_checker */,
NULL /* ssl_host_info_factory */,
proxy_service_.get(),
+ client_socket_factory_,
ssl_config_service_,
new net::SpdySessionPool(ssl_config_service_),
&http_auth_handler_factory_,
- NULL /* NetworkDelegate */,
- NULL /* NetLog */));
+ NULL /* network_delegate */,
+ NULL /* net_log */));
+ http_transaction_factory_.reset(
+ new net::HttpNetworkLayer(network_session));
proxy_script_fetcher_context_->set_http_transaction_factory(
http_transaction_factory_.get());
// In-memory cookie store.