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

Unified Diff: net/dns/host_cache.cc

Issue 2701673003: HostCache: always evict stale entries before valid entries (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | net/dns/host_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_cache.cc
diff --git a/net/dns/host_cache.cc b/net/dns/host_cache.cc
index 1ff1755e8b11da77060185ce61828da4c2f196a4..0026c02176c03c8c5dc28ba463000d4d8699d890 100644
--- a/net/dns/host_cache.cc
+++ b/net/dns/host_cache.cc
@@ -253,8 +253,11 @@ void HostCache::EvictOneEntry(base::TimeTicks now) {
auto oldest_it = entries_.begin();
for (auto it = entries_.begin(); it != entries_.end(); ++it) {
- if (it->second.expires() < oldest_it->second.expires())
+ if ((it->second.expires() < oldest_it->second.expires()) &&
+ (it->second.IsStale(now, network_changes_) ||
+ !oldest_it->second.IsStale(now, network_changes_))) {
oldest_it = it;
+ }
}
if (!eviction_callback_.is_null())
« no previous file with comments | « no previous file | net/dns/host_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698