summaryrefslogtreecommitdiffstats
path: root/net/proxy
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-09 20:35:40 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-09 20:35:40 +0000
commitf9ad22f0e3faea2c7a1fb9853bbf3fb768637be0 (patch)
treedce1dc706e3be50f17104581823593354f63f278 /net/proxy
parent7284c6508f840128a86ebed19423157a10e7ed41 (diff)
downloadchromium_src-f9ad22f0e3faea2c7a1fb9853bbf3fb768637be0.zip
chromium_src-f9ad22f0e3faea2c7a1fb9853bbf3fb768637be0.tar.gz
chromium_src-f9ad22f0e3faea2c7a1fb9853bbf3fb768637be0.tar.bz2
This change implements the performance recommendation from:
http://msdn.microsoft.com/en-us/library/aa383153(VS.85).aspx This fixes the performance problem of resolving PAC query when WinHTTP AutoProxy service is running, which seems to at least be default on Vista and Win2k3. Contributed by griffinz@gmail.com BUG=1684 R=nsylvain Review URL: http://codereview.chromium.org/1657 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1924 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy')
-rw-r--r--net/proxy/proxy_resolver_winhttp.cc38
1 files changed, 25 insertions, 13 deletions
diff --git a/net/proxy/proxy_resolver_winhttp.cc b/net/proxy/proxy_resolver_winhttp.cc
index beb079e..2a12e06 100644
--- a/net/proxy/proxy_resolver_winhttp.cc
+++ b/net/proxy/proxy_resolver_winhttp.cc
@@ -90,7 +90,7 @@ int ProxyResolverWinHttp::GetProxyForURL(const std::string& query_url,
// supports DHCP based auto-detection) also appears to have issues.
//
WINHTTP_AUTOPROXY_OPTIONS options = {0};
- options.fAutoLogonIfChallenged = TRUE;
+ options.fAutoLogonIfChallenged = FALSE;
options.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
std::wstring pac_url_wide = ASCIIToWide(pac_url);
options.lpszAutoConfigUrl =
@@ -98,19 +98,31 @@ int ProxyResolverWinHttp::GetProxyForURL(const std::string& query_url,
WINHTTP_PROXY_INFO info = {0};
DCHECK(session_handle_);
- if (!CallWinHttpGetProxyForUrl(
- session_handle_, ASCIIToWide(query_url).c_str(), &options, &info)) {
- DWORD error = GetLastError();
- LOG(ERROR) << "WinHttpGetProxyForUrl failed: " << error;
-
- // If we got here because of RPC timeout during out of process PAC
- // resolution, no further requests on this session are going to work.
- if ((ERROR_WINHTTP_TIMEOUT == error) ||
- (ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR == error)) {
- CloseWinHttpSession();
- }
- return ERR_FAILED; // TODO(darin): Bug 1189288: translate error code.
+ // Per http://msdn.microsoft.com/en-us/library/aa383153(VS.85).aspx, it is
+ // necessary to first try resolving with fAutoLogonIfChallenged set to false.
+ // Otherwise, we fail over to trying it with a value of true. This way we
+ // get good performance in the case where WinHTTP uses an out-of-process
+ // resolver. This is important for Vista and Win2k3.
+ BOOL ok = CallWinHttpGetProxyForUrl(
+ session_handle_, ASCIIToWide(query_url).c_str(), &options, &info);
+ if (!ok) {
+ if (ERROR_WINHTTP_LOGIN_FAILURE == GetLastError()) {
+ options.fAutoLogonIfChallenged = TRUE;
+ ok = CallWinHttpGetProxyForUrl(
+ session_handle_, ASCIIToWide(query_url).c_str(), &options, &info);
+ }
+ if (!ok) {
+ DWORD error = GetLastError();
+ LOG(ERROR) << "WinHttpGetProxyForUrl failed: " << error;
+ // If we got here because of RPC timeout during out of process PAC
+ // resolution, no further requests on this session are going to work.
+ if (ERROR_WINHTTP_TIMEOUT == error ||
+ ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR == error) {
+ CloseWinHttpSession();
+ }
+ return ERR_FAILED; // TODO(darin): Bug 1189288: translate error code.
+ }
}
int rv = OK;