summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-08 04:21:08 +0000
committermbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-08 04:21:08 +0000
commitd93d833fbc80b3cbe987b35c62b8fd290c6ee791 (patch)
tree8b8fd2c3e8eeed85e697adf16a3da5f8322625ab /net
parent882245ec433abea563a0af490b175f19d8d19f4a (diff)
downloadchromium_src-d93d833fbc80b3cbe987b35c62b8fd290c6ee791.zip
chromium_src-d93d833fbc80b3cbe987b35c62b8fd290c6ee791.tar.gz
chromium_src-d93d833fbc80b3cbe987b35c62b8fd290c6ee791.tar.bz2
Add a port to the SPDY debugging flags so that we can force SPDY for just a
single port without forcing SPDY on all ports. BUG=none TEST=none --use-spdy="ssl,port=1000" Review URL: http://codereview.chromium.org/6083012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70834 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/http/http_network_layer.cc11
-rw-r--r--net/http/http_stream_factory.cc2
-rw-r--r--net/http/http_stream_factory.h14
-rw-r--r--net/http/http_stream_request.cc32
-rw-r--r--net/http/http_stream_request.h6
5 files changed, 59 insertions, 6 deletions
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc
index 3d3c5dd..9a11034 100644
--- a/net/http/http_network_layer.cc
+++ b/net/http/http_network_layer.cc
@@ -5,6 +5,7 @@
#include "net/http/http_network_layer.h"
#include "base/logging.h"
+#include "base/string_number_conversions.h"
#include "base/string_split.h"
#include "base/string_util.h"
#include "net/http/http_network_session.h"
@@ -188,6 +189,7 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) {
static const char kOff[] = "off";
static const char kSSL[] = "ssl";
static const char kDisableSSL[] = "no-ssl";
+ static const char kExclude[] = "exclude"; // Hosts to exclude
static const char kDisableCompression[] = "no-compress";
static const char kDisableAltProtocols[] = "no-alt-protocols";
static const char kEnableVersionOne[] = "v1";
@@ -228,7 +230,12 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) {
for (std::vector<std::string>::iterator it = spdy_options.begin();
it != spdy_options.end(); ++it) {
- const std::string& option = *it;
+ const std::string& element = *it;
+ std::vector<std::string> name_value;
+ base::SplitString(element, '=', &name_value);
+ const std::string& option = name_value[0];
+ const std::string value = name_value.size() > 1 ? name_value[1] : "";
+
if (option == kOff) {
HttpStreamFactory::set_spdy_enabled(false);
} else if (option == kDisableSSL) {
@@ -238,6 +245,8 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) {
} else if (option == kSSL) {
HttpStreamFactory::set_force_spdy_over_ssl(true);
HttpStreamFactory::set_force_spdy_always(true);
+ } else if (option == kExclude) {
+ HttpStreamFactory::add_forced_spdy_exclusion(value);
} else if (option == kDisableCompression) {
spdy::SpdyFramer::set_enable_compression_default(false);
} else if (option == kEnableNPN) {
diff --git a/net/http/http_stream_factory.cc b/net/http/http_stream_factory.cc
index e30c0c5..b575f48 100644
--- a/net/http/http_stream_factory.cc
+++ b/net/http/http_stream_factory.cc
@@ -28,6 +28,8 @@ bool HttpStreamFactory::force_spdy_over_ssl_ = true;
// static
bool HttpStreamFactory::force_spdy_always_ = false;
// static
+std::list<HostPortPair>* HttpStreamFactory::forced_spdy_exclusions_ = NULL;
+// static
bool HttpStreamFactory::ignore_certificate_errors_ = false;
// static
diff --git a/net/http/http_stream_factory.h b/net/http/http_stream_factory.h
index c5a0dc3..3bb6d2f 100644
--- a/net/http/http_stream_factory.h
+++ b/net/http/http_stream_factory.h
@@ -5,6 +5,7 @@
#ifndef NET_HTTP_HTTP_STREAM_FACTORY_H_
#define NET_HTTP_HTTP_STREAM_FACTORY_H_
+#include <list>
#include <map>
#include <set>
#include <string>
@@ -12,6 +13,7 @@
#include "base/scoped_ptr.h"
#include "net/base/completion_callback.h"
#include "net/base/host_mapping_rules.h"
+#include "net/base/host_port_pair.h"
#include "net/base/ssl_config_service.h"
#include "net/http/http_auth.h"
#include "net/http/http_auth_controller.h"
@@ -91,6 +93,17 @@ class HttpStreamFactory : public StreamFactory,
}
static bool force_spdy_always() { return force_spdy_always_; }
+ // Add a URL to exclude from forced SPDY.
+ static void add_forced_spdy_exclusion(const std::string& value) {
+ HostPortPair pair = HostPortPair::FromURL(GURL(value));
+ if (!forced_spdy_exclusions_)
+ forced_spdy_exclusions_ = new std::list<HostPortPair>();
+ forced_spdy_exclusions_->push_back(pair);
+ }
+ static std::list<HostPortPair>* forced_spdy_exclusions() {
+ return forced_spdy_exclusions_;
+ }
+
// Sets the next protocol negotiation value used during the SSL handshake.
static void set_next_protos(const std::string& value) {
delete next_protos_;
@@ -120,6 +133,7 @@ class HttpStreamFactory : public StreamFactory,
static bool use_alternate_protocols_;
static bool force_spdy_over_ssl_;
static bool force_spdy_always_;
+ static std::list<HostPortPair>* forced_spdy_exclusions_;
static bool ignore_certificate_errors_;
DISALLOW_COPY_AND_ASSIGN(HttpStreamFactory);
diff --git a/net/http/http_stream_request.cc b/net/http/http_stream_request.cc
index 485dba7..c031145 100644
--- a/net/http/http_stream_request.cc
+++ b/net/http/http_stream_request.cc
@@ -451,6 +451,29 @@ int HttpStreamRequest::DoResolveProxyComplete(int result) {
return OK;
}
+bool HasSpdyExclusion(const HostPortPair& endpoint) {
+ std::list<HostPortPair>* exclusions =
+ HttpStreamFactory::forced_spdy_exclusions();
+ if (!exclusions)
+ return false;
+
+ std::list<HostPortPair>::const_iterator it;
+ for (it = exclusions->begin(); it != exclusions->end(); it++)
+ if (it->Equals(endpoint))
+ return true;
+ return false;
+}
+
+bool HttpStreamRequest::ShouldForceSpdySSL() {
+ bool rv = force_spdy_always_ && force_spdy_over_ssl_;
+ return rv && !HasSpdyExclusion(endpoint_);
+}
+
+bool HttpStreamRequest::ShouldForceSpdyWithoutSSL() {
+ bool rv = force_spdy_always_ && !force_spdy_over_ssl_;
+ return rv && !HasSpdyExclusion(endpoint_);
+}
+
int HttpStreamRequest::DoInitConnection() {
DCHECK(!connection_->is_initialized());
DCHECK(proxy_info()->proxy_server().is_valid());
@@ -460,8 +483,7 @@ int HttpStreamRequest::DoInitConnection() {
alternate_protocol_mode_ == kUsingAlternateProtocol &&
alternate_protocol_ == HttpAlternateProtocols::NPN_SPDY_2;
using_ssl_ = request_info().url.SchemeIs("https") ||
- (force_spdy_always_ && force_spdy_over_ssl_) ||
- want_spdy_over_npn;
+ ShouldForceSpdySSL() || want_spdy_over_npn;
using_spdy_ = false;
// If spdy has been turned off on-the-fly, then there may be SpdySessions
@@ -669,7 +691,7 @@ int HttpStreamRequest::DoInitConnectionComplete(int result) {
if (ssl_socket->was_spdy_negotiated())
SwitchToSpdyMode();
}
- if (force_spdy_over_ssl_ && force_spdy_always_)
+ if (ShouldForceSpdySSL())
SwitchToSpdyMode();
} else if (proxy_info()->is_https() && connection_->socket() &&
result == OK) {
@@ -682,7 +704,7 @@ int HttpStreamRequest::DoInitConnectionComplete(int result) {
}
// We may be using spdy without SSL
- if (!force_spdy_over_ssl_ && force_spdy_always_)
+ if (ShouldForceSpdyWithoutSSL())
SwitchToSpdyMode();
if (result == ERR_PROXY_AUTH_REQUESTED ||
@@ -905,7 +927,7 @@ scoped_refptr<SSLSocketParams> HttpStreamRequest::GenerateSSLParams(
new SSLSocketParams(tcp_params, socks_params, http_proxy_params,
proxy_scheme, host_and_port,
*ssl_config(), load_flags,
- force_spdy_always_ && force_spdy_over_ssl_,
+ ShouldForceSpdySSL(),
want_spdy_over_npn));
return ssl_params;
diff --git a/net/http/http_stream_request.h b/net/http/http_stream_request.h
index f20b5f3..62ba5d8 100644
--- a/net/http/http_stream_request.h
+++ b/net/http/http_stream_request.h
@@ -180,6 +180,12 @@ class HttpStreamRequest : public StreamRequest {
// Moves this stream request into SPDY mode.
void SwitchToSpdyMode();
+ // Should we force SPDY to run over SSL for this stream request.
+ bool ShouldForceSpdySSL();
+
+ // Should we force SPDY to run without SSL for this stream request.
+ bool ShouldForceSpdyWithoutSSL();
+
// Record histograms of latency until Connect() completes.
static void LogHttpConnectedMetrics(const ClientSocketHandle& handle);