OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_resolver_winhttp.h" | 5 #include "net/proxy/proxy_resolver_winhttp.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <winhttp.h> | 8 #include <winhttp.h> |
9 | 9 |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 WINHTTP_PROXY_INFO info = {0}; | 60 WINHTTP_PROXY_INFO info = {0}; |
61 DCHECK(session_handle_); | 61 DCHECK(session_handle_); |
62 | 62 |
63 // Per http://msdn.microsoft.com/en-us/library/aa383153(VS.85).aspx, it is | 63 // Per http://msdn.microsoft.com/en-us/library/aa383153(VS.85).aspx, it is |
64 // necessary to first try resolving with fAutoLogonIfChallenged set to false. | 64 // necessary to first try resolving with fAutoLogonIfChallenged set to false. |
65 // Otherwise, we fail over to trying it with a value of true. This way we | 65 // Otherwise, we fail over to trying it with a value of true. This way we |
66 // get good performance in the case where WinHTTP uses an out-of-process | 66 // get good performance in the case where WinHTTP uses an out-of-process |
67 // resolver. This is important for Vista and Win2k3. | 67 // resolver. This is important for Vista and Win2k3. |
68 BOOL ok = WinHttpGetProxyForUrl(session_handle_, | 68 BOOL ok = WinHttpGetProxyForUrl(session_handle_, |
69 base::ASCIIToWide(query_url.spec()).c_str(), | 69 base::ASCIIToWide(query_url.spec()).c_str(), |
70 &options, &info); | 70 &options, |
| 71 &info); |
71 if (!ok) { | 72 if (!ok) { |
72 if (ERROR_WINHTTP_LOGIN_FAILURE == GetLastError()) { | 73 if (ERROR_WINHTTP_LOGIN_FAILURE == GetLastError()) { |
73 options.fAutoLogonIfChallenged = TRUE; | 74 options.fAutoLogonIfChallenged = TRUE; |
74 ok = WinHttpGetProxyForUrl( | 75 ok = WinHttpGetProxyForUrl(session_handle_, |
75 session_handle_, base::ASCIIToWide(query_url.spec()).c_str(), | 76 base::ASCIIToWide(query_url.spec()).c_str(), |
76 &options, &info); | 77 &options, |
| 78 &info); |
77 } | 79 } |
78 if (!ok) { | 80 if (!ok) { |
79 DWORD error = GetLastError(); | 81 DWORD error = GetLastError(); |
80 // If we got here because of RPC timeout during out of process PAC | 82 // If we got here because of RPC timeout during out of process PAC |
81 // resolution, no further requests on this session are going to work. | 83 // resolution, no further requests on this session are going to work. |
82 if (ERROR_WINHTTP_TIMEOUT == error || | 84 if (ERROR_WINHTTP_TIMEOUT == error || |
83 ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR == error) { | 85 ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR == error) { |
84 CloseWinHttpSession(); | 86 CloseWinHttpSession(); |
85 } | 87 } |
86 return ERR_FAILED; // TODO(darin): Bug 1189288: translate error code. | 88 return ERR_FAILED; // TODO(darin): Bug 1189288: translate error code. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 167 } |
166 | 168 |
167 void ProxyResolverWinHttp::CloseWinHttpSession() { | 169 void ProxyResolverWinHttp::CloseWinHttpSession() { |
168 if (session_handle_) { | 170 if (session_handle_) { |
169 WinHttpCloseHandle(session_handle_); | 171 WinHttpCloseHandle(session_handle_); |
170 session_handle_ = NULL; | 172 session_handle_ = NULL; |
171 } | 173 } |
172 } | 174 } |
173 | 175 |
174 } // namespace net | 176 } // namespace net |
OLD | NEW |