diff options
author | cevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-05 22:00:24 +0000 |
---|---|---|
committer | cevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-05 22:00:24 +0000 |
commit | 2b83813511561091e570f15a76ae830e7ccdf8bb (patch) | |
tree | 12c5c160730417696e9cb49f083bd4cc67302851 | |
parent | 746750b6d511d7febcbc8d1930f0bb7971dbbab5 (diff) | |
download | chromium_src-2b83813511561091e570f15a76ae830e7ccdf8bb.zip chromium_src-2b83813511561091e570f15a76ae830e7ccdf8bb.tar.gz chromium_src-2b83813511561091e570f15a76ae830e7ccdf8bb.tar.bz2 |
Refactor to address URLRequestContext dependency added in
http://codereview.chromium.org/6873029/
BUG=81009
Review URL: http://codereview.chromium.org/6930040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84325 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/renderer_host/socket_stream_host.cc | 3 | ||||
-rw-r--r-- | net/base/ssl_config_service.cc | 10 | ||||
-rw-r--r-- | net/base/ssl_config_service.h | 3 | ||||
-rw-r--r-- | net/socket_stream/socket_stream_job.cc | 10 | ||||
-rw-r--r-- | net/socket_stream/socket_stream_job.h | 6 | ||||
-rw-r--r-- | net/url_request/url_request_context.cc | 9 | ||||
-rw-r--r-- | net/url_request/url_request_context.h | 3 | ||||
-rw-r--r-- | net/url_request/url_request_http_job.cc | 9 | ||||
-rw-r--r-- | net/websockets/websocket_job_unittest.cc | 6 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_socket_stream_bridge.cc | 3 |
10 files changed, 37 insertions, 25 deletions
diff --git a/content/browser/renderer_host/socket_stream_host.cc b/content/browser/renderer_host/socket_stream_host.cc index 67350fd..bcbe431 100644 --- a/content/browser/renderer_host/socket_stream_host.cc +++ b/content/browser/renderer_host/socket_stream_host.cc @@ -48,7 +48,8 @@ void SocketStreamHost::Connect(const GURL& url, net::URLRequestContext* request_context) { VLOG(1) << "SocketStreamHost::Connect url=" << url; socket_ = net::SocketStreamJob::CreateSocketStreamJob( - url, delegate_, *request_context); + url, delegate_, request_context->transport_security_state(), + request_context->ssl_config_service()); socket_->set_context(request_context); socket_->SetUserData(kSocketIdKey, new SocketStreamId(socket_id_)); socket_->Connect(); diff --git a/net/base/ssl_config_service.cc b/net/base/ssl_config_service.cc index 09ed84b..722a26d 100644 --- a/net/base/ssl_config_service.cc +++ b/net/base/ssl_config_service.cc @@ -115,4 +115,14 @@ void SSLConfigService::ProcessConfigUpdate(const SSLConfig& orig_config, } } +// static +bool SSLConfigService::IsSNIAvailable(SSLConfigService* service) { + if (!service) + return false; + + SSLConfig ssl_config; + service->GetSSLConfig(&ssl_config); + return ssl_config.tls1_enabled; +} + } // namespace net diff --git a/net/base/ssl_config_service.h b/net/base/ssl_config_service.h index 19d113e..04af2fc 100644 --- a/net/base/ssl_config_service.h +++ b/net/base/ssl_config_service.h @@ -146,6 +146,9 @@ class SSLConfigService : public base::RefCountedThreadSafe<SSLConfigService> { static void EnableDNSCertProvenanceChecking(); static bool dns_cert_provenance_checking_enabled(); + // Is SNI available in this configuration? + static bool IsSNIAvailable(SSLConfigService* service); + // Add an observer of this service. void AddObserver(Observer* observer); diff --git a/net/socket_stream/socket_stream_job.cc b/net/socket_stream/socket_stream_job.cc index 0349de8..cfbea3e 100644 --- a/net/socket_stream/socket_stream_job.cc +++ b/net/socket_stream/socket_stream_job.cc @@ -5,6 +5,7 @@ #include "net/socket_stream/socket_stream_job.h" #include "base/memory/singleton.h" +#include "net/base/ssl_config_service.h" #include "net/base/transport_security_state.h" #include "net/socket_stream/socket_stream_job_manager.h" #include "net/url_request/url_request_context.h" @@ -22,13 +23,12 @@ SocketStreamJob::ProtocolFactory* SocketStreamJob::RegisterProtocolFactory( SocketStreamJob* SocketStreamJob::CreateSocketStreamJob( const GURL& url, SocketStream::Delegate* delegate, - const URLRequestContext& context) { + TransportSecurityState* sts, + SSLConfigService* ssl) { GURL socket_url(url); TransportSecurityState::DomainState domain_state; - if (url.scheme() == "ws" && - context.transport_security_state() && - context.transport_security_state()->IsEnabledForHost( - &domain_state, url.host(), context.IsSNIAvailable()) && + if (url.scheme() == "ws" && sts && sts->IsEnabledForHost( + &domain_state, url.host(), SSLConfigService::IsSNIAvailable(ssl)) && domain_state.mode == TransportSecurityState::DomainState::MODE_STRICT) { url_canon::Replacements<char> replacements; static const char kNewScheme[] = "wss"; diff --git a/net/socket_stream/socket_stream_job.h b/net/socket_stream/socket_stream_job.h index 24eaa19..fdf8d4b 100644 --- a/net/socket_stream/socket_stream_job.h +++ b/net/socket_stream/socket_stream_job.h @@ -16,6 +16,9 @@ class GURL; namespace net { +class SSLConfigService; +class TransportSecurityState; + // SocketStreamJob represents full-duplex communication over SocketStream. // If a protocol (e.g. WebSocket protocol) needs to inspect/modify data // over SocketStream, you can implement protocol specific job (e.g. @@ -34,7 +37,8 @@ class SocketStreamJob : public base::RefCountedThreadSafe<SocketStreamJob> { static SocketStreamJob* CreateSocketStreamJob( const GURL& url, SocketStream::Delegate* delegate, - const URLRequestContext& context); + TransportSecurityState* sts, + SSLConfigService* ssl); SocketStreamJob(); void InitSocketStream(SocketStream* socket) { diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc index 09ac381..7e02641 100644 --- a/net/url_request/url_request_context.cc +++ b/net/url_request/url_request_context.cc @@ -58,15 +58,6 @@ const std::string& URLRequestContext::GetUserAgent(const GURL& url) const { return EmptyString(); } -bool URLRequestContext::IsSNIAvailable() const { - if (!ssl_config_service_) - return false; - - SSLConfig ssl_config; - ssl_config_service_->GetSSLConfig(&ssl_config); - return ssl_config.tls1_enabled; -} - URLRequestContext::~URLRequestContext() { } diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h index 545f629..ae09f4d 100644 --- a/net/url_request/url_request_context.h +++ b/net/url_request/url_request_context.h @@ -180,9 +180,6 @@ class URLRequestContext bool is_main() const { return is_main_; } void set_is_main(bool is_main) { is_main_ = is_main; } - // Is SNI available in this request context? - bool IsSNIAvailable() const; - protected: friend class base::RefCountedThreadSafe<URLRequestContext>; diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index ae87029..2871797 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -192,7 +192,8 @@ URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request, request->context()->transport_security_state()->IsEnabledForHost( &domain_state, request->url().host(), - request->context()->IsSNIAvailable())) { + SSLConfigService::IsSNIAvailable( + request->context()->ssl_config_service()))) { if (domain_state.mode == TransportSecurityState::DomainState::MODE_STRICT) { DCHECK_EQ(request->url().scheme(), "http"); @@ -675,7 +676,8 @@ void URLRequestHttpJob::OnStartCompleted(int result) { if (context_->transport_security_state()->HasPinsForHost( &domain_state, request_->url().host(), - context_->IsSNIAvailable())) { + SSLConfigService::IsSNIAvailable( + context_->ssl_config_service()))) { if (!domain_state.IsChainOfPublicKeysPermitted( ssl_info.public_key_hashes)) { result = ERR_CERT_INVALID; @@ -734,7 +736,8 @@ bool URLRequestHttpJob::ShouldTreatAsCertificateError(int result) { TransportSecurityState::DomainState domain_state; // TODO(agl): don't ignore opportunistic mode. const bool r = context_->transport_security_state()->IsEnabledForHost( - &domain_state, request_info_.url.host(), context_->IsSNIAvailable()); + &domain_state, request_info_.url.host(), + SSLConfigService::IsSNIAvailable(context_->ssl_config_service())); return !r || domain_state.mode == TransportSecurityState::DomainState::MODE_OPPORTUNISTIC; diff --git a/net/websockets/websocket_job_unittest.cc b/net/websockets/websocket_job_unittest.cc index db29ee6..eb4bca1 100644 --- a/net/websockets/websocket_job_unittest.cc +++ b/net/websockets/websocket_job_unittest.cc @@ -509,13 +509,15 @@ TEST_F(WebSocketJobTest, HSTSUpgrade) { GURL url("ws://upgrademe.com/"); MockSocketStreamDelegate delegate; scoped_refptr<SocketStreamJob> job = SocketStreamJob::CreateSocketStreamJob( - url, &delegate, *context_.get()); + url, &delegate, context_->transport_security_state(), + context_->ssl_config_service()); EXPECT_TRUE(GetSocket(job.get())->is_secure()); job->DetachDelegate(); url = GURL("ws://donotupgrademe.com/"); job = SocketStreamJob::CreateSocketStreamJob( - url, &delegate, *context_.get()); + url, &delegate, context_->transport_security_state(), + context_->ssl_config_service()); EXPECT_FALSE(GetSocket(job.get())->is_secure()); job->DetachDelegate(); } diff --git a/webkit/tools/test_shell/simple_socket_stream_bridge.cc b/webkit/tools/test_shell/simple_socket_stream_bridge.cc index a555b48..43ee58e 100644 --- a/webkit/tools/test_shell/simple_socket_stream_bridge.cc +++ b/webkit/tools/test_shell/simple_socket_stream_bridge.cc @@ -157,7 +157,8 @@ void WebSocketStreamHandleBridgeImpl::OnClose(net::SocketStream* socket) { void WebSocketStreamHandleBridgeImpl::DoConnect(const GURL& url) { DCHECK(MessageLoop::current() == g_io_thread); socket_ = net::SocketStreamJob::CreateSocketStreamJob( - url, this, *g_request_context); + url, this, g_request_context->transport_security_state(), + g_request_context->ssl_config_service()); socket_->set_context(g_request_context); socket_->Connect(); } |