OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base/host_resolver_impl.h" | 5 #include "net/base/host_resolver_impl.h" |
6 #include "net/base/net_log.h" | 6 #include "net/base/net_log.h" |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <deque> | 9 #include <deque> |
10 | 10 |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 return; | 996 return; |
997 } | 997 } |
998 } | 998 } |
999 | 999 |
1000 cur_completing_job_ = NULL; | 1000 cur_completing_job_ = NULL; |
1001 } | 1001 } |
1002 | 1002 |
1003 void HostResolverImpl::OnStartRequest(const BoundNetLog& net_log, | 1003 void HostResolverImpl::OnStartRequest(const BoundNetLog& net_log, |
1004 int request_id, | 1004 int request_id, |
1005 const RequestInfo& info) { | 1005 const RequestInfo& info) { |
1006 net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL); | 1006 net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL, NULL); |
1007 | 1007 |
1008 if (requests_trace_) { | 1008 if (requests_trace_) { |
1009 requests_trace_->Add(StringPrintf( | 1009 requests_trace_->Add(StringPrintf( |
1010 "Received request r%d for {hostname='%s', port=%d, priority=%d, " | 1010 "Received request r%d for {hostname='%s', port=%d, priority=%d, " |
1011 "speculative=%d, address_family=%d, allow_cached=%d, referrer='%s'}", | 1011 "speculative=%d, address_family=%d, allow_cached=%d, referrer='%s'}", |
1012 request_id, | 1012 request_id, |
1013 info.hostname().c_str(), | 1013 info.hostname().c_str(), |
1014 info.port(), | 1014 info.port(), |
1015 static_cast<int>(info.priority()), | 1015 static_cast<int>(info.priority()), |
1016 static_cast<int>(info.is_speculative()), | 1016 static_cast<int>(info.is_speculative()), |
1017 static_cast<int>(info.address_family()), | 1017 static_cast<int>(info.address_family()), |
1018 static_cast<int>(info.allow_cached_response()), | 1018 static_cast<int>(info.allow_cached_response()), |
1019 info.referrer().spec().c_str())); | 1019 info.referrer().spec().c_str())); |
1020 } | 1020 } |
1021 | 1021 |
1022 // Notify the observers of the start. | 1022 // Notify the observers of the start. |
1023 if (!observers_.empty()) { | 1023 if (!observers_.empty()) { |
1024 net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART); | 1024 net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART, NULL); |
1025 | 1025 |
1026 for (ObserversList::iterator it = observers_.begin(); | 1026 for (ObserversList::iterator it = observers_.begin(); |
1027 it != observers_.end(); ++it) { | 1027 it != observers_.end(); ++it) { |
1028 (*it)->OnStartResolution(request_id, info); | 1028 (*it)->OnStartResolution(request_id, info); |
1029 } | 1029 } |
1030 | 1030 |
1031 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART); | 1031 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART, NULL); |
1032 } | 1032 } |
1033 } | 1033 } |
1034 | 1034 |
1035 void HostResolverImpl::OnFinishRequest(const BoundNetLog& net_log, | 1035 void HostResolverImpl::OnFinishRequest(const BoundNetLog& net_log, |
1036 int request_id, | 1036 int request_id, |
1037 const RequestInfo& info, | 1037 const RequestInfo& info, |
1038 int error) { | 1038 int error) { |
1039 if (requests_trace_) { | 1039 if (requests_trace_) { |
1040 requests_trace_->Add(StringPrintf( | 1040 requests_trace_->Add(StringPrintf( |
1041 "Finished request r%d with error=%d", request_id, error)); | 1041 "Finished request r%d with error=%d", request_id, error)); |
1042 } | 1042 } |
1043 | 1043 |
1044 // Notify the observers of the completion. | 1044 // Notify the observers of the completion. |
1045 if (!observers_.empty()) { | 1045 if (!observers_.empty()) { |
1046 net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH); | 1046 net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH, NULL); |
1047 | 1047 |
1048 bool was_resolved = error == OK; | 1048 bool was_resolved = error == OK; |
1049 for (ObserversList::iterator it = observers_.begin(); | 1049 for (ObserversList::iterator it = observers_.begin(); |
1050 it != observers_.end(); ++it) { | 1050 it != observers_.end(); ++it) { |
1051 (*it)->OnFinishResolutionWithStatus(request_id, was_resolved, info); | 1051 (*it)->OnFinishResolutionWithStatus(request_id, was_resolved, info); |
1052 } | 1052 } |
1053 | 1053 |
1054 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH); | 1054 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH, NULL); |
1055 } | 1055 } |
1056 | 1056 |
1057 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL); | 1057 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL, NULL); |
1058 } | 1058 } |
1059 | 1059 |
1060 void HostResolverImpl::OnCancelRequest(const BoundNetLog& net_log, | 1060 void HostResolverImpl::OnCancelRequest(const BoundNetLog& net_log, |
1061 int request_id, | 1061 int request_id, |
1062 const RequestInfo& info) { | 1062 const RequestInfo& info) { |
1063 net_log.AddEvent(NetLog::TYPE_CANCELLED); | 1063 net_log.AddEvent(NetLog::TYPE_CANCELLED, NULL); |
1064 | 1064 |
1065 if (requests_trace_) | 1065 if (requests_trace_) |
1066 requests_trace_->Add(StringPrintf("Cancelled request r%d", request_id)); | 1066 requests_trace_->Add(StringPrintf("Cancelled request r%d", request_id)); |
1067 | 1067 |
1068 // Notify the observers of the cancellation. | 1068 // Notify the observers of the cancellation. |
1069 if (!observers_.empty()) { | 1069 if (!observers_.empty()) { |
1070 net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL); | 1070 net_log.BeginEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL, NULL); |
1071 | 1071 |
1072 for (ObserversList::iterator it = observers_.begin(); | 1072 for (ObserversList::iterator it = observers_.begin(); |
1073 it != observers_.end(); ++it) { | 1073 it != observers_.end(); ++it) { |
1074 (*it)->OnCancelResolution(request_id, info); | 1074 (*it)->OnCancelResolution(request_id, info); |
1075 } | 1075 } |
1076 | 1076 |
1077 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL); | 1077 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL, NULL); |
1078 } | 1078 } |
1079 | 1079 |
1080 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL); | 1080 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL, NULL); |
1081 } | 1081 } |
1082 | 1082 |
1083 void HostResolverImpl::OnIPAddressChanged() { | 1083 void HostResolverImpl::OnIPAddressChanged() { |
1084 if (cache_.get()) | 1084 if (cache_.get()) |
1085 cache_->clear(); | 1085 cache_->clear(); |
1086 if (ipv6_probe_monitoring_) { | 1086 if (ipv6_probe_monitoring_) { |
1087 DCHECK(!shutdown_); | 1087 DCHECK(!shutdown_); |
1088 if (shutdown_) | 1088 if (shutdown_) |
1089 return; | 1089 return; |
1090 DiscardIPv6ProbeJob(); | 1090 DiscardIPv6ProbeJob(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 if (r == req) | 1194 if (r == req) |
1195 return error; | 1195 return error; |
1196 | 1196 |
1197 r->OnComplete(error, AddressList()); | 1197 r->OnComplete(error, AddressList()); |
1198 } | 1198 } |
1199 | 1199 |
1200 return ERR_IO_PENDING; | 1200 return ERR_IO_PENDING; |
1201 } | 1201 } |
1202 | 1202 |
1203 } // namespace net | 1203 } // namespace net |
OLD | NEW |