summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 20:14:27 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 20:14:27 +0000
commit04a0f0269fc3e37cf6d79b86ca136e45d63a14b5 (patch)
tree68fdeca2da4b79d08a76a68320668852f8f4c4b6 /chrome/browser/net
parent83f1b0828b19c791df2f4765296777e4bfeb60b2 (diff)
downloadchromium_src-04a0f0269fc3e37cf6d79b86ca136e45d63a14b5.zip
chromium_src-04a0f0269fc3e37cf6d79b86ca136e45d63a14b5.tar.gz
chromium_src-04a0f0269fc3e37cf6d79b86ca136e45d63a14b5.tar.bz2
* Add an OnCancelResolution() notifier to HostResolver::Observer, so observers can tell when a request has been cancelled.
* Use OnCancelResolution() in DNS prefetcher observer, to avoid leaking entries in the |resolution| table when requests are cancelled. (BUG=14138) * Fix a bug where completion notification wasn't being sent when the response was cached. (BUG=14188) BUG=14138,14188 TEST=HostResolverTest.CancellationObserver, HostResolverTest.Observer Review URL: http://codereview.chromium.org/125171 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/dns_global.cc26
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)