OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/dhcp_proxy_script_adapter_fetcher_win.h" | 5 #include "net/proxy/dhcp_proxy_script_adapter_fetcher_win.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
11 #include "base/metrics/histogram.h" | |
12 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
13 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
14 #include "base/task_runner.h" | 13 #include "base/task_runner.h" |
15 #include "base/time/time.h" | 14 #include "base/time/time.h" |
16 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
17 #include "net/proxy/dhcpcsvc_init_win.h" | 16 #include "net/proxy/dhcpcsvc_init_win.h" |
18 #include "net/proxy/proxy_script_fetcher_impl.h" | 17 #include "net/proxy/proxy_script_fetcher_impl.h" |
19 #include "net/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
20 | 19 |
21 #include <windows.h> | 20 #include <windows.h> |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 const_cast<LPWSTR>(adapter_name_wide.c_str()), | 254 const_cast<LPWSTR>(adapter_name_wide.c_str()), |
256 NULL, | 255 NULL, |
257 send_params, request_params, | 256 send_params, request_params, |
258 result_buffer.get(), &result_buffer_size, | 257 result_buffer.get(), &result_buffer_size, |
259 NULL); | 258 NULL); |
260 ++retry_count; | 259 ++retry_count; |
261 } while (res == ERROR_MORE_DATA && retry_count <= 3); | 260 } while (res == ERROR_MORE_DATA && retry_count <= 3); |
262 | 261 |
263 if (res != NO_ERROR) { | 262 if (res != NO_ERROR) { |
264 VLOG(1) << "Error fetching PAC URL from DHCP: " << res; | 263 VLOG(1) << "Error fetching PAC URL from DHCP: " << res; |
265 UMA_HISTOGRAM_COUNTS("Net.DhcpWpadUnhandledDhcpError", 1); | |
266 } else if (wpad_params.nBytesData) { | 264 } else if (wpad_params.nBytesData) { |
267 return SanitizeDhcpApiString( | 265 return SanitizeDhcpApiString( |
268 reinterpret_cast<const char*>(wpad_params.Data), | 266 reinterpret_cast<const char*>(wpad_params.Data), |
269 wpad_params.nBytesData); | 267 wpad_params.nBytesData); |
270 } | 268 } |
271 | 269 |
272 return ""; | 270 return ""; |
273 } | 271 } |
274 | 272 |
275 // static | 273 // static |
(...skipping 10 matching lines...) Expand all Loading... |
286 // first null in case of embedded NULLs; this is the outer | 284 // first null in case of embedded NULLs; this is the outer |
287 // constructor that takes the result of c_str() on the inner. If | 285 // constructor that takes the result of c_str() on the inner. If |
288 // the server is giving us back a buffer with embedded NULLs, | 286 // the server is giving us back a buffer with embedded NULLs, |
289 // something is broken anyway. Finally, trim trailing whitespace. | 287 // something is broken anyway. Finally, trim trailing whitespace. |
290 std::string result(std::string(data, count_bytes).c_str()); | 288 std::string result(std::string(data, count_bytes).c_str()); |
291 base::TrimWhitespaceASCII(result, base::TRIM_TRAILING, &result); | 289 base::TrimWhitespaceASCII(result, base::TRIM_TRAILING, &result); |
292 return result; | 290 return result; |
293 } | 291 } |
294 | 292 |
295 } // namespace net | 293 } // namespace net |
OLD | NEW |