From 82f954e39c77f4dc20d39c88ca49982a9e48cf94 Mon Sep 17 00:00:00 2001 From: "darin@google.com" Date: Tue, 12 Aug 2008 05:11:38 +0000 Subject: Change the ProxyService to work with ASCII strings. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@711 0039d316-1c4b-4281-b951-d872f2087c98 --- net/http/http_network_transaction.cc | 4 +- net/http/http_network_transaction_unittest.cc | 4 +- net/http/http_transaction_winhttp.cc | 2 +- net/proxy/proxy_resolver_fixed.cc | 4 +- net/proxy/proxy_resolver_fixed.h | 4 +- net/proxy/proxy_resolver_winhttp.cc | 18 +++--- net/proxy/proxy_resolver_winhttp.h | 4 +- net/proxy/proxy_service.cc | 74 +++++++++++----------- net/proxy/proxy_service.h | 28 ++++----- net/proxy/proxy_service_unittest.cc | 88 +++++++++++++-------------- 10 files changed, 115 insertions(+), 115 deletions(-) (limited to 'net') diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 1d45191..56ec449 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -347,7 +347,7 @@ int HttpNetworkTransaction::DoInitConnection() { // Build the string used to uniquely identify connections of this type. std::string connection_group; if (using_proxy_ || using_tunnel_) - connection_group = "proxy/" + proxy_info_.GetProxyServer() + "/"; + connection_group = "proxy/" + proxy_info_.proxy_server() + "/"; if (!using_proxy_) connection_group.append(request_->url.GetOrigin().spec()); @@ -380,7 +380,7 @@ int HttpNetworkTransaction::DoResolveHost() { // Determine the host and port to connect to. if (using_proxy_ || using_tunnel_) { - const std::string& proxy = proxy_info_.GetProxyServer(); + const std::string& proxy = proxy_info_.proxy_server(); StringTokenizer t(proxy, ":"); // TODO(darin): Handle errors here. Perhaps HttpProxyInfo should do this // before claiming a proxy server configuration. diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 600b508..2dc9721 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -176,8 +176,8 @@ class NullProxyResolver : public net::ProxyResolver { virtual int GetProxyConfig(net::ProxyConfig* config) { return net::ERR_FAILED; } - virtual int GetProxyForURL(const std::wstring& query_url, - const std::wstring& pac_url, + virtual int GetProxyForURL(const std::string& query_url, + const std::string& pac_url, net::ProxyInfo* results) { return net::ERR_FAILED; } diff --git a/net/http/http_transaction_winhttp.cc b/net/http/http_transaction_winhttp.cc index 5c49fc7..b946a6d 100644 --- a/net/http/http_transaction_winhttp.cc +++ b/net/http/http_transaction_winhttp.cc @@ -1274,7 +1274,7 @@ int HttpTransactionWinHttp::SendRequest() { if (proxy_info_.is_direct()) connect_peer_ = request_->url.GetOrigin().spec(); else - connect_peer_ = WideToASCII(proxy_info_.proxy_server()); + connect_peer_ = proxy_info_.proxy_server(); DWORD_PTR ctx = reinterpret_cast(session_callback_.get()); if (!session_->request_throttle()->SubmitRequest(connect_peer_, request_handle_, diff --git a/net/proxy/proxy_resolver_fixed.cc b/net/proxy/proxy_resolver_fixed.cc index 412cd2d..2bbddd2 100644 --- a/net/proxy/proxy_resolver_fixed.cc +++ b/net/proxy/proxy_resolver_fixed.cc @@ -38,8 +38,8 @@ int ProxyResolverFixed::GetProxyConfig(ProxyConfig* config) { return OK; } -int ProxyResolverFixed::GetProxyForURL(const std::wstring& query_url, - const std::wstring& pac_url, +int ProxyResolverFixed::GetProxyForURL(const std::string& query_url, + const std::string& pac_url, ProxyInfo* results) { NOTREACHED() << "Should not be asked to do proxy auto config"; return ERR_FAILED; diff --git a/net/proxy/proxy_resolver_fixed.h b/net/proxy/proxy_resolver_fixed.h index 81283e7..1103321 100644 --- a/net/proxy/proxy_resolver_fixed.h +++ b/net/proxy/proxy_resolver_fixed.h @@ -41,8 +41,8 @@ class ProxyResolverFixed : public ProxyResolver { // ProxyResolver methods: virtual int GetProxyConfig(ProxyConfig* config); - virtual int GetProxyForURL(const std::wstring& query_url, - const std::wstring& pac_url, + virtual int GetProxyForURL(const std::string& query_url, + const std::string& pac_url, ProxyInfo* results); private: diff --git a/net/proxy/proxy_resolver_winhttp.cc b/net/proxy/proxy_resolver_winhttp.cc index aa1a296..094f48e 100644 --- a/net/proxy/proxy_resolver_winhttp.cc +++ b/net/proxy/proxy_resolver_winhttp.cc @@ -91,18 +91,18 @@ int ProxyResolverWinHttp::GetProxyConfig(ProxyConfig* config) { if (ie_config.fAutoDetect) config->auto_detect = true; if (ie_config.lpszProxy) - config->proxy_server = ie_config.lpszProxy; + config->proxy_server = WideToASCII(ie_config.lpszProxy); if (ie_config.lpszProxyBypass) - config->proxy_bypass = ie_config.lpszProxyBypass; + config->proxy_bypass = WideToASCII(ie_config.lpszProxyBypass); if (ie_config.lpszAutoConfigUrl) - config->pac_url = ie_config.lpszAutoConfigUrl; + config->pac_url = WideToASCII(ie_config.lpszAutoConfigUrl); FreeConfig(&ie_config); return OK; } -int ProxyResolverWinHttp::GetProxyForURL(const std::wstring& query_url, - const std::wstring& pac_url, +int ProxyResolverWinHttp::GetProxyForURL(const std::string& query_url, + const std::string& pac_url, ProxyInfo* results) { // If we don't have a WinHTTP session, then create a new one. if (!session_handle_ && !OpenWinHttpSession()) @@ -118,12 +118,12 @@ int ProxyResolverWinHttp::GetProxyForURL(const std::wstring& query_url, options.fAutoLogonIfChallenged = TRUE; options.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL; options.lpszAutoConfigUrl = - pac_url.empty() ? L"http://wpad/wpad.dat" : pac_url.c_str(); + pac_url.empty() ? L"http://wpad/wpad.dat" : ASCIIToWide(pac_url).c_str(); WINHTTP_PROXY_INFO info = {0}; DCHECK(session_handle_); - if (!CallWinHttpGetProxyForUrl(session_handle_, query_url.c_str(), &options, - &info)) { + if (!CallWinHttpGetProxyForUrl( + session_handle_, ASCIIToWide(query_url).c_str(), &options, &info)) { DWORD error = GetLastError(); LOG(ERROR) << "WinHttpGetProxyForUrl failed: " << error; @@ -144,7 +144,7 @@ int ProxyResolverWinHttp::GetProxyForURL(const std::wstring& query_url, results->UseDirect(); break; case WINHTTP_ACCESS_TYPE_NAMED_PROXY: - results->UseNamedProxy(info.lpszProxy); + results->UseNamedProxy(WideToASCII(info.lpszProxy)); break; default: NOTREACHED(); diff --git a/net/proxy/proxy_resolver_winhttp.h b/net/proxy/proxy_resolver_winhttp.h index 5d2a432..5de8b01 100644 --- a/net/proxy/proxy_resolver_winhttp.h +++ b/net/proxy/proxy_resolver_winhttp.h @@ -45,8 +45,8 @@ class ProxyResolverWinHttp : public ProxyResolver { // ProxyResolver implementation: virtual int GetProxyConfig(ProxyConfig* config); - virtual int GetProxyForURL(const std::wstring& query_url, - const std::wstring& pac_url, + virtual int GetProxyForURL(const std::string& query_url, + const std::string& pac_url, ProxyInfo* results); private: diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index 6007909..1c6c4059 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc @@ -62,26 +62,26 @@ bool ProxyConfig::Equals(const ProxyConfig& other) const { } // ProxyList ------------------------------------------------------------------ -void ProxyList::SetVector(const std::vector& proxies) { +void ProxyList::SetVector(const std::vector& proxies) { proxies_.clear(); - std::vector::const_iterator iter = proxies.begin(); + std::vector::const_iterator iter = proxies.begin(); for (; iter != proxies.end(); ++iter) { - std::wstring proxy_sever; + std::string proxy_sever; TrimWhitespace(*iter, TRIM_ALL, &proxy_sever); proxies_.push_back(proxy_sever); } } -void ProxyList::Set(const std::wstring& proxy_list) { +void ProxyList::Set(const std::string& proxy_list) { // Extract the different proxies from the list. - std::vector proxies; + std::vector proxies; SplitString(proxy_list, L';', &proxies); SetVector(proxies); } void ProxyList::RemoveBadProxies(const ProxyRetryInfoMap& proxy_retry_info) { - std::vector new_proxy_list; - std::vector::const_iterator iter = proxies_.begin(); + std::vector new_proxy_list; + std::vector::const_iterator iter = proxies_.begin(); for (; iter != proxies_.end(); ++iter) { ProxyRetryInfoMap::const_iterator bad_proxy = proxy_retry_info.find(*iter); @@ -98,16 +98,16 @@ void ProxyList::RemoveBadProxies(const ProxyRetryInfoMap& proxy_retry_info) { proxies_ = new_proxy_list; } -std::wstring ProxyList::Get() const { +std::string ProxyList::Get() const { if (!proxies_.empty()) return proxies_[0]; - return std::wstring(); + return std::string(); } -std::wstring ProxyList::GetList() const { - std::wstring proxy_list; - std::vector::const_iterator iter = proxies_.begin(); +std::string ProxyList::GetList() const { + std::string proxy_list; + std::vector::const_iterator iter = proxies_.begin(); for (; iter != proxies_.end(); ++iter) { if (!proxy_list.empty()) proxy_list += L';'; @@ -158,10 +158,10 @@ void ProxyInfo::Use(const ProxyInfo& other) { } void ProxyInfo::UseDirect() { - proxy_list_.Set(std::wstring()); + proxy_list_.Set(std::string()); } -void ProxyInfo::UseNamedProxy(const std::wstring& proxy_server) { +void ProxyInfo::UseNamedProxy(const std::string& proxy_server) { proxy_list_.Set(proxy_server); } @@ -174,7 +174,7 @@ void ProxyInfo::Apply(HINTERNET request_handle) { pi.lpszProxy = WINHTTP_NO_PROXY_NAME; pi.lpszProxyBypass = WINHTTP_NO_PROXY_BYPASS; } else { - proxy = proxy_list_.Get(); + proxy = ASCIIToWide(proxy_list_.Get()); pi.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY; pi.lpszProxy = const_cast(proxy.c_str()); // NOTE: Specifying a bypass list here would serve no purpose. @@ -192,7 +192,7 @@ class ProxyService::PacRequest : public base::RefCountedThreadSafe { public: PacRequest(ProxyService* service, - const std::wstring& pac_url, + const std::string& pac_url, CompletionCallback* callback) : service_(service), callback_(callback), @@ -205,7 +205,7 @@ class ProxyService::PacRequest : origin_loop_ = MessageLoop::current(); } - void Query(const std::wstring& url, ProxyInfo* results) { + void Query(const std::string& url, ProxyInfo* results) { results_ = results; // If we have a valid callback then execute Query asynchronously if (callback_) { @@ -229,8 +229,8 @@ class ProxyService::PacRequest : private: // Runs on the PAC thread if a valid callback is provided. void DoQuery(ProxyResolver* resolver, - const std::wstring& query_url, - const std::wstring& pac_url) { + const std::string& query_url, + const std::string& pac_url) { int rv = resolver->GetProxyForURL(query_url, pac_url, &results_buf_); if (origin_loop_) { origin_loop_->PostTask(FROM_HERE, @@ -268,7 +268,7 @@ class ProxyService::PacRequest : // Usable from within DoQuery on the PAC thread. ProxyInfo results_buf_; - std::wstring pac_url_; + std::string pac_url_; MessageLoop* origin_loop_; }; @@ -308,16 +308,16 @@ int ProxyService::ResolveProxy(const GURL& url, ProxyInfo* result, // If proxies are specified on a per protocol basis, the proxy server // field contains a list the format of which is as below:- // "scheme1=url:port;scheme2=url:port", etc. - std::wstring url_scheme = ASCIIToWide(url.scheme()); + std::string url_scheme = url.scheme(); - WStringTokenizer proxy_server_list(config_.proxy_server, L";"); + StringTokenizer proxy_server_list(config_.proxy_server, ";"); while (proxy_server_list.GetNext()) { - WStringTokenizer proxy_server_for_scheme( + StringTokenizer proxy_server_for_scheme( proxy_server_list.token_begin(), proxy_server_list.token_end(), - L"="); + "="); while (proxy_server_for_scheme.GetNext()) { - const std::wstring& proxy_server_scheme = + const std::string& proxy_server_scheme = proxy_server_for_scheme.token(); // If we fail to get the proxy server here, it means that @@ -356,7 +356,9 @@ int ProxyService::ResolveProxy(const GURL& url, ProxyInfo* result, scoped_refptr req = new PacRequest(this, config_.pac_url, callback); - req->Query(UTF8ToWide(url.spec()), result); + // TODO(darin): We should strip away any reference fragment since it is + // not relevant, and moreover it could contain non-ASCII bytes. + req->Query(url.spec(), result); if (callback) { if (pac_request) @@ -455,19 +457,19 @@ void ProxyService::UpdateConfig() { } bool ProxyService::ShouldBypassProxyForURL(const GURL& url) { - std::wstring url_domain = ASCIIToWide(url.scheme()); + std::string url_domain = url.scheme(); if (!url_domain.empty()) - url_domain += L"://"; + url_domain += "://"; - url_domain += ASCIIToWide(url.host()); + url_domain += url.host(); StringToLowerASCII(url_domain); - WStringTokenizer proxy_server_bypass_list(config_.proxy_bypass, L";"); + StringTokenizer proxy_server_bypass_list(config_.proxy_bypass, ";"); while (proxy_server_bypass_list.GetNext()) { - std::wstring bypass_url_domain = proxy_server_bypass_list.token(); - if (bypass_url_domain == L"") { + std::string bypass_url_domain = proxy_server_bypass_list.token(); + if (bypass_url_domain == "") { // Any name without a DOT (.) is considered to be local. - if (url.host().find(L'.') == std::wstring::npos) + if (url.host().find('.') == std::string::npos) return true; continue; } @@ -476,9 +478,9 @@ bool ProxyService::ShouldBypassProxyForURL(const GURL& url) { // If no scheme is specified then it indicates that all schemes are // allowed for the current entry. For matching this we just use // the protocol scheme of the url passed in. - if (bypass_url_domain.find(L"://") == std::wstring::npos) { - std::wstring bypass_url_domain_with_scheme = ASCIIToWide(url.scheme()); - bypass_url_domain_with_scheme += L"://"; + if (bypass_url_domain.find("://") == std::string::npos) { + std::string bypass_url_domain_with_scheme = url.scheme(); + bypass_url_domain_with_scheme += "://"; bypass_url_domain_with_scheme += bypass_url_domain; bypass_url_domain = bypass_url_domain_with_scheme; diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h index c52926e..ee2bd23 100644 --- a/net/proxy/proxy_service.h +++ b/net/proxy/proxy_service.h @@ -67,15 +67,15 @@ class ProxyConfig { bool auto_detect; // If non-empty, indicates the URL of the proxy auto-config file to use. - std::wstring pac_url; + std::string pac_url; // If non-empty, indicates the proxy server to use (of the form host:port). - std::wstring proxy_server; + std::string proxy_server; // If non-empty, indicates a comma-delimited list of hosts that should bypass // any proxy configuration. For these hosts, a direct connection should // always be used. - std::wstring proxy_bypass; + std::string proxy_bypass; // Returns true if the given config is equivalent to this config. bool Equals(const ProxyConfig& other) const; @@ -96,7 +96,7 @@ struct ProxyRetryInfo { }; // Map of proxy servers with the associated RetryInfo structures. -typedef std::map ProxyRetryInfoMap; +typedef std::map ProxyRetryInfoMap; // This class can be used to resolve the proxy server to use when loading a // HTTP(S) URL. It uses to the given ProxyResolver to handle the actual proxy @@ -199,20 +199,20 @@ class ProxyList { public: // Initializes the proxy list to a string containing one or more proxy servers // delimited by a semicolon. - void Set(const std::wstring& proxy_list); + void Set(const std::string& proxy_list); // Initializes the proxy list to a vector containing one or more proxy // servers. - void SetVector(const std::vector& proxy_list); + void SetVector(const std::vector& proxy_list); // Remove all proxies known to be bad from the proxy list. void RemoveBadProxies(const ProxyRetryInfoMap& proxy_retry_info); // Returns the first valid proxy server in the list. - std::wstring Get() const; + std::string Get() const; // Returns all the valid proxies, delimited by a semicolon. - std::wstring GetList() const; + std::string GetList() const; // Marks the current proxy server as bad and deletes it from the list. The // list of known bad proxies is given by proxy_retry_info. Returns true if @@ -221,7 +221,7 @@ class ProxyList { private: // List of proxies. - std::vector proxies_; + std::vector proxies_; }; // This object holds proxy information returned by ResolveProxy. @@ -237,7 +237,7 @@ class ProxyInfo { // Use a specific proxy server, of the form: [":" ] // This may optionally be a semi-colon delimited list of proxy servers. - void UseNamedProxy(const std::wstring& proxy_server); + void UseNamedProxy(const std::string& proxy_server); // Apply this proxy information to the given WinHTTP request handle. void Apply(HINTERNET request_handle); @@ -246,9 +246,7 @@ class ProxyInfo { bool is_direct() const { return proxy_list_.Get().empty(); } // Returns the first valid proxy server. - std::wstring proxy_server() const { return proxy_list_.Get(); } - - std::string GetProxyServer() const { return WideToASCII(proxy_server()); } + std::string proxy_server() const { return proxy_list_.Get(); } // Marks the current proxy as bad. Returns true if there is another proxy // available to try in proxy list_. @@ -293,8 +291,8 @@ class ProxyResolver { // Query the proxy auto-config file (specified by |pac_url|) for the proxy to // use to load the given |query_url|. Returns OK if successful or an error // code if otherwise. - virtual int GetProxyForURL(const std::wstring& query_url, - const std::wstring& pac_url, + virtual int GetProxyForURL(const std::string& query_url, + const std::string& pac_url, ProxyInfo* results) = 0; }; diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc index f4b9292..e0fba4e 100644 --- a/net/proxy/proxy_service_unittest.cc +++ b/net/proxy/proxy_service_unittest.cc @@ -43,8 +43,8 @@ class MockProxyResolver : public net::ProxyResolver { *results = *(config.get()); return net::OK; } - virtual int GetProxyForURL(const std::wstring& query_url, - const std::wstring& pac_url, + virtual int GetProxyForURL(const std::string& query_url, + const std::string& pac_url, net::ProxyInfo* results) { if (pac_url != config->pac_url) return net::ERR_INVALID_ARGUMENT; @@ -84,8 +84,8 @@ TEST(ProxyServiceTest, Direct) { TEST(ProxyServiceTest, PAC) { MockProxyResolver resolver; - resolver.config->pac_url = L"http://foopy/proxy.pac"; - resolver.info.UseNamedProxy(L"foopy"); + resolver.config->pac_url = "http://foopy/proxy.pac"; + resolver.info.UseNamedProxy("foopy"); resolver.info_predicate_query_host = "www.google.com"; net::ProxyService service(&resolver); @@ -96,13 +96,13 @@ TEST(ProxyServiceTest, PAC) { int rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); - EXPECT_EQ(info.proxy_server(), L"foopy"); + EXPECT_EQ(info.proxy_server(), "foopy"); } TEST(ProxyServiceTest, PAC_FailoverToDirect) { MockProxyResolver resolver; - resolver.config->pac_url = L"http://foopy/proxy.pac"; - resolver.info.UseNamedProxy(L"foopy:8080"); + resolver.config->pac_url = "http://foopy/proxy.pac"; + resolver.info.UseNamedProxy("foopy:8080"); resolver.info_predicate_query_host = "www.google.com"; net::ProxyService service(&resolver); @@ -113,7 +113,7 @@ TEST(ProxyServiceTest, PAC_FailoverToDirect) { int rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); - EXPECT_EQ(info.proxy_server(), L"foopy:8080"); + EXPECT_EQ(info.proxy_server(), "foopy:8080"); // Now, imagine that connecting to foopy:8080 fails. rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); @@ -125,8 +125,8 @@ TEST(ProxyServiceTest, PAC_FailsToDownload) { // Test what happens when we fail to download the PAC URL. MockProxyResolver resolver; - resolver.config->pac_url = L"http://foopy/proxy.pac"; - resolver.info.UseNamedProxy(L"foopy:8080"); + resolver.config->pac_url = "http://foopy/proxy.pac"; + resolver.info.UseNamedProxy("foopy:8080"); resolver.info_predicate_query_host = "www.google.com"; resolver.fail_get_proxy_for_url = true; @@ -143,14 +143,14 @@ TEST(ProxyServiceTest, PAC_FailsToDownload) { EXPECT_TRUE(info.is_direct()); resolver.fail_get_proxy_for_url = false; - resolver.info.UseNamedProxy(L"foopy_valid:8080"); + resolver.info.UseNamedProxy("foopy_valid:8080"); // But, if that fails, then we should give the proxy config another shot // since we have never tried it with this URL before. rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); - EXPECT_EQ(info.proxy_server(), L"foopy_valid:8080"); + EXPECT_EQ(info.proxy_server(), "foopy_valid:8080"); } TEST(ProxyServiceTest, ProxyFallback) { @@ -158,8 +158,8 @@ TEST(ProxyServiceTest, ProxyFallback) { // are bad. MockProxyResolver resolver; - resolver.config->pac_url = L"http://foopy/proxy.pac"; - resolver.info.UseNamedProxy(L"foopy1:8080;foopy2:9090"); + resolver.config->pac_url = "http://foopy/proxy.pac"; + resolver.info.UseNamedProxy("foopy1:8080;foopy2:9090"); resolver.info_predicate_query_host = "www.google.com"; resolver.fail_get_proxy_for_url = false; @@ -174,31 +174,31 @@ TEST(ProxyServiceTest, ProxyFallback) { EXPECT_FALSE(info.is_direct()); // The first item is valid. - EXPECT_EQ(info.proxy_server(), L"foopy1:8080"); + EXPECT_EQ(info.proxy_server(), "foopy1:8080"); // Fake an error on the proxy. rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); // The second proxy should be specified. - EXPECT_EQ(info.proxy_server(), L"foopy2:9090"); + EXPECT_EQ(info.proxy_server(), "foopy2:9090"); // Create a new resolver that returns 3 proxies. The second one is already // known to be bad. - resolver.config->pac_url = L"http://foopy/proxy.pac"; - resolver.info.UseNamedProxy(L"foopy3:7070;foopy1:8080;foopy2:9090"); + resolver.config->pac_url = "http://foopy/proxy.pac"; + resolver.info.UseNamedProxy("foopy3:7070;foopy1:8080;foopy2:9090"); resolver.info_predicate_query_host = "www.google.com"; resolver.fail_get_proxy_for_url = false; rv = service.ResolveProxy(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info.is_direct()); - EXPECT_EQ(info.proxy_server(), L"foopy3:7070"); + EXPECT_EQ(info.proxy_server(), "foopy3:7070"); // We fake another error. It should now try the third one. rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); - EXPECT_EQ(info.proxy_server(), L"foopy2:9090"); + EXPECT_EQ(info.proxy_server(), "foopy2:9090"); // Fake another error, the last proxy is gone, the list should now be empty. rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); @@ -216,8 +216,8 @@ TEST(ProxyServiceTest, ProxyFallback_NewSettings) { // Test proxy failover when new settings are available. MockProxyResolver resolver; - resolver.config->pac_url = L"http://foopy/proxy.pac"; - resolver.info.UseNamedProxy(L"foopy1:8080;foopy2:9090"); + resolver.config->pac_url = "http://foopy/proxy.pac"; + resolver.info.UseNamedProxy("foopy1:8080;foopy2:9090"); resolver.info_predicate_query_host = "www.google.com"; resolver.fail_get_proxy_for_url = false; @@ -232,39 +232,39 @@ TEST(ProxyServiceTest, ProxyFallback_NewSettings) { EXPECT_FALSE(info.is_direct()); // The first item is valid. - EXPECT_EQ(info.proxy_server(), L"foopy1:8080"); + EXPECT_EQ(info.proxy_server(), "foopy1:8080"); // Fake an error on the proxy, and also a new configuration on the proxy. resolver.config.reset(new net::ProxyConfig); - resolver.config->pac_url = L"http://foopy-new/proxy.pac"; + resolver.config->pac_url = "http://foopy-new/proxy.pac"; rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); // The first proxy is still there since the configuration changed. - EXPECT_EQ(info.proxy_server(), L"foopy1:8080"); + EXPECT_EQ(info.proxy_server(), "foopy1:8080"); // We fake another error. It should now ignore the first one. rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); - EXPECT_EQ(info.proxy_server(), L"foopy2:9090"); + EXPECT_EQ(info.proxy_server(), "foopy2:9090"); // We simulate a new configuration. resolver.config.reset(new net::ProxyConfig); - resolver.config->pac_url = L"http://foopy-new2/proxy.pac"; + resolver.config->pac_url = "http://foopy-new2/proxy.pac"; // We fake anothe error. It should go back to the first proxy. rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); EXPECT_EQ(rv, net::OK); - EXPECT_EQ(info.proxy_server(), L"foopy1:8080"); + EXPECT_EQ(info.proxy_server(), "foopy1:8080"); } TEST(ProxyServiceTest, ProxyFallback_BadConfig) { // Test proxy failover when the configuration is bad. MockProxyResolver resolver; - resolver.config->pac_url = L"http://foopy/proxy.pac"; - resolver.info.UseNamedProxy(L"foopy1:8080;foopy2:9090"); + resolver.config->pac_url = "http://foopy/proxy.pac"; + resolver.info.UseNamedProxy("foopy1:8080;foopy2:9090"); resolver.info_predicate_query_host = "www.google.com"; resolver.fail_get_proxy_for_url = false; @@ -279,7 +279,7 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfig) { EXPECT_FALSE(info.is_direct()); // The first item is valid. - EXPECT_EQ(info.proxy_server(), L"foopy1:8080"); + EXPECT_EQ(info.proxy_server(), "foopy1:8080"); // Fake a proxy error. rv = service.ReconsiderProxyAfterError(url, &info, NULL, NULL); @@ -287,7 +287,7 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfig) { // The first proxy is ignored, and the second one is selected. EXPECT_FALSE(info.is_direct()); - EXPECT_EQ(info.proxy_server(), L"foopy2:9090"); + EXPECT_EQ(info.proxy_server(), "foopy2:9090"); // Fake a PAC failure. net::ProxyInfo info2; @@ -317,16 +317,16 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfig) { // The first proxy is still there since the list of bad proxies got cleared. EXPECT_FALSE(info3.is_direct()); - EXPECT_EQ(info3.proxy_server(), L"foopy1:8080"); + EXPECT_EQ(info3.proxy_server(), "foopy1:8080"); } TEST(ProxyServiceTest, ProxyBypassList) { // Test what happens when a proxy bypass list is specified. MockProxyResolver resolver; - resolver.config->proxy_server = L"foopy1:8080;foopy2:9090"; + resolver.config->proxy_server = "foopy1:8080;foopy2:9090"; resolver.config->auto_detect = false; - resolver.config->proxy_bypass = L""; + resolver.config->proxy_bypass = ""; net::ProxyService service(&resolver); GURL url("http://www.google.com/"); @@ -343,7 +343,7 @@ TEST(ProxyServiceTest, ProxyBypassList) { EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info1.is_direct()); - resolver.config->proxy_bypass = L";*.org"; + resolver.config->proxy_bypass = ";*.org"; net::ProxyService service2(&resolver); GURL test_url2("http://www.webkit.org"); net::ProxyInfo info2; @@ -351,7 +351,7 @@ TEST(ProxyServiceTest, ProxyBypassList) { EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info2.is_direct()); - resolver.config->proxy_bypass = L";*.org;7*"; + resolver.config->proxy_bypass = ";*.org;7*"; net::ProxyService service3(&resolver); GURL test_url3("http://74.125.19.147"); net::ProxyInfo info3; @@ -359,7 +359,7 @@ TEST(ProxyServiceTest, ProxyBypassList) { EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info3.is_direct()); - resolver.config->proxy_bypass = L";*.org;"; + resolver.config->proxy_bypass = ";*.org;"; net::ProxyService service4(&resolver); GURL test_url4("http://www.msn.com"); net::ProxyInfo info4; @@ -370,7 +370,7 @@ TEST(ProxyServiceTest, ProxyBypassList) { TEST(ProxyServiceTest, PerProtocolProxyTests) { MockProxyResolver resolver; - resolver.config->proxy_server = L"http=foopy1:8080;https=foopy2:8080"; + resolver.config->proxy_server = "http=foopy1:8080;https=foopy2:8080"; resolver.config->auto_detect = false; net::ProxyService service1(&resolver); @@ -379,7 +379,7 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) { int rv = service1.ResolveProxy(test_url1, &info1, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info1.is_direct()); - EXPECT_TRUE(info1.proxy_server() == L"foopy1:8080"); + EXPECT_TRUE(info1.proxy_server() == "foopy1:8080"); net::ProxyService service2(&resolver); GURL test_url2("ftp://ftp.google.com"); @@ -387,7 +387,7 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) { rv = service2.ResolveProxy(test_url2, &info2, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_TRUE(info2.is_direct()); - EXPECT_TRUE(info2.proxy_server() == L""); + EXPECT_TRUE(info2.proxy_server() == ""); net::ProxyService service3(&resolver); GURL test_url3("https://webbranch.techcu.com"); @@ -395,14 +395,14 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) { rv = service3.ResolveProxy(test_url3, &info3, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info3.is_direct()); - EXPECT_TRUE(info3.proxy_server() == L"foopy2:8080"); + EXPECT_TRUE(info3.proxy_server() == "foopy2:8080"); - resolver.config->proxy_server = L"foopy1:8080"; + resolver.config->proxy_server = "foopy1:8080"; net::ProxyService service4(&resolver); GURL test_url4("www.microsoft.com"); net::ProxyInfo info4; rv = service4.ResolveProxy(test_url4, &info4, NULL, NULL); EXPECT_EQ(rv, net::OK); EXPECT_FALSE(info4.is_direct()); - EXPECT_TRUE(info4.proxy_server() == L"foopy1:8080"); + EXPECT_TRUE(info4.proxy_server() == "foopy1:8080"); } -- cgit v1.1