| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/proxy/proxy_server.h" | 5 #include "net/proxy/proxy_server.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // have been specified. It is important for this to be consistent since we | 81 // have been specified. It is important for this to be consistent since we |
| 82 // do raw field comparisons in the equality and comparison functions. | 82 // do raw field comparisons in the equality and comparison functions. |
| 83 DCHECK(host_port_pair.Equals(HostPortPair())); | 83 DCHECK(host_port_pair.Equals(HostPortPair())); |
| 84 host_port_pair_ = HostPortPair(); | 84 host_port_pair_ = HostPortPair(); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 const HostPortPair& ProxyServer::host_port_pair() const { | 88 const HostPortPair& ProxyServer::host_port_pair() const { |
| 89 // Doesn't make sense to call this if the URI scheme doesn't | 89 // Doesn't make sense to call this if the URI scheme doesn't |
| 90 // have concept of a host. | 90 // have concept of a host. |
| 91 DCHECK(is_valid() && !is_direct()); | 91 DCHECK(is_valid()); |
| 92 DCHECK(!is_direct()); |
| 92 return host_port_pair_; | 93 return host_port_pair_; |
| 93 } | 94 } |
| 94 | 95 |
| 95 // static | 96 // static |
| 96 ProxyServer ProxyServer::FromURI(const std::string& uri, | 97 ProxyServer ProxyServer::FromURI(const std::string& uri, |
| 97 Scheme default_scheme) { | 98 Scheme default_scheme) { |
| 98 return FromURI(uri.begin(), uri.end(), default_scheme); | 99 return FromURI(uri.begin(), uri.end(), default_scheme); |
| 99 } | 100 } |
| 100 | 101 |
| 101 // static | 102 // static |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 break; | 213 break; |
| 213 } | 214 } |
| 214 return -1; | 215 return -1; |
| 215 } | 216 } |
| 216 | 217 |
| 217 // static | 218 // static |
| 218 ProxyServer::Scheme ProxyServer::GetSchemeFromURI(const std::string& scheme) { | 219 ProxyServer::Scheme ProxyServer::GetSchemeFromURI(const std::string& scheme) { |
| 219 return GetSchemeFromURIInternal(scheme.begin(), scheme.end()); | 220 return GetSchemeFromURIInternal(scheme.begin(), scheme.end()); |
| 220 } | 221 } |
| 221 | 222 |
| 222 // TODO(bengr): Use |scheme_| to indicate that this is the data reduction proxy. | |
| 223 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 224 bool ProxyServer::isDataReductionProxy() const { | |
| 225 bool dev_host = false; | |
| 226 #if defined (DATA_REDUCTION_DEV_HOST) | |
| 227 dev_host = host_port_pair_.Equals( | |
| 228 HostPortPair::FromURL(GURL(DATA_REDUCTION_DEV_HOST))); | |
| 229 #endif | |
| 230 return dev_host || host_port_pair_.Equals( | |
| 231 HostPortPair::FromURL(GURL(SPDY_PROXY_AUTH_ORIGIN))); | |
| 232 } | |
| 233 | |
| 234 bool ProxyServer::isDataReductionProxyFallback() const { | |
| 235 #if defined(DATA_REDUCTION_FALLBACK_HOST) | |
| 236 return host_port_pair_.Equals( | |
| 237 HostPortPair::FromURL(GURL(DATA_REDUCTION_FALLBACK_HOST))); | |
| 238 #endif // defined(DATA_REDUCTION_FALLBACK_HOST) | |
| 239 return false; | |
| 240 } | |
| 241 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 242 | |
| 243 // static | 223 // static |
| 244 ProxyServer ProxyServer::FromSchemeHostAndPort( | 224 ProxyServer ProxyServer::FromSchemeHostAndPort( |
| 245 Scheme scheme, | 225 Scheme scheme, |
| 246 std::string::const_iterator begin, | 226 std::string::const_iterator begin, |
| 247 std::string::const_iterator end) { | 227 std::string::const_iterator end) { |
| 248 | 228 |
| 249 // Trim leading/trailing space. | 229 // Trim leading/trailing space. |
| 250 HttpUtil::TrimLWS(&begin, &end); | 230 HttpUtil::TrimLWS(&begin, &end); |
| 251 | 231 |
| 252 if (scheme == SCHEME_DIRECT && begin != end) | 232 if (scheme == SCHEME_DIRECT && begin != end) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 266 if (port == -1) | 246 if (port == -1) |
| 267 port = GetDefaultPortForScheme(scheme); | 247 port = GetDefaultPortForScheme(scheme); |
| 268 | 248 |
| 269 host_port_pair = HostPortPair(HostNoBrackets(host), port); | 249 host_port_pair = HostPortPair(HostNoBrackets(host), port); |
| 270 } | 250 } |
| 271 | 251 |
| 272 return ProxyServer(scheme, host_port_pair); | 252 return ProxyServer(scheme, host_port_pair); |
| 273 } | 253 } |
| 274 | 254 |
| 275 } // namespace net | 255 } // namespace net |
| OLD | NEW |