From 04a0f0269fc3e37cf6d79b86ca136e45d63a14b5 Mon Sep 17 00:00:00 2001 From: "ericroman@google.com" Date: Tue, 16 Jun 2009 20:14:27 +0000 Subject: * 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 --- net/base/host_resolver.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'net/base/host_resolver.h') diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h index 34c803f..0b5c3fc 100644 --- a/net/base/host_resolver.h +++ b/net/base/host_resolver.h @@ -106,13 +106,18 @@ class HostResolver { // Called at the start of HostResolver::Resolve(). |id| is a unique number // given to the request, so it can be matched up with a corresponding call - // to OnFinishResolutionWithStatus(). + // to OnFinishResolutionWithStatus() or OnCancelResolution(). virtual void OnStartResolution(int id, const RequestInfo& info) = 0; // Called on completion of request |id|. Note that if the request was - // cancelled, OnFinishResolutionWithStatus() will not be called. + // cancelled, OnCancelResolution() will be called instead. virtual void OnFinishResolutionWithStatus(int id, bool was_resolved, const RequestInfo& info) = 0; + + // Called when request |id| has been cancelled. A request is "cancelled" + // if either the HostResolver is destroyed while a resolution is in + // progress, or HostResolver::CancelRequest() is called. + virtual void OnCancelResolution(int id, const RequestInfo& info) = 0; }; // Creates a HostResolver that caches up to |max_cache_entries| for @@ -175,15 +180,19 @@ class HostResolver { // Callback for when |job| has completed with |error| and |addrlist|. void OnJobComplete(Job* job, int error, const AddressList& addrlist); - // Notify all obsevers of the start of a resolve request. + // Notify all observers of the start of a resolve request. void NotifyObserversStartRequest(int request_id, const RequestInfo& info); - // Notify all obsevers of the completion of a resolve request. + // Notify all observers of the completion of a resolve request. void NotifyObserversFinishRequest(int request_id, const RequestInfo& info, int error); + // Notify all observers of the cancellation of a resolve request. + void NotifyObserversCancelRequest(int request_id, + const RequestInfo& info); + // Cache of host resolution results. HostCache cache_; -- cgit v1.1