OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/histogram.h" | 10 #include "base/histogram.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 | 12 |
13 #pragma comment(lib, "winhttp.lib") | 13 #pragma comment(lib, "winhttp.lib") |
14 | 14 |
15 using base::TimeDelta; | 15 using base::TimeDelta; |
16 using base::TimeTicks; | 16 using base::TimeTicks; |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 // A small wrapper for histogramming purposes ;-) | 20 // A small wrapper for histogramming purposes ;-) |
21 static BOOL CallWinHttpGetProxyForUrl(HINTERNET session, LPCWSTR url, | 21 static BOOL CallWinHttpGetProxyForUrl(HINTERNET session, LPCWSTR url, |
22 WINHTTP_AUTOPROXY_OPTIONS* options, | 22 WINHTTP_AUTOPROXY_OPTIONS* options, |
23 WINHTTP_PROXY_INFO* results) { | 23 WINHTTP_PROXY_INFO* results) { |
24 TimeTicks time_start = TimeTicks::Now(); | 24 TimeTicks time_start = TimeTicks::Now(); |
25 BOOL rv = WinHttpGetProxyForUrl(session, url, options, results); | 25 BOOL rv = WinHttpGetProxyForUrl(session, url, options, results); |
26 TimeDelta time_delta = TimeTicks::Now() - time_start; | 26 TimeDelta time_delta = TimeTicks::Now() - time_start; |
27 // Record separately success and failure times since they will have very | 27 // Record separately success and failure times since they will have very |
28 // different characteristics. | 28 // different characteristics. |
29 if (rv) { | 29 if (rv) { |
30 UMA_HISTOGRAM_LONG_TIMES(L"Net.GetProxyForUrl_OK", time_delta); | 30 UMA_HISTOGRAM_LONG_TIMES("Net.GetProxyForUrl_OK", time_delta); |
31 } else { | 31 } else { |
32 UMA_HISTOGRAM_LONG_TIMES(L"Net.GetProxyForUrl_FAIL", time_delta); | 32 UMA_HISTOGRAM_LONG_TIMES("Net.GetProxyForUrl_FAIL", time_delta); |
33 } | 33 } |
34 return rv; | 34 return rv; |
35 } | 35 } |
36 | 36 |
37 static void FreeInfo(WINHTTP_PROXY_INFO* info) { | 37 static void FreeInfo(WINHTTP_PROXY_INFO* info) { |
38 if (info->lpszProxy) | 38 if (info->lpszProxy) |
39 GlobalFree(info->lpszProxy); | 39 GlobalFree(info->lpszProxy); |
40 if (info->lpszProxyBypass) | 40 if (info->lpszProxyBypass) |
41 GlobalFree(info->lpszProxyBypass); | 41 GlobalFree(info->lpszProxyBypass); |
42 } | 42 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 | 153 |
154 void ProxyResolverWinHttp::CloseWinHttpSession() { | 154 void ProxyResolverWinHttp::CloseWinHttpSession() { |
155 if (session_handle_) { | 155 if (session_handle_) { |
156 WinHttpCloseHandle(session_handle_); | 156 WinHttpCloseHandle(session_handle_); |
157 session_handle_ = NULL; | 157 session_handle_ = NULL; |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 } // namespace net | 161 } // namespace net |
162 | |
OLD | NEW |