diff options
author | erikchen@google.com <erikchen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-23 23:09:15 +0000 |
---|---|---|
committer | erikchen@google.com <erikchen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-23 23:09:15 +0000 |
commit | 9e9e842e287f9f949aa59bcf88321fa7f94fd524 (patch) | |
tree | b84963a14d5c7a4a7908d268320d29bb40b726b2 /net/http | |
parent | 148971b8a6efa47182662a17c8e7b455043fb632 (diff) | |
download | chromium_src-9e9e842e287f9f949aa59bcf88321fa7f94fd524.zip chromium_src-9e9e842e287f9f949aa59bcf88321fa7f94fd524.tar.gz chromium_src-9e9e842e287f9f949aa59bcf88321fa7f94fd524.tar.bz2 |
SPDY now always uses http_network_transaction instead of spdy_network_transaction.
It was previously possible to use spdy_network_transaction using the command line flags:
--use-spdy=no-ssl
--use-spdy=no-compress
This does not affect instances of chrome that are not run with --use-spdy.
Also changed spdy_network_transaction_unittest so that all tests are run with 3 different connection configurations: spdy over npn, spdy over ssl, and spdy without ssl.
TEST=net_unittests
BUG=49082
Review URL: http://codereview.chromium.org/3048003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53548 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_network_layer.cc | 18 | ||||
-rw-r--r-- | net/http/http_network_layer.h | 1 | ||||
-rw-r--r-- | net/http/http_network_transaction.cc | 72 | ||||
-rw-r--r-- | net/http/http_network_transaction.h | 16 |
4 files changed, 79 insertions, 28 deletions
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc index 4950a7b..30feddc 100644 --- a/net/http/http_network_layer.cc +++ b/net/http/http_network_layer.cc @@ -45,8 +45,6 @@ HttpTransactionFactory* HttpNetworkLayer::CreateFactory( } //----------------------------------------------------------------------------- -bool HttpNetworkLayer::force_spdy_ = false; - HttpNetworkLayer::HttpNetworkLayer( ClientSocketFactory* socket_factory, HostResolver* host_resolver, @@ -88,10 +86,7 @@ int HttpNetworkLayer::CreateTransaction(scoped_ptr<HttpTransaction>* trans) { if (suspended_) return ERR_NETWORK_IO_SUSPENDED; - if (force_spdy_) - trans->reset(new SpdyNetworkTransaction(GetSession())); - else - trans->reset(new HttpNetworkTransaction(GetSession())); + trans->reset(new HttpNetworkTransaction(GetSession())); return OK; } @@ -126,6 +121,7 @@ HttpNetworkSession* HttpNetworkLayer::GetSession() { // static void HttpNetworkLayer::EnableSpdy(const std::string& mode) { + static const char kSSL[] = "ssl"; static const char kDisableSSL[] = "no-ssl"; static const char kDisableCompression[] = "no-compress"; static const char kDisableAltProtocols[] = "no-alt-protocols"; @@ -160,9 +156,6 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) { std::vector<std::string> spdy_options; SplitString(mode, ',', &spdy_options); - // Force spdy mode (use SpdyNetworkTransaction for all http requests). - force_spdy_ = true; - bool use_alt_protocols = true; for (std::vector<std::string>::iterator it = spdy_options.begin(); @@ -170,18 +163,21 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) { const std::string& option = *it; if (option == kDisableSSL) { SpdySession::SetSSLMode(false); // Disable SSL + HttpNetworkTransaction::SetUseSSLOverSpdyWithoutNPN(false); + HttpNetworkTransaction::SetUseSpdyWithoutNPN(true); + } else if (option == kSSL) { + HttpNetworkTransaction::SetUseSSLOverSpdyWithoutNPN(true); + HttpNetworkTransaction::SetUseSpdyWithoutNPN(true); } else if (option == kDisableCompression) { spdy::SpdyFramer::set_enable_compression_default(false); } else if (option == kEnableNPN) { HttpNetworkTransaction::SetUseAlternateProtocols(use_alt_protocols); HttpNetworkTransaction::SetNextProtos(kNpnProtosFull); - force_spdy_ = false; } else if (option == kEnableNpnHttpOnly) { // Avoid alternate protocol in this case. Otherwise, browser will try SSL // and then fallback to http. This introduces extra load. HttpNetworkTransaction::SetUseAlternateProtocols(false); HttpNetworkTransaction::SetNextProtos(kNpnProtosHttpOnly); - force_spdy_ = false; } else if (option == kDisableAltProtocols) { use_alt_protocols = false; HttpNetworkTransaction::SetUseAlternateProtocols(false); diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h index 657fcd3..b7229de 100644 --- a/net/http/http_network_layer.h +++ b/net/http/http_network_layer.h @@ -94,7 +94,6 @@ class HttpNetworkLayer : public HttpTransactionFactory, public NonThreadSafe { NetLog* net_log_; bool suspended_; - static bool force_spdy_; }; } // namespace net diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 2e5b437..ae1e86f 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -59,6 +59,8 @@ namespace { const HostMappingRules* g_host_mapping_rules = NULL; const std::string* g_next_protos = NULL; bool g_use_alternate_protocols = false; +bool g_want_ssl_over_spdy_without_npn = true; +bool g_want_spdy_without_npn = false; // A set of host:port strings. These are servers which we have needed to back // off to SSLv3 for. @@ -207,6 +209,8 @@ HttpNetworkTransaction::HttpNetworkTransaction(HttpNetworkSession* session) logged_response_time_(false), using_ssl_(false), using_spdy_(false), + want_spdy_without_npn_(g_want_spdy_without_npn), + want_ssl_over_spdy_without_npn_(g_want_ssl_over_spdy_without_npn), spdy_certificate_error_(OK), alternate_protocol_mode_( g_use_alternate_protocols ? kUnspecified : @@ -235,6 +239,16 @@ void HttpNetworkTransaction::SetUseAlternateProtocols(bool value) { } // static +void HttpNetworkTransaction::SetUseSSLOverSpdyWithoutNPN(bool value) { + g_want_ssl_over_spdy_without_npn = value; +} + +// static +void HttpNetworkTransaction::SetUseSpdyWithoutNPN(bool value) { + g_want_spdy_without_npn = value; +} + +// static void HttpNetworkTransaction::SetNextProtos(const std::string& next_protos) { delete g_next_protos; g_next_protos = new std::string(next_protos); @@ -711,9 +725,11 @@ int HttpNetworkTransaction::DoInitConnection() { session_); } - bool want_spdy = alternate_protocol_mode_ == kUsingAlternateProtocol + bool want_spdy_over_npn = alternate_protocol_mode_ == kUsingAlternateProtocol && alternate_protocol_ == HttpAlternateProtocols::NPN_SPDY_1; - using_ssl_ = request_->url.SchemeIs("https") || want_spdy; + using_ssl_ = request_->url.SchemeIs("https") || + (want_spdy_without_npn_ && want_ssl_over_spdy_without_npn_) || + want_spdy_over_npn; using_spdy_ = false; response_.was_fetched_via_proxy = !proxy_info_.is_direct(); @@ -814,7 +830,10 @@ int HttpNetworkTransaction::DoInitConnection() { new SSLSocketParams(tcp_params, http_proxy_params, socks_params, proxy_info_.proxy_server().scheme(), request_->url.HostNoBrackets(), ssl_config_, - load_flags, want_spdy); + load_flags, + want_spdy_without_npn_ && + want_ssl_over_spdy_without_npn_, + want_spdy_over_npn); scoped_refptr<SSLClientSocketPool> ssl_pool; if (proxy_info_.is_direct()) @@ -868,8 +887,14 @@ int HttpNetworkTransaction::DoInitConnectionComplete(int result) { SSLClientSocket::kProtoSPDY1) using_spdy_ = true; } + if(want_ssl_over_spdy_without_npn_ && want_spdy_without_npn_) + using_spdy_ = true; } + // We may be using spdy without SSL + if(!want_ssl_over_spdy_without_npn_ && want_spdy_without_npn_) + using_spdy_ = true; + if (result == ERR_PROXY_AUTH_REQUESTED) { DCHECK(!ssl_started); const HttpResponseInfo& tunnel_auth_response = @@ -902,12 +927,19 @@ int HttpNetworkTransaction::DoInitConnectionComplete(int result) { // trying to reuse a keep-alive connection. reused_socket_ = connection_->is_reused(); // TODO(vandebo) should we exclude SPDY in the following if? - if (!reused_socket_) - UpdateConnectionTypeHistograms(CONNECTION_HTTP); + if (!reused_socket_) { + if (using_spdy_) + UpdateConnectionTypeHistograms(CONNECTION_SPDY); + else + UpdateConnectionTypeHistograms(CONNECTION_HTTP); + } if (!using_ssl_) { DCHECK_EQ(OK, result); - next_state_ = STATE_GENERATE_PROXY_AUTH_TOKEN; + if (using_spdy_) + next_state_ = STATE_SPDY_GET_STREAM; + else + next_state_ = STATE_GENERATE_PROXY_AUTH_TOKEN; return result; } } @@ -1243,15 +1275,25 @@ int HttpNetworkTransaction::DoSpdyGetStream() { if (spdy_pool->HasSession(endpoint_)) { spdy_session = spdy_pool->Get(endpoint_, session_, net_log_); } else { - // SPDY is negotiated using the TLS next protocol negotiation (NPN) - // extension, so |connection_| must contain an SSLClientSocket. - DCHECK(using_ssl_); - CHECK(connection_->socket()); - int error = spdy_pool->GetSpdySessionFromSSLSocket( - endpoint_, session_, connection_.release(), net_log_, - spdy_certificate_error_, &spdy_session); - if (error != OK) - return error; + if(using_ssl_) { + // SPDY can be negotiated using the TLS next protocol negotiation (NPN) + // extension, or just directly using SSL. Either way, |connection_| must + // contain an SSLClientSocket. + CHECK(connection_->socket()); + int error = spdy_pool->GetSpdySessionFromSocket( + endpoint_, session_, connection_.release(), net_log_, + spdy_certificate_error_, &spdy_session, true); + if (error != OK) + return error; + } + else { + // We may want SPDY without SSL + int error = spdy_pool->GetSpdySessionFromSocket( + endpoint_, session_, connection_.release(), net_log_, + spdy_certificate_error_, &spdy_session, false); + if (error != OK) + return error; + } } CHECK(spdy_session.get()); diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index 7c32bd3..4d3cf4e 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -47,6 +47,12 @@ class HttpNetworkTransaction : public HttpTransaction { // Controls whether or not we use the Alternate-Protocol header. static void SetUseAlternateProtocols(bool value); + // Controls whether or not we use ssl when in spdy mode. + static void SetUseSSLOverSpdyWithoutNPN(bool value); + + // Controls whether or not we use spdy without npn. + static void SetUseSpdyWithoutNPN(bool value); + // Sets the next protocol negotiation value used during the SSL handshake. static void SetNextProtos(const std::string& next_protos); @@ -274,11 +280,19 @@ class HttpNetworkTransaction : public HttpTransaction { // responses. bool logged_response_time_; - bool using_ssl_; // True if handling a HTTPS request + // True if handling a HTTPS request, or using SPDY with SSL + bool using_ssl_; // True if this network transaction is using SPDY instead of HTTP. bool using_spdy_; + // True if this network transaction wants to use SPDY (not over npn) + bool want_spdy_without_npn_; + + // True if this network transaction wants to use SSL with SPDY (not over npn) + bool want_ssl_over_spdy_without_npn_; + + // The certificate error while using SPDY over SSL for insecure URLs. int spdy_certificate_error_; |