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

Unified Diff: net/dns/host_cache.cc

Issue 2298173002: Implement host-based deletion for the hostname resolution cache. (Closed)
Patch Set: Updated callsite. 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..ee50f8626131883117e534312428f64d3422d99e 100644
--- a/net/dns/host_cache.cc
+++ b/net/dns/host_cache.cc
@@ -198,6 +198,27 @@ 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;
+ }
+
+ 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, base::TimeTicks::Now(), it->second);
mmenke 2016/08/31 15:24:37 Maybe just call base::TimeTicks::Now() once, outsi
msramek 2016/08/31 16:02:55 Done. Good point - it's even better for consistenc
+ 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