Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Unified Diff: net/dns/async_host_resolver.cc

Issue 9197009: Adds custom ttl argument to HostCache::Set. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed incomplete refactor. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698