Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: net/proxy/proxy_resolver_winhttp.cc

Issue 112963005: Update uses of UTF conversions in courgette/, device/, extensions/, google_apis/, gpu/, ipc/, media… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_resolver_v8_unittest.cc ('k') | net/proxy/proxy_script_decider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 // If we have been given an empty PAC url, then use auto-detection. 48 // If we have been given an empty PAC url, then use auto-detection.
49 // 49 //
50 // NOTE: We just use DNS-based auto-detection here like Firefox. We do this 50 // NOTE: We just use DNS-based auto-detection here like Firefox. We do this
51 // to avoid WinHTTP's auto-detection code, which while more featureful (it 51 // to avoid WinHTTP's auto-detection code, which while more featureful (it
52 // supports DHCP based auto-detection) also appears to have issues. 52 // supports DHCP based auto-detection) also appears to have issues.
53 // 53 //
54 WINHTTP_AUTOPROXY_OPTIONS options = {0}; 54 WINHTTP_AUTOPROXY_OPTIONS options = {0};
55 options.fAutoLogonIfChallenged = FALSE; 55 options.fAutoLogonIfChallenged = FALSE;
56 options.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL; 56 options.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
57 std::wstring pac_url_wide = ASCIIToWide(pac_url_.spec()); 57 std::wstring pac_url_wide = base::ASCIIToWide(pac_url_.spec());
58 options.lpszAutoConfigUrl = pac_url_wide.c_str(); 58 options.lpszAutoConfigUrl = pac_url_wide.c_str();
59 59
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( 68 BOOL ok = WinHttpGetProxyForUrl(session_handle_,
69 session_handle_, ASCIIToWide(query_url.spec()).c_str(), &options, &info); 69 base::ASCIIToWide(query_url.spec()).c_str(),
70 &options, &info);
70 if (!ok) { 71 if (!ok) {
71 if (ERROR_WINHTTP_LOGIN_FAILURE == GetLastError()) { 72 if (ERROR_WINHTTP_LOGIN_FAILURE == GetLastError()) {
72 options.fAutoLogonIfChallenged = TRUE; 73 options.fAutoLogonIfChallenged = TRUE;
73 ok = WinHttpGetProxyForUrl( 74 ok = WinHttpGetProxyForUrl(
74 session_handle_, ASCIIToWide(query_url.spec()).c_str(), 75 session_handle_, base::ASCIIToWide(query_url.spec()).c_str(),
75 &options, &info); 76 &options, &info);
76 } 77 }
77 if (!ok) { 78 if (!ok) {
78 DWORD error = GetLastError(); 79 DWORD error = GetLastError();
79 // If we got here because of RPC timeout during out of process PAC 80 // If we got here because of RPC timeout during out of process PAC
80 // resolution, no further requests on this session are going to work. 81 // resolution, no further requests on this session are going to work.
81 if (ERROR_WINHTTP_TIMEOUT == error || 82 if (ERROR_WINHTTP_TIMEOUT == error ||
82 ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR == error) { 83 ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR == error) {
83 CloseWinHttpSession(); 84 CloseWinHttpSession();
84 } 85 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 165 }
165 166
166 void ProxyResolverWinHttp::CloseWinHttpSession() { 167 void ProxyResolverWinHttp::CloseWinHttpSession() {
167 if (session_handle_) { 168 if (session_handle_) {
168 WinHttpCloseHandle(session_handle_); 169 WinHttpCloseHandle(session_handle_);
169 session_handle_ = NULL; 170 session_handle_ = NULL;
170 } 171 }
171 } 172 }
172 173
173 } // namespace net 174 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_v8_unittest.cc ('k') | net/proxy/proxy_script_decider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698