From 31e68d79c7a0ee90d6de5f8fd26b72a7b35bdd2e Mon Sep 17 00:00:00 2001 From: "eroman@chromium.org" Date: Wed, 25 Aug 2010 06:36:58 +0000 Subject: 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 --- net/proxy/proxy_server.cc | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'net/proxy/proxy_server.cc') 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 [":"] - } - // 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 -- cgit v1.1