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

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: Removed default TTL from net-internals 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..00ecf5e566e490550a977d1df78acd9da7cf7d3b 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);
}
}
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::TimeDelta::FromSeconds(ttl),
+ base::TimeTicks::Now());
}
// Cleanup requests.

Powered by Google App Engine
This is Rietveld 408576698