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

Unified Diff: net/dns/host_cache.cc

Issue 2298173002: Implement host-based deletion for the hostname resolution cache. (Closed)
Patch Set: Take TimeTicks::Now() out of the loop Created 4 years, 4 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 | « net/dns/host_cache.h ('k') | 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 7556e7eee478408afd182eef19360fafc3681ffe..881f5140b6f8518cc77f2bfe48caae64b36bcdf0 100644
--- a/net/dns/host_cache.cc
+++ b/net/dns/host_cache.cc
@@ -198,6 +198,28 @@ void HostCache::clear() {
entries_.clear();
}
+void HostCache::ClearForHosts(
+ const base::Callback<bool(const std::string&)>& host_filter) {
+ DCHECK(CalledOnValidThread());
+
+ if (host_filter.is_null()) {
+ clear();
+ return;
+ }
+
+ base::TimeTicks now = base::TimeTicks::Now();
+ for (EntryMap::iterator it = entries_.begin(); it != entries_.end();) {
+ EntryMap::iterator next_it = std::next(it);
+
+ if (host_filter.Run(it->first.hostname)) {
+ RecordErase(ERASE_CLEAR, now, it->second);
+ entries_.erase(it);
+ }
+
+ it = next_it;
+ }
+}
+
size_t HostCache::size() const {
DCHECK(CalledOnValidThread());
return entries_.size();
« no previous file with comments | « net/dns/host_cache.h ('k') | net/dns/host_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698