| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 return false; | 290 return false; |
| 291 default: | 291 default: |
| 292 NOTREACHED(); | 292 NOTREACHED(); |
| 293 return false; | 293 return false; |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 return true; | 296 return true; |
| 297 } | 297 } |
| 298 | 298 |
| 299 // Creates NetLog parameters when the resolve failed. | 299 // Creates NetLog parameters when the resolve failed. |
| 300 base::Value* NetLogProcTaskFailedCallback(uint32 attempt_number, | 300 base::Value* NetLogProcTaskFailedCallback( |
| 301 int net_error, | 301 uint32 attempt_number, |
| 302 int os_error, | 302 int net_error, |
| 303 NetLog::LogLevel /* log_level */) { | 303 int os_error, |
| 304 NetLogCaptureMode /* capture_mode */) { |
| 304 base::DictionaryValue* dict = new base::DictionaryValue(); | 305 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 305 if (attempt_number) | 306 if (attempt_number) |
| 306 dict->SetInteger("attempt_number", attempt_number); | 307 dict->SetInteger("attempt_number", attempt_number); |
| 307 | 308 |
| 308 dict->SetInteger("net_error", net_error); | 309 dict->SetInteger("net_error", net_error); |
| 309 | 310 |
| 310 if (os_error) { | 311 if (os_error) { |
| 311 dict->SetInteger("os_error", os_error); | 312 dict->SetInteger("os_error", os_error); |
| 312 #if defined(OS_POSIX) | 313 #if defined(OS_POSIX) |
| 313 dict->SetString("os_error_string", gai_strerror(os_error)); | 314 dict->SetString("os_error_string", gai_strerror(os_error)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 325 LocalFree(error_string); | 326 LocalFree(error_string); |
| 326 #endif | 327 #endif |
| 327 } | 328 } |
| 328 | 329 |
| 329 return dict; | 330 return dict; |
| 330 } | 331 } |
| 331 | 332 |
| 332 // Creates NetLog parameters when the DnsTask failed. | 333 // Creates NetLog parameters when the DnsTask failed. |
| 333 base::Value* NetLogDnsTaskFailedCallback(int net_error, | 334 base::Value* NetLogDnsTaskFailedCallback(int net_error, |
| 334 int dns_error, | 335 int dns_error, |
| 335 NetLog::LogLevel /* log_level */) { | 336 NetLogCaptureMode /* capture_mode */) { |
| 336 base::DictionaryValue* dict = new base::DictionaryValue(); | 337 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 337 dict->SetInteger("net_error", net_error); | 338 dict->SetInteger("net_error", net_error); |
| 338 if (dns_error) | 339 if (dns_error) |
| 339 dict->SetInteger("dns_error", dns_error); | 340 dict->SetInteger("dns_error", dns_error); |
| 340 return dict; | 341 return dict; |
| 341 }; | 342 }; |
| 342 | 343 |
| 343 // Creates NetLog parameters containing the information in a RequestInfo object, | 344 // Creates NetLog parameters containing the information in a RequestInfo object, |
| 344 // along with the associated NetLog::Source. | 345 // along with the associated NetLog::Source. |
| 345 base::Value* NetLogRequestInfoCallback(const HostResolver::RequestInfo* info, | 346 base::Value* NetLogRequestInfoCallback(const HostResolver::RequestInfo* info, |
| 346 NetLog::LogLevel /* log_level */) { | 347 NetLogCaptureMode /* capture_mode */) { |
| 347 base::DictionaryValue* dict = new base::DictionaryValue(); | 348 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 348 | 349 |
| 349 dict->SetString("host", info->host_port_pair().ToString()); | 350 dict->SetString("host", info->host_port_pair().ToString()); |
| 350 dict->SetInteger("address_family", | 351 dict->SetInteger("address_family", |
| 351 static_cast<int>(info->address_family())); | 352 static_cast<int>(info->address_family())); |
| 352 dict->SetBoolean("allow_cached_response", info->allow_cached_response()); | 353 dict->SetBoolean("allow_cached_response", info->allow_cached_response()); |
| 353 dict->SetBoolean("is_speculative", info->is_speculative()); | 354 dict->SetBoolean("is_speculative", info->is_speculative()); |
| 354 return dict; | 355 return dict; |
| 355 } | 356 } |
| 356 | 357 |
| 357 // Creates NetLog parameters for the creation of a HostResolverImpl::Job. | 358 // Creates NetLog parameters for the creation of a HostResolverImpl::Job. |
| 358 base::Value* NetLogJobCreationCallback(const NetLog::Source& source, | 359 base::Value* NetLogJobCreationCallback(const NetLog::Source& source, |
| 359 const std::string* host, | 360 const std::string* host, |
| 360 NetLog::LogLevel /* log_level */) { | 361 NetLogCaptureMode /* capture_mode */) { |
| 361 base::DictionaryValue* dict = new base::DictionaryValue(); | 362 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 362 source.AddToEventParameters(dict); | 363 source.AddToEventParameters(dict); |
| 363 dict->SetString("host", *host); | 364 dict->SetString("host", *host); |
| 364 return dict; | 365 return dict; |
| 365 } | 366 } |
| 366 | 367 |
| 367 // Creates NetLog parameters for HOST_RESOLVER_IMPL_JOB_ATTACH/DETACH events. | 368 // Creates NetLog parameters for HOST_RESOLVER_IMPL_JOB_ATTACH/DETACH events. |
| 368 base::Value* NetLogJobAttachCallback(const NetLog::Source& source, | 369 base::Value* NetLogJobAttachCallback(const NetLog::Source& source, |
| 369 RequestPriority priority, | 370 RequestPriority priority, |
| 370 NetLog::LogLevel /* log_level */) { | 371 NetLogCaptureMode /* capture_mode */) { |
| 371 base::DictionaryValue* dict = new base::DictionaryValue(); | 372 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 372 source.AddToEventParameters(dict); | 373 source.AddToEventParameters(dict); |
| 373 dict->SetString("priority", RequestPriorityToString(priority)); | 374 dict->SetString("priority", RequestPriorityToString(priority)); |
| 374 return dict; | 375 return dict; |
| 375 } | 376 } |
| 376 | 377 |
| 377 // Creates NetLog parameters for the DNS_CONFIG_CHANGED event. | 378 // Creates NetLog parameters for the DNS_CONFIG_CHANGED event. |
| 378 base::Value* NetLogDnsConfigCallback(const DnsConfig* config, | 379 base::Value* NetLogDnsConfigCallback(const DnsConfig* config, |
| 379 NetLog::LogLevel /* log_level */) { | 380 NetLogCaptureMode /* capture_mode */) { |
| 380 return config->ToValue(); | 381 return config->ToValue(); |
| 381 } | 382 } |
| 382 | 383 |
| 383 // The logging routines are defined here because some requests are resolved | 384 // The logging routines are defined here because some requests are resolved |
| 384 // without a Request object. | 385 // without a Request object. |
| 385 | 386 |
| 386 // Logs when a request has just been started. | 387 // Logs when a request has just been started. |
| 387 void LogStartRequest(const BoundNetLog& source_net_log, | 388 void LogStartRequest(const BoundNetLog& source_net_log, |
| 388 const HostResolver::RequestInfo& info) { | 389 const HostResolver::RequestInfo& info) { |
| 389 source_net_log.BeginEvent( | 390 source_net_log.BeginEvent( |
| (...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2377 dns_client_->SetConfig(dns_config); | 2378 dns_client_->SetConfig(dns_config); |
| 2378 num_dns_failures_ = 0; | 2379 num_dns_failures_ = 0; |
| 2379 if (dns_client_->GetConfig()) | 2380 if (dns_client_->GetConfig()) |
| 2380 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2381 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
| 2381 } | 2382 } |
| 2382 | 2383 |
| 2383 AbortDnsTasks(); | 2384 AbortDnsTasks(); |
| 2384 } | 2385 } |
| 2385 | 2386 |
| 2386 } // namespace net | 2387 } // namespace net |
| OLD | NEW |