Chromium Code Reviews| Index: net/dns/async_host_resolver.cc |
| diff --git a/net/dns/async_host_resolver.cc b/net/dns/async_host_resolver.cc |
| index 6f6552bcfa684a7c680c9076ef19733c45e9918c..81133fbae03d541799a0b0cd8aa2176d199b750f 100644 |
| --- a/net/dns/async_host_resolver.cc |
| +++ b/net/dns/async_host_resolver.cc |
| @@ -349,8 +349,9 @@ void AsyncHostResolver::OnDnsRequestComplete( |
| RequestList& requests = rit->second; |
| int port = requests.empty() ? 80 : requests.front()->info().port(); |
| - // Extract AddressList out of DnsResponse. |
| + // Extract AddressList and TTL out of DnsResponse. |
| AddressList addr_list; |
| + uint32 ttl = kuint32max; |
| if (result == OK) { |
| IPAddressList ip_addresses; |
| DnsRecordParser parser = response->Parser(); |
| @@ -362,6 +363,7 @@ void AsyncHostResolver::OnDnsRequestComplete( |
| record.rdata.size() == kIPv6AddressSize)) { |
| ip_addresses.push_back(IPAddressNumber(record.rdata.begin(), |
| record.rdata.end())); |
| + ttl = std::min(ttl, record.ttl); |
|
cbentzel
2012/01/20 11:04:53
I thought all of the RR's in the RRSet need to hav
szym
2012/01/20 16:31:46
This policy is just a stub. We really should check
|
| } |
| } |
| if (!ip_addresses.empty()) |
| @@ -389,7 +391,11 @@ void AsyncHostResolver::OnDnsRequestComplete( |
| HostResolver::RequestInfo info = request->info(); |
| HostCache::Key key( |
| info.hostname(), info.address_family(), info.host_resolver_flags()); |
| - cache_->Set(key, result, addr_list, base::TimeTicks::Now()); |
| + cache_->Set(key, |
| + result, |
| + addr_list, |
| + base::TimeTicks::Now(), |
| + base::TimeDelta::FromSeconds(ttl)); |
| } |
| // Cleanup requests. |