diff options
Diffstat (limited to 'chrome/browser/net/dns_global.cc')
-rw-r--r-- | chrome/browser/net/dns_global.cc | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/chrome/browser/net/dns_global.cc b/chrome/browser/net/dns_global.cc index cf7145c..9e4c8f6 100644 --- a/chrome/browser/net/dns_global.cc +++ b/chrome/browser/net/dns_global.cc @@ -149,6 +149,9 @@ class PrefetchObserver : public net::HostResolver::Observer { int request_id, bool was_resolved, const net::HostResolver::RequestInfo& request_info); + virtual void OnCancelResolution( + int request_id, + const net::HostResolver::RequestInfo& request_info); static void DnsGetFirstResolutionsHtml(std::string* output); static void SaveStartupListAsPref(PrefService* local_state); @@ -202,12 +205,9 @@ void PrefetchObserver::OnStartResolution( NavigatingTo(request_info.hostname()); - // TODO(eroman): If the resolve request is cancelled, then - // OnFinishResolutionWithStatus will not be called, and |resolutions| will - // grow unbounded! - // http://crbug.com/14138 - AutoLock auto_lock(*lock); + // This entry will be deleted either by OnFinishResolutionWithStatus(), or + // by OnCancelResolution(). (*resolutions)[request_id] = navigation_info; } @@ -240,6 +240,22 @@ void PrefetchObserver::OnFinishResolutionWithStatus( StartupListAppend(navigation_info); } +void PrefetchObserver::OnCancelResolution( + int request_id, + const net::HostResolver::RequestInfo& request_info) { + if (request_info.is_speculative()) + return; // One of our own requests. + + // Remove the entry from |resolutions| that was added by OnStartResolution(). + AutoLock auto_lock(*lock); + ObservedResolutionMap::iterator it = resolutions->find(request_id); + if (resolutions->end() == it) { + DCHECK(false); + return; + } + resolutions->erase(it); +} + // static void PrefetchObserver::StartupListAppend(const DnsHostInfo& navigation_info) { if (!on_the_record_switch || NULL == dns_master) |