diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 06:36:58 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 06:36:58 +0000 |
commit | 31e68d79c7a0ee90d6de5f8fd26b72a7b35bdd2e (patch) | |
tree | 884da7cd68797bda1109b596355a2ec2c1647561 /net/proxy/proxy_server.cc | |
parent | 7a6a4b3a5b233bb2eae6cec674d90ac858d1a9e7 (diff) | |
download | chromium_src-31e68d79c7a0ee90d6de5f8fd26b72a7b35bdd2e.zip chromium_src-31e68d79c7a0ee90d6de5f8fd26b72a7b35bdd2e.tar.gz chromium_src-31e68d79c7a0ee90d6de5f8fd26b72a7b35bdd2e.tar.bz2 |
Refactor: change the spdy session pool key to take a ProxyServer instead of a string representation of the proxy server.
BUG=52668
Review URL: http://codereview.chromium.org/3197018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57297 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_server.cc')
-rw-r--r-- | net/proxy/proxy_server.cc | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/net/proxy/proxy_server.cc b/net/proxy/proxy_server.cc index f172a6b..1cb6e68 100644 --- a/net/proxy/proxy_server.cc +++ b/net/proxy/proxy_server.cc @@ -72,6 +72,13 @@ std::string HostNoBrackets(const std::string& host) { ProxyServer::ProxyServer(Scheme scheme, const HostPortPair& host_port_pair) : scheme_(scheme), host_port_pair_(host_port_pair) { + if (scheme_ == SCHEME_DIRECT || scheme_ == SCHEME_INVALID) { + // |host_port_pair| isn't relevant for these special schemes, so none should + // have been specified. It is important for this to be consistent since we + // do raw field comparisons in the equality and comparison functions. + DCHECK(host_port_pair.Equals(HostPortPair())); + host_port_pair_ = HostPortPair(); + } } const HostPortPair& ProxyServer::host_port_pair() const { @@ -208,21 +215,24 @@ ProxyServer ProxyServer::FromSchemeHostAndPort( if (scheme == SCHEME_DIRECT && begin != end) return ProxyServer(); // Invalid -- DIRECT cannot have a host/port. - std::string host; - int port = -1; + HostPortPair host_port_pair; if (scheme != SCHEME_INVALID && scheme != SCHEME_DIRECT) { + std::string host; + int port = -1; // If the scheme has a host/port, parse it. bool ok = net::ParseHostAndPort(begin, end, &host, &port); if (!ok) return ProxyServer(); // Invalid -- failed parsing <host>[":"<port>] - } - // Choose a default port number if none was given. - if (port == -1) - port = GetDefaultPortForScheme(scheme); + // Choose a default port number if none was given. + if (port == -1) + port = GetDefaultPortForScheme(scheme); + + host_port_pair = HostPortPair(HostNoBrackets(host), port); + } - return ProxyServer(scheme, HostPortPair(HostNoBrackets(host), port)); + return ProxyServer(scheme, host_port_pair); } } // namespace net |