diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 06:03:48 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 06:03:48 +0000 |
commit | 2b6ed3dc5fc23bdadbd5052f896648d2d62b9ca2 (patch) | |
tree | 300be8681ec2f27b6382697bbdc67f4a66388bb2 /net | |
parent | 33d24e55bf85ee985972563503f977d35134c815 (diff) | |
download | chromium_src-2b6ed3dc5fc23bdadbd5052f896648d2d62b9ca2.zip chromium_src-2b6ed3dc5fc23bdadbd5052f896648d2d62b9ca2.tar.gz chromium_src-2b6ed3dc5fc23bdadbd5052f896648d2d62b9ca2.tar.bz2 |
Cleanup: rename ProxyRules::socks_proxy --> ProxyRules::fallback_proxy.
BUG=None
TEST=Compiles
Review URL: http://codereview.chromium.org/3146029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57294 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/proxy/proxy_config.cc | 44 | ||||
-rw-r--r-- | net/proxy/proxy_config.h | 14 | ||||
-rw-r--r-- | net/proxy/proxy_config_service_common_unittest.cc | 4 | ||||
-rw-r--r-- | net/proxy/proxy_config_service_common_unittest.h | 8 | ||||
-rw-r--r-- | net/proxy/proxy_config_service_mac.cc | 2 | ||||
-rw-r--r-- | net/proxy/proxy_config_unittest.cc | 8 |
6 files changed, 44 insertions, 36 deletions
diff --git a/net/proxy/proxy_config.cc b/net/proxy/proxy_config.cc index 19fa926..784adaf 100644 --- a/net/proxy/proxy_config.cc +++ b/net/proxy/proxy_config.cc @@ -53,7 +53,7 @@ std::ostream& operator<<(std::ostream& out, << " proxy_for_http: " << rules.proxy_for_http << "\n" << " proxy_for_https: " << rules.proxy_for_https << "\n" << " proxy_for_ftp: " << rules.proxy_for_ftp << "\n" - << " socks_proxy: " << rules.socks_proxy << "\n" + << " fallback_proxy: " << rules.fallback_proxy << "\n" << " }"; } @@ -88,8 +88,10 @@ std::ostream& operator<<(std::ostream& out, const ProxyConfig& config) { out << " HTTPS: " << config.proxy_rules().proxy_for_https << "\n"; if (config.proxy_rules().proxy_for_ftp.is_valid()) out << " FTP: " << config.proxy_rules().proxy_for_ftp << "\n"; - if (config.proxy_rules().socks_proxy.is_valid()) - out << " SOCKS: " << config.proxy_rules().socks_proxy << "\n"; + if (config.proxy_rules().fallback_proxy.is_valid()) { + out << " (fallback): " + << config.proxy_rules().fallback_proxy << "\n"; + } break; } @@ -126,7 +128,7 @@ bool ProxyConfig::ProxyRules::Equals(const ProxyRules& other) const { proxy_for_http == other.proxy_for_http && proxy_for_https == other.proxy_for_https && proxy_for_ftp == other.proxy_for_ftp && - socks_proxy == other.socks_proxy && + fallback_proxy == other.fallback_proxy && bypass_rules.Equals(other.bypass_rules) && reverse_bypass == other.reverse_bypass; } @@ -176,7 +178,7 @@ void ProxyConfig::ProxyRules::ParseFromString(const std::string& proxy_rules) { proxy_for_http = ProxyServer(); proxy_for_https = ProxyServer(); proxy_for_ftp = ProxyServer(); - socks_proxy = ProxyServer(); + fallback_proxy = ProxyServer(); StringTokenizer proxy_server_list(proxy_rules, ";"); while (proxy_server_list.GetNext()) { @@ -203,11 +205,21 @@ void ProxyConfig::ProxyRules::ParseFromString(const std::string& proxy_rules) { // Add it to the per-scheme mappings (if supported scheme). type = TYPE_PROXY_PER_SCHEME; - if (ProxyServer* entry = MapSchemeToProxy(url_scheme)) { - std::string proxy_server_token = proxy_server_for_scheme.token(); - ProxyServer::Scheme scheme = (entry == &socks_proxy) ? - ProxyServer::SCHEME_SOCKS4 : ProxyServer::SCHEME_HTTP; - *entry = ProxyServer::FromURI(proxy_server_token, scheme); + ProxyServer* entry = MapUrlSchemeToProxyNoFallback(url_scheme); + ProxyServer::Scheme default_scheme = ProxyServer::SCHEME_HTTP; + + // socks=XXX is inconsistent with the other formats, since "socks" + // is not a URL scheme. Rather this means "for everything else, send + // it to the SOCKS proxy server XXX". + if (url_scheme == "socks") { + DCHECK(!entry); + entry = &fallback_proxy; + default_scheme = ProxyServer::SCHEME_SOCKS4; + } + + if (entry) { + *entry = ProxyServer::FromURI(proxy_server_for_scheme.token(), + default_scheme); } } } @@ -216,25 +228,23 @@ void ProxyConfig::ProxyRules::ParseFromString(const std::string& proxy_rules) { const ProxyServer* ProxyConfig::ProxyRules::MapUrlSchemeToProxy( const std::string& url_scheme) const { const ProxyServer* proxy_server = - const_cast<ProxyRules*>(this)->MapSchemeToProxy(url_scheme); + const_cast<ProxyRules*>(this)->MapUrlSchemeToProxyNoFallback(url_scheme); if (proxy_server && proxy_server->is_valid()) return proxy_server; - if (socks_proxy.is_valid()) - return &socks_proxy; + if (fallback_proxy.is_valid()) + return &fallback_proxy; return NULL; // No mapping for this scheme. Use direct. } -ProxyServer* ProxyConfig::ProxyRules::MapSchemeToProxy( +ProxyServer* ProxyConfig::ProxyRules::MapUrlSchemeToProxyNoFallback( const std::string& scheme) { - DCHECK(type == TYPE_PROXY_PER_SCHEME); + DCHECK_EQ(TYPE_PROXY_PER_SCHEME, type); if (scheme == "http") return &proxy_for_http; if (scheme == "https") return &proxy_for_https; if (scheme == "ftp") return &proxy_for_ftp; - if (scheme == "socks") - return &socks_proxy; return NULL; // No mapping for this scheme. } diff --git a/net/proxy/proxy_config.h b/net/proxy/proxy_config.h index 6720acd..9cae51a 100644 --- a/net/proxy/proxy_config.h +++ b/net/proxy/proxy_config.h @@ -70,9 +70,7 @@ class ProxyConfig { void ParseFromString(const std::string& proxy_rules); // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp, - // &socks_proxy}, or NULL if it is a scheme that we don't have a mapping - // for. If the scheme mapping is not present and socks_proxy is defined, - // we fall back to using socks_proxy. + // &fallback_proxy}, or NULL if there is no proxy to use. // Should only call this if the type is TYPE_PROXY_PER_SCHEME. const ProxyServer* MapUrlSchemeToProxy(const std::string& url_scheme) const; @@ -95,14 +93,14 @@ class ProxyConfig { ProxyServer proxy_for_https; ProxyServer proxy_for_ftp; - // Set if the configuration has a SOCKS proxy fallback. - ProxyServer socks_proxy; + // Used when there isn't a more specific per-scheme proxy server. + ProxyServer fallback_proxy; private: - // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp, - // &socks_proxy}, or NULL if it is a scheme that we don't have a mapping + // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp} + // or NULL if it is a scheme that we don't have a mapping // for. Should only call this if the type is TYPE_PROXY_PER_SCHEME. - ProxyServer* MapSchemeToProxy(const std::string& scheme); + ProxyServer* MapUrlSchemeToProxyNoFallback(const std::string& scheme); }; typedef int ID; diff --git a/net/proxy/proxy_config_service_common_unittest.cc b/net/proxy/proxy_config_service_common_unittest.cc index 9e5fd76..b233bb6 100644 --- a/net/proxy/proxy_config_service_common_unittest.cc +++ b/net/proxy/proxy_config_service_common_unittest.cc @@ -66,8 +66,8 @@ std::string FlattenProxyBypass(const ProxyBypassRules& bypass_rules) { rules.proxy_for_http, &failure_details, &failed); MatchesProxyServerHelper("Bad proxy_for_https", proxy_for_https, rules.proxy_for_https, &failure_details, &failed); - MatchesProxyServerHelper("Bad proxy_for_socks", socks_proxy, - rules.socks_proxy, &failure_details, &failed); + MatchesProxyServerHelper("Bad fallback_proxy", fallback_proxy, + rules.fallback_proxy, &failure_details, &failed); std::string actual_flattened_bypass = FlattenProxyBypass(rules.bypass_rules); if (std::string(flattened_bypass_rules) != actual_flattened_bypass) { diff --git a/net/proxy/proxy_config_service_common_unittest.h b/net/proxy/proxy_config_service_common_unittest.h index d6b40cd..b64cd6b 100644 --- a/net/proxy/proxy_config_service_common_unittest.h +++ b/net/proxy/proxy_config_service_common_unittest.h @@ -22,7 +22,7 @@ struct ProxyRulesExpectation { const char* proxy_for_http, const char* proxy_for_https, const char* proxy_for_ftp, - const char* socks_proxy, + const char* fallback_proxy, const char* flattened_bypass_rules, bool reverse_bypass) : type(type), @@ -30,7 +30,7 @@ struct ProxyRulesExpectation { proxy_for_http(proxy_for_http), proxy_for_https(proxy_for_https), proxy_for_ftp(proxy_for_ftp), - socks_proxy(socks_proxy), + fallback_proxy(fallback_proxy), flattened_bypass_rules(flattened_bypass_rules), reverse_bypass(reverse_bypass) { } @@ -66,7 +66,7 @@ struct ProxyRulesExpectation { const char* proxy_http, const char* proxy_https, const char* proxy_ftp, - const char* socks_proxy, + const char* fallback_proxy, const char* flattened_bypass_rules); // Same as PerScheme, but with the bypass rules reversed @@ -81,7 +81,7 @@ struct ProxyRulesExpectation { const char* proxy_for_http; const char* proxy_for_https; const char* proxy_for_ftp; - const char* socks_proxy; + const char* fallback_proxy; const char* flattened_bypass_rules; bool reverse_bypass; }; diff --git a/net/proxy/proxy_config_service_mac.cc b/net/proxy/proxy_config_service_mac.cc index 38237a56..84a5da3 100644 --- a/net/proxy/proxy_config_service_mac.cc +++ b/net/proxy/proxy_config_service_mac.cc @@ -122,7 +122,7 @@ void GetCurrentProxyConfig(ProxyConfig* config) { if (proxy_server.is_valid()) { config->proxy_rules().type = ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; - config->proxy_rules().socks_proxy = proxy_server; + config->proxy_rules().fallback_proxy = proxy_server; } } diff --git a/net/proxy/proxy_config_unittest.cc b/net/proxy/proxy_config_unittest.cc index 864b200..118e957 100644 --- a/net/proxy/proxy_config_unittest.cc +++ b/net/proxy/proxy_config_unittest.cc @@ -104,7 +104,7 @@ TEST(ProxyConfigTest, ParseProxyRules) { const char* proxy_for_http; const char* proxy_for_https; const char* proxy_for_ftp; - const char* socks_proxy; + const char* fallback_proxy; } tests[] = { // One HTTP proxy for all schemes. { @@ -246,8 +246,8 @@ TEST(ProxyConfigTest, ParseProxyRules) { config.proxy_rules().proxy_for_https); ExpectProxyServerEquals(tests[i].proxy_for_ftp, config.proxy_rules().proxy_for_ftp); - ExpectProxyServerEquals(tests[i].socks_proxy, - config.proxy_rules().socks_proxy); + ExpectProxyServerEquals(tests[i].fallback_proxy, + config.proxy_rules().fallback_proxy); } } @@ -335,7 +335,7 @@ TEST(ProxyConfigTest, ToString) { "Manual settings:\n" " Proxy server: \n" " HTTP: proxy-for-http:1801\n" - " SOCKS: socks4://socks-server:6083\n" + " (fallback): socks4://socks-server:6083\n" " Bypass list: [None]", config.ToString()); } |