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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "net/dns/address_sorter.h" | 48 #include "net/dns/address_sorter.h" |
49 #include "net/dns/dns_client.h" | 49 #include "net/dns/dns_client.h" |
50 #include "net/dns/dns_config_service.h" | 50 #include "net/dns/dns_config_service.h" |
51 #include "net/dns/dns_protocol.h" | 51 #include "net/dns/dns_protocol.h" |
52 #include "net/dns/dns_reloader.h" | 52 #include "net/dns/dns_reloader.h" |
53 #include "net/dns/dns_response.h" | 53 #include "net/dns/dns_response.h" |
54 #include "net/dns/dns_transaction.h" | 54 #include "net/dns/dns_transaction.h" |
55 #include "net/dns/dns_util.h" | 55 #include "net/dns/dns_util.h" |
56 #include "net/dns/host_resolver_proc.h" | 56 #include "net/dns/host_resolver_proc.h" |
57 #include "net/log/net_log.h" | 57 #include "net/log/net_log.h" |
| 58 #include "net/log/net_log_capture_mode.h" |
58 #include "net/log/net_log_event_type.h" | 59 #include "net/log/net_log_event_type.h" |
| 60 #include "net/log/net_log_parameters_callback_typedef.h" |
| 61 #include "net/log/net_log_source.h" |
59 #include "net/log/net_log_source_type.h" | 62 #include "net/log/net_log_source_type.h" |
| 63 #include "net/log/net_log_with_source.h" |
60 #include "net/socket/client_socket_factory.h" | 64 #include "net/socket/client_socket_factory.h" |
61 #include "net/udp/datagram_client_socket.h" | 65 #include "net/udp/datagram_client_socket.h" |
62 #include "url/url_canon_ip.h" | 66 #include "url/url_canon_ip.h" |
63 | 67 |
64 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
65 #include "net/base/winsock_init.h" | 69 #include "net/base/winsock_init.h" |
66 #endif | 70 #endif |
67 | 71 |
68 namespace net { | 72 namespace net { |
69 | 73 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 int dns_error, | 367 int dns_error, |
364 NetLogCaptureMode /* capture_mode */) { | 368 NetLogCaptureMode /* capture_mode */) { |
365 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 369 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
366 dict->SetInteger("net_error", net_error); | 370 dict->SetInteger("net_error", net_error); |
367 if (dns_error) | 371 if (dns_error) |
368 dict->SetInteger("dns_error", dns_error); | 372 dict->SetInteger("dns_error", dns_error); |
369 return std::move(dict); | 373 return std::move(dict); |
370 } | 374 } |
371 | 375 |
372 // Creates NetLog parameters containing the information in a RequestInfo object, | 376 // Creates NetLog parameters containing the information in a RequestInfo object, |
373 // along with the associated NetLog::Source. | 377 // along with the associated NetLogSource. |
374 std::unique_ptr<base::Value> NetLogRequestInfoCallback( | 378 std::unique_ptr<base::Value> NetLogRequestInfoCallback( |
375 const HostResolver::RequestInfo* info, | 379 const HostResolver::RequestInfo* info, |
376 NetLogCaptureMode /* capture_mode */) { | 380 NetLogCaptureMode /* capture_mode */) { |
377 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 381 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
378 | 382 |
379 dict->SetString("host", info->host_port_pair().ToString()); | 383 dict->SetString("host", info->host_port_pair().ToString()); |
380 dict->SetInteger("address_family", | 384 dict->SetInteger("address_family", |
381 static_cast<int>(info->address_family())); | 385 static_cast<int>(info->address_family())); |
382 dict->SetBoolean("allow_cached_response", info->allow_cached_response()); | 386 dict->SetBoolean("allow_cached_response", info->allow_cached_response()); |
383 dict->SetBoolean("is_speculative", info->is_speculative()); | 387 dict->SetBoolean("is_speculative", info->is_speculative()); |
384 return std::move(dict); | 388 return std::move(dict); |
385 } | 389 } |
386 | 390 |
387 // Creates NetLog parameters for the creation of a HostResolverImpl::Job. | 391 // Creates NetLog parameters for the creation of a HostResolverImpl::Job. |
388 std::unique_ptr<base::Value> NetLogJobCreationCallback( | 392 std::unique_ptr<base::Value> NetLogJobCreationCallback( |
389 const NetLog::Source& source, | 393 const NetLogSource& source, |
390 const std::string* host, | 394 const std::string* host, |
391 NetLogCaptureMode /* capture_mode */) { | 395 NetLogCaptureMode /* capture_mode */) { |
392 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 396 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
393 source.AddToEventParameters(dict.get()); | 397 source.AddToEventParameters(dict.get()); |
394 dict->SetString("host", *host); | 398 dict->SetString("host", *host); |
395 return std::move(dict); | 399 return std::move(dict); |
396 } | 400 } |
397 | 401 |
398 // Creates NetLog parameters for HOST_RESOLVER_IMPL_JOB_ATTACH/DETACH events. | 402 // Creates NetLog parameters for HOST_RESOLVER_IMPL_JOB_ATTACH/DETACH events. |
399 std::unique_ptr<base::Value> NetLogJobAttachCallback( | 403 std::unique_ptr<base::Value> NetLogJobAttachCallback( |
400 const NetLog::Source& source, | 404 const NetLogSource& source, |
401 RequestPriority priority, | 405 RequestPriority priority, |
402 NetLogCaptureMode /* capture_mode */) { | 406 NetLogCaptureMode /* capture_mode */) { |
403 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 407 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
404 source.AddToEventParameters(dict.get()); | 408 source.AddToEventParameters(dict.get()); |
405 dict->SetString("priority", RequestPriorityToString(priority)); | 409 dict->SetString("priority", RequestPriorityToString(priority)); |
406 return std::move(dict); | 410 return std::move(dict); |
407 } | 411 } |
408 | 412 |
409 // Creates NetLog parameters for the DNS_CONFIG_CHANGED event. | 413 // Creates NetLog parameters for the DNS_CONFIG_CHANGED event. |
410 std::unique_ptr<base::Value> NetLogDnsConfigCallback( | 414 std::unique_ptr<base::Value> NetLogDnsConfigCallback( |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 // If this is the first attempt that is finishing later, then record data | 789 // If this is the first attempt that is finishing later, then record data |
786 // for the first attempt. Won't contaminate with retry attempt's data. | 790 // for the first attempt. Won't contaminate with retry attempt's data. |
787 if (!was_retry_attempt) | 791 if (!was_retry_attempt) |
788 RecordPerformanceHistograms(start_time, error, os_error); | 792 RecordPerformanceHistograms(start_time, error, os_error); |
789 | 793 |
790 RecordAttemptHistograms(start_time, attempt_number, error, os_error); | 794 RecordAttemptHistograms(start_time, attempt_number, error, os_error); |
791 | 795 |
792 if (was_canceled()) | 796 if (was_canceled()) |
793 return; | 797 return; |
794 | 798 |
795 NetLog::ParametersCallback net_log_callback; | 799 NetLogParametersCallback net_log_callback; |
796 if (error != OK) { | 800 if (error != OK) { |
797 net_log_callback = base::Bind(&NetLogProcTaskFailedCallback, | 801 net_log_callback = base::Bind(&NetLogProcTaskFailedCallback, |
798 attempt_number, | 802 attempt_number, |
799 error, | 803 error, |
800 os_error); | 804 os_error); |
801 } else { | 805 } else { |
802 net_log_callback = NetLog::IntCallback("attempt_number", attempt_number); | 806 net_log_callback = NetLog::IntCallback("attempt_number", attempt_number); |
803 } | 807 } |
804 net_log_.AddEvent(NetLogEventType::HOST_RESOLVER_IMPL_ATTEMPT_FINISHED, | 808 net_log_.AddEvent(NetLogEventType::HOST_RESOLVER_IMPL_ATTEMPT_FINISHED, |
805 net_log_callback); | 809 net_log_callback); |
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2605 if (job_) | 2609 if (job_) |
2606 job_->CancelRequest(this); | 2610 job_->CancelRequest(this); |
2607 } | 2611 } |
2608 | 2612 |
2609 void HostResolverImpl::RequestImpl::ChangeRequestPriority( | 2613 void HostResolverImpl::RequestImpl::ChangeRequestPriority( |
2610 RequestPriority priority) { | 2614 RequestPriority priority) { |
2611 job_->ChangeRequestPriority(this, priority); | 2615 job_->ChangeRequestPriority(this, priority); |
2612 } | 2616 } |
2613 | 2617 |
2614 } // namespace net | 2618 } // namespace net |
OLD | NEW |