summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-19 21:48:42 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-19 21:48:42 +0000
commitdb36938cb26cf265a5fd93690a8e783d01406958 (patch)
tree7261d389592cdfbbb3063f223455518db12d3bda /net/http
parent0d1872ebba9b790f3a33bcaecc11258ea924b397 (diff)
downloadchromium_src-db36938cb26cf265a5fd93690a8e783d01406958.zip
chromium_src-db36938cb26cf265a5fd93690a8e783d01406958.tar.gz
chromium_src-db36938cb26cf265a5fd93690a8e783d01406958.tar.bz2
Pref-backed SSLConfigService for Linux.
Makes SSLConfigService into a ref-counted interface, and makes Profile own an SSLConfigServiceFactory which is used to create the SSLConfigService and pass it through the URLRequestContext on down to where it is actually used. R=eroman,wtc BUG=11507,19290 Review URL: http://codereview.chromium.org/165003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23757 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_cache.cc6
-rw-r--r--net/http/http_cache.h3
-rw-r--r--net/http/http_network_layer.cc13
-rw-r--r--net/http/http_network_layer.h13
-rw-r--r--net/http/http_network_layer_unittest.cc10
-rw-r--r--net/http/http_network_session.cc7
-rw-r--r--net/http/http_network_session.h12
-rw-r--r--net/http/http_network_transaction.cc3
-rw-r--r--net/http/http_network_transaction_unittest.cc15
9 files changed, 53 insertions, 29 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 4d9802a..1299111 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -1505,13 +1505,14 @@ int HttpCache::Transaction::DoPartialCacheReadCompleted(int result) {
HttpCache::HttpCache(HostResolver* host_resolver,
ProxyService* proxy_service,
+ SSLConfigService* ssl_config_service,
const std::wstring& cache_dir,
int cache_size)
: disk_cache_dir_(cache_dir),
mode_(NORMAL),
type_(DISK_CACHE),
network_layer_(HttpNetworkLayer::CreateFactory(
- host_resolver, proxy_service)),
+ host_resolver, proxy_service, ssl_config_service)),
ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
in_memory_cache_(false),
deleted_(false),
@@ -1533,11 +1534,12 @@ HttpCache::HttpCache(HttpNetworkSession* session,
HttpCache::HttpCache(HostResolver* host_resolver,
ProxyService* proxy_service,
+ SSLConfigService* ssl_config_service,
int cache_size)
: mode_(NORMAL),
type_(MEMORY_CACHE),
network_layer_(HttpNetworkLayer::CreateFactory(
- host_resolver, proxy_service)),
+ host_resolver, proxy_service, ssl_config_service)),
ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
in_memory_cache_(true),
deleted_(false),
diff --git a/net/http/http_cache.h b/net/http/http_cache.h
index 1a76180..19c4331 100644
--- a/net/http/http_cache.h
+++ b/net/http/http_cache.h
@@ -36,6 +36,7 @@ class HttpNetworkSession;
class HttpRequestInfo;
class HttpResponseInfo;
class ProxyService;
+class SSLConfigService;
class HttpCache : public HttpTransactionFactory {
public:
@@ -60,6 +61,7 @@ class HttpCache : public HttpTransactionFactory {
// |cache_size| is zero, a default value will be calculated automatically.
HttpCache(HostResolver* host_resolver,
ProxyService* proxy_service,
+ SSLConfigService* ssl_config_service,
const std::wstring& cache_dir,
int cache_size);
@@ -77,6 +79,7 @@ class HttpCache : public HttpTransactionFactory {
// value will be calculated automatically.
HttpCache(HostResolver* host_resolver,
ProxyService* proxy_service,
+ SSLConfigService* ssl_config_service,
int cache_size);
// Initialize the cache from its component parts, which is useful for
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc
index 7f5c142..87969ba 100644
--- a/net/http/http_network_layer.cc
+++ b/net/http/http_network_layer.cc
@@ -16,11 +16,12 @@ namespace net {
// static
HttpTransactionFactory* HttpNetworkLayer::CreateFactory(
HostResolver* host_resolver,
- ProxyService* proxy_service) {
+ ProxyService* proxy_service,
+ SSLConfigService* ssl_config_service) {
DCHECK(proxy_service);
return new HttpNetworkLayer(ClientSocketFactory::GetDefaultFactory(),
- host_resolver, proxy_service);
+ host_resolver, proxy_service, ssl_config_service);
}
// static
@@ -35,17 +36,21 @@ HttpTransactionFactory* HttpNetworkLayer::CreateFactory(
HttpNetworkLayer::HttpNetworkLayer(ClientSocketFactory* socket_factory,
HostResolver* host_resolver,
- ProxyService* proxy_service)
+ ProxyService* proxy_service,
+ SSLConfigService* ssl_config_service)
: socket_factory_(socket_factory),
host_resolver_(host_resolver),
proxy_service_(proxy_service),
+ ssl_config_service_(ssl_config_service),
session_(NULL),
suspended_(false) {
DCHECK(proxy_service_);
+ DCHECK(ssl_config_service_.get());
}
HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session)
: socket_factory_(ClientSocketFactory::GetDefaultFactory()),
+ ssl_config_service_(NULL),
session_(session),
suspended_(false) {
DCHECK(session_.get());
@@ -76,7 +81,7 @@ HttpNetworkSession* HttpNetworkLayer::GetSession() {
if (!session_) {
DCHECK(proxy_service_);
session_ = new HttpNetworkSession(host_resolver_, proxy_service_,
- socket_factory_);
+ socket_factory_, ssl_config_service_);
// These were just temps for lazy-initializing HttpNetworkSession.
host_resolver_ = NULL;
proxy_service_ = NULL;
diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h
index bd3cb68..c920ce1 100644
--- a/net/http/http_network_layer.h
+++ b/net/http/http_network_layer.h
@@ -16,13 +16,15 @@ class HostResolver;
class HttpNetworkSession;
class ProxyInfo;
class ProxyService;
+class SSLConfigService;
class HttpNetworkLayer : public HttpTransactionFactory {
public:
// |socket_factory|, |proxy_service| and |host_resolver| must remain valid
// for the lifetime of HttpNetworkLayer.
HttpNetworkLayer(ClientSocketFactory* socket_factory,
- HostResolver* host_resolver, ProxyService* proxy_service);
+ HostResolver* host_resolver, ProxyService* proxy_service,
+ SSLConfigService* ssl_config_service);
// Construct a HttpNetworkLayer with an existing HttpNetworkSession which
// contains a valid ProxyService.
explicit HttpNetworkLayer(HttpNetworkSession* session);
@@ -30,8 +32,10 @@ class HttpNetworkLayer : public HttpTransactionFactory {
// This function hides the details of how a network layer gets instantiated
// and allows other implementations to be substituted.
- static HttpTransactionFactory* CreateFactory(HostResolver* host_resolver,
- ProxyService* proxy_service);
+ static HttpTransactionFactory* CreateFactory(
+ HostResolver* host_resolver,
+ ProxyService* proxy_service,
+ SSLConfigService* ssl_config_service);
// Create a transaction factory that instantiate a network layer over an
// existing network session. Network session contains some valuable
// information (e.g. authentication data) that we want to share across
@@ -56,6 +60,9 @@ class HttpNetworkLayer : public HttpTransactionFactory {
scoped_refptr<HostResolver> host_resolver_;
scoped_refptr<ProxyService> proxy_service_;
+ // The SSL config service being used for the session.
+ scoped_refptr<SSLConfigService> ssl_config_service_;
+
scoped_refptr<HttpNetworkSession> session_;
bool suspended_;
};
diff --git a/net/http/http_network_layer_unittest.cc b/net/http/http_network_layer_unittest.cc
index 0d32335..73d83ec 100644
--- a/net/http/http_network_layer_unittest.cc
+++ b/net/http/http_network_layer_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "net/base/mock_host_resolver.h"
+#include "net/base/ssl_config_service_defaults.h"
#include "net/http/http_network_layer.h"
#include "net/http/http_transaction_unittest.h"
#include "net/proxy/proxy_service.h"
@@ -15,14 +16,16 @@ class HttpNetworkLayerTest : public PlatformTest {
TEST_F(HttpNetworkLayerTest, CreateAndDestroy) {
net::HttpNetworkLayer factory(
- NULL, new net::MockHostResolver, net::ProxyService::CreateNull());
+ NULL, new net::MockHostResolver, net::ProxyService::CreateNull(),
+ new net::SSLConfigServiceDefaults);
scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction());
}
TEST_F(HttpNetworkLayerTest, Suspend) {
net::HttpNetworkLayer factory(
- NULL, new net::MockHostResolver, net::ProxyService::CreateNull());
+ NULL, new net::MockHostResolver, net::ProxyService::CreateNull(),
+ new net::SSLConfigServiceDefaults);
scoped_ptr<net::HttpTransaction> trans(factory.CreateTransaction());
trans.reset();
@@ -54,7 +57,8 @@ TEST_F(HttpNetworkLayerTest, GET) {
mock_socket_factory.AddMockSocket(&data);
net::HttpNetworkLayer factory(&mock_socket_factory, new net::MockHostResolver,
- net::ProxyService::CreateNull());
+ net::ProxyService::CreateNull(),
+ new net::SSLConfigServiceDefaults);
TestCompletionCallback callback;
diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc
index b7d32c2..8525e51 100644
--- a/net/http/http_network_session.cc
+++ b/net/http/http_network_session.cc
@@ -17,13 +17,16 @@ int HttpNetworkSession::max_sockets_per_group_ = 6;
HttpNetworkSession::HttpNetworkSession(
HostResolver* host_resolver,
ProxyService* proxy_service,
- ClientSocketFactory* client_socket_factory)
+ ClientSocketFactory* client_socket_factory,
+ SSLConfigService* ssl_config_service)
: tcp_socket_pool_(new TCPClientSocketPool(
max_sockets_, max_sockets_per_group_, host_resolver,
client_socket_factory)),
host_resolver_(host_resolver),
- proxy_service_(proxy_service) {
+ proxy_service_(proxy_service),
+ ssl_config_service_(ssl_config_service) {
DCHECK(proxy_service);
+ DCHECK(ssl_config_service);
}
// static
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index b6327c6..94555ef 100644
--- a/net/http/http_network_session.h
+++ b/net/http/http_network_session.h
@@ -21,7 +21,8 @@ class ClientSocketFactory;
class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
public:
HttpNetworkSession(HostResolver* host_resolver, ProxyService* proxy_service,
- ClientSocketFactory* client_socket_factory);
+ ClientSocketFactory* client_socket_factory,
+ SSLConfigService* ssl_config_service);
HttpAuthCache* auth_cache() { return &auth_cache_; }
SSLClientAuthCache* ssl_client_auth_cache() {
@@ -31,9 +32,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
TCPClientSocketPool* tcp_socket_pool() { return tcp_socket_pool_; }
HostResolver* host_resolver() { return host_resolver_; }
ProxyService* proxy_service() { return proxy_service_; }
-#if defined(OS_WIN)
- SSLConfigService* ssl_config_service() { return &ssl_config_service_; }
-#endif
+ SSLConfigService* ssl_config_service() { return ssl_config_service_; }
static void set_max_sockets_per_group(int socket_count);
@@ -53,10 +52,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
scoped_refptr<TCPClientSocketPool> tcp_socket_pool_;
scoped_refptr<HostResolver> host_resolver_;
scoped_refptr<ProxyService> proxy_service_;
-#if defined(OS_WIN)
- // TODO(port): Port the SSLConfigService class to Linux and Mac OS X.
- SSLConfigService ssl_config_service_;
-#endif
+ scoped_refptr<SSLConfigService> ssl_config_service_;
};
} // namespace net
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 7d2e6da..79be223 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -155,10 +155,7 @@ HttpNetworkTransaction::HttpNetworkTransaction(HttpNetworkSession* session,
response_body_read_(0),
read_buf_len_(0),
next_state_(STATE_NONE) {
-#if defined(OS_WIN)
- // TODO(port): Port the SSLConfigService class to Linux and Mac OS X.
session->ssl_config_service()->GetSSLConfig(&ssl_config_);
-#endif
}
int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info,
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 164450e..d19df2c 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -7,6 +7,7 @@
#include "base/compiler_specific.h"
#include "net/base/completion_callback.h"
#include "net/base/mock_host_resolver.h"
+#include "net/base/ssl_config_service_defaults.h"
#include "net/base/ssl_info.h"
#include "net/base/test_completion_callback.h"
#include "net/base/upload_data.h"
@@ -35,15 +36,20 @@ ProxyService* CreateNullProxyService() {
class SessionDependencies {
public:
// Default set of dependencies -- "null" proxy service.
- SessionDependencies() : host_resolver(new MockHostResolver),
- proxy_service(CreateNullProxyService()) {}
+ SessionDependencies()
+ : host_resolver(new MockHostResolver),
+ proxy_service(CreateNullProxyService()),
+ ssl_config_service(new SSLConfigServiceDefaults) {}
// Custom proxy service dependency.
explicit SessionDependencies(ProxyService* proxy_service)
- : host_resolver(new MockHostResolver), proxy_service(proxy_service) {}
+ : host_resolver(new MockHostResolver),
+ proxy_service(proxy_service),
+ ssl_config_service(new SSLConfigServiceDefaults) {}
scoped_refptr<MockHostResolverBase> host_resolver;
scoped_refptr<ProxyService> proxy_service;
+ scoped_refptr<SSLConfigService> ssl_config_service;
MockClientSocketFactory socket_factory;
};
@@ -57,7 +63,8 @@ ProxyService* CreateFixedProxyService(const std::string& proxy) {
HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
return new HttpNetworkSession(session_deps->host_resolver,
session_deps->proxy_service,
- &session_deps->socket_factory);
+ &session_deps->socket_factory,
+ session_deps->ssl_config_service);
}
class HttpNetworkTransactionTest : public PlatformTest {