Remove HostResolver's CacheHitCallback logic.
It was landed almost a year ago, but was never used. If it turns out we
really do need it, can bring it back.
Bug: none
Change-Id: I8635219b8a3af3c46711ff7931403bf32854f351
Reviewed-on: https://chromium-review.googlesource.com/580387
Reviewed-by: Miriam Gershenson <[email protected]>
Commit-Queue: Matt Menke <[email protected]>
Cr-Commit-Position: refs/heads/master@{#488460}
diff --git a/net/dns/host_resolver_impl.cc b/net/dns/host_resolver_impl.cc
index ba8607b..79953ca 100644
--- a/net/dns/host_resolver_impl.cc
+++ b/net/dns/host_resolver_impl.cc
@@ -1817,12 +1817,8 @@
bool did_complete = (entry.error() != ERR_NETWORK_CHANGED) &&
(entry.error() != ERR_HOST_RESOLVER_QUEUE_TOO_LARGE);
- if (did_complete) {
+ if (did_complete)
resolver_->CacheResult(key_, entry, ttl);
- // Erase any previous cache hit callbacks, since a new DNS request went
- // out since they were set.
- resolver_->cache_hit_callbacks_.erase(key_);
- }
// Complete all of the requests that were attached to the job and
// detach them.
@@ -1833,7 +1829,6 @@
// Update the net log and notify registered observers.
LogFinishRequest(req->source_net_log(), req->info(), entry.error());
if (did_complete) {
- resolver_->MaybeAddCacheHitCallback(key_, req->info());
// Record effective total time from creation to completion.
RecordTotalTime(had_dns_config_, req->info().is_speculative(),
base::TimeTicks::Now() - req->request_time());
@@ -1967,9 +1962,6 @@
Key key;
int rv = ResolveHelper(info, false, nullptr, source_net_log, addresses, &key);
if (rv != ERR_DNS_CACHE_MISS) {
- // TODO(mmenke): Remove this code. Nothing's using it.
- if (rv == OK)
- MaybeAddCacheHitCallback(key, info);
LogFinishRequest(source_net_log, info, rv);
RecordTotalTime(HaveDnsConfig(), info.is_speculative(), base::TimeDelta());
return rv;
@@ -2112,7 +2104,6 @@
source_net_log.AddEvent(NetLogEventType::HOST_RESOLVER_IMPL_CACHE_HIT,
addresses->CreateNetLogCallback());
// |ServeFromCache()| will set |*stale_info| as needed.
- RunCacheHitCallbacks(*key, info);
return net_error;
}
// TODO(szym): Do not do this if nsswitch.conf instructs not to.
@@ -2507,10 +2498,8 @@
last_ipv6_probe_time_ = base::TimeTicks();
// Abandon all ProbeJobs.
probe_weak_ptr_factory_.InvalidateWeakPtrs();
- if (cache_.get()) {
+ if (cache_.get())
cache_->OnNetworkChange();
- cache_hit_callbacks_.clear();
- }
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
RunLoopbackProbeJob();
#endif
@@ -2568,10 +2557,8 @@
// have to expire our internal cache :( Note that OS level DNS caches, such
// as NSCD's cache should be dropped automatically by the OS when
// resolv.conf changes so we don't need to do anything to clear that cache.
- if (cache_.get()) {
+ if (cache_.get())
cache_->OnNetworkChange();
- cache_hit_callbacks_.clear();
- }
// Life check to bail once |this| is deleted.
base::WeakPtr<HostResolverImpl> self = weak_ptr_factory_.GetWeakPtr();
@@ -2617,28 +2604,6 @@
std::abs(net_error));
}
-void HostResolverImpl::OnCacheEntryEvicted(const HostCache::Key& key,
- const HostCache::Entry& entry) {
- cache_hit_callbacks_.erase(key);
-}
-
-void HostResolverImpl::MaybeAddCacheHitCallback(const HostCache::Key& key,
- const RequestInfo& info) {
- const RequestInfo::CacheHitCallback& callback = info.cache_hit_callback();
- if (callback.is_null())
- return;
- cache_hit_callbacks_[key].push_back(callback);
-}
-
-void HostResolverImpl::RunCacheHitCallbacks(const HostCache::Key& key,
- const RequestInfo& info) {
- auto it = cache_hit_callbacks_.find(key);
- if (it == cache_hit_callbacks_.end())
- return;
- for (auto& callback : it->second)
- callback.Run(info);
-}
-
void HostResolverImpl::SetDnsClient(std::unique_ptr<DnsClient> dns_client) {
// DnsClient and config must be updated before aborting DnsTasks, since doing
// so may start new jobs.