Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(459)

Unified Diff: net/proxy/proxy_server.cc

Issue 3197018: Refactor: change the spdy session pool key to take a ProxyServer instead of a stri... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/proxy_server.h ('k') | net/proxy/proxy_server_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_server.cc
===================================================================
--- net/proxy/proxy_server.cc (revision 57276)
+++ net/proxy/proxy_server.cc (working copy)
@@ -72,6 +72,13 @@
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 @@
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);
+
+ host_port_pair = HostPortPair(HostNoBrackets(host), port);
}
- // Choose a default port number if none was given.
- if (port == -1)
- port = GetDefaultPortForScheme(scheme);
-
- return ProxyServer(scheme, HostPortPair(HostNoBrackets(host), port));
+ return ProxyServer(scheme, host_port_pair);
}
} // namespace net
« no previous file with comments | « net/proxy/proxy_server.h ('k') | net/proxy/proxy_server_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698