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/dns/host_resolver_impl.h" | 5 #include "net/dns/host_resolver_impl.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <Winsock2.h> | 8 #include <Winsock2.h> |
9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
10 #include <netdb.h> | 10 #include <netdb.h> |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 293 |
294 dict->SetInteger("net_error", net_error); | 294 dict->SetInteger("net_error", net_error); |
295 | 295 |
296 if (os_error) { | 296 if (os_error) { |
297 dict->SetInteger("os_error", os_error); | 297 dict->SetInteger("os_error", os_error); |
298 #if defined(OS_POSIX) | 298 #if defined(OS_POSIX) |
299 dict->SetString("os_error_string", gai_strerror(os_error)); | 299 dict->SetString("os_error_string", gai_strerror(os_error)); |
300 #elif defined(OS_WIN) | 300 #elif defined(OS_WIN) |
301 // Map the error code to a human-readable string. | 301 // Map the error code to a human-readable string. |
302 LPWSTR error_string = NULL; | 302 LPWSTR error_string = NULL; |
303 int size = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | | 303 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, |
304 FORMAT_MESSAGE_FROM_SYSTEM, | 304 0, // Use the internal message table. |
305 0, // Use the internal message table. | 305 os_error, |
306 os_error, | 306 0, // Use default language. |
307 0, // Use default language. | 307 (LPWSTR)&error_string, |
308 (LPWSTR)&error_string, | 308 0, // Buffer size. |
309 0, // Buffer size. | 309 0); // Arguments (unused). |
310 0); // Arguments (unused). | |
311 dict->SetString("os_error_string", base::WideToUTF8(error_string)); | 310 dict->SetString("os_error_string", base::WideToUTF8(error_string)); |
312 LocalFree(error_string); | 311 LocalFree(error_string); |
313 #endif | 312 #endif |
314 } | 313 } |
315 | 314 |
316 return dict; | 315 return dict; |
317 } | 316 } |
318 | 317 |
319 // Creates NetLog parameters when the DnsTask failed. | 318 // Creates NetLog parameters when the DnsTask failed. |
320 base::Value* NetLogDnsTaskFailedCallback(int net_error, | 319 base::Value* NetLogDnsTaskFailedCallback(int net_error, |
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2329 dns_client_->SetConfig(dns_config); | 2328 dns_client_->SetConfig(dns_config); |
2330 num_dns_failures_ = 0; | 2329 num_dns_failures_ = 0; |
2331 if (dns_client_->GetConfig()) | 2330 if (dns_client_->GetConfig()) |
2332 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2331 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
2333 } | 2332 } |
2334 | 2333 |
2335 AbortDnsTasks(); | 2334 AbortDnsTasks(); |
2336 } | 2335 } |
2337 | 2336 |
2338 } // namespace net | 2337 } // namespace net |
OLD | NEW |