diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-17 02:34:56 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-17 02:34:56 +0000 |
commit | 1ff3c23680621228ea756e1acde0ede0f5baabbb (patch) | |
tree | fca0796944126c794f5e80696ac9a622b786bb88 /net/base | |
parent | 3e8f4cf5a6765a50218a116d5638eb8884a6a6e1 (diff) | |
download | chromium_src-1ff3c23680621228ea756e1acde0ede0f5baabbb.zip chromium_src-1ff3c23680621228ea756e1acde0ede0f5baabbb.tar.gz chromium_src-1ff3c23680621228ea756e1acde0ede0f5baabbb.tar.bz2 |
Re-land second-to-last subset of r18520 (now everything is relanded except notification of cancellation during destruction).
The original code review that this belongs to is:<http://codereview.chromium.org/125171>. (BUG=14138)
The original was backed out because of a valgrind linux error (BUG=14218), so I am now re-landing in smaller chunks to identify where the problem resides
Review URL: http://codereview.chromium.org/126254
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/host_resolver.cc | 9 | ||||
-rw-r--r-- | net/base/host_resolver.h | 4 | ||||
-rw-r--r-- | net/base/host_resolver_unittest.cc | 7 |
3 files changed, 17 insertions, 3 deletions
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc index 14ad212..d834eb1 100644 --- a/net/base/host_resolver.cc +++ b/net/base/host_resolver.cc @@ -488,6 +488,7 @@ void HostResolver::CancelRequest(Request* req) { DCHECK(req->job()); // NULL out the fields of req, to mark it as cancelled. req->MarkAsCancelled(); + NotifyObserversCancelRequest(req->id(), req->info()); } void HostResolver::AddObserver(Observer* observer) { @@ -578,6 +579,14 @@ void HostResolver::NotifyObserversFinishRequest(int request_id, } } +void HostResolver::NotifyObserversCancelRequest(int request_id, + const RequestInfo& info) { + for (ObserversList::iterator it = observers_.begin(); + it != observers_.end(); ++it) { + (*it)->OnCancelResolution(request_id, info); + } +} + //----------------------------------------------------------------------------- SingleRequestHostResolver::SingleRequestHostResolver(HostResolver* resolver) diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h index 6e2add7..0b5c3fc 100644 --- a/net/base/host_resolver.h +++ b/net/base/host_resolver.h @@ -189,6 +189,10 @@ class HostResolver { 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_; diff --git a/net/base/host_resolver_unittest.cc b/net/base/host_resolver_unittest.cc index 62281f0..41e7047 100644 --- a/net/base/host_resolver_unittest.cc +++ b/net/base/host_resolver_unittest.cc @@ -822,7 +822,7 @@ TEST_F(HostResolverTest, Observers) { // cancelled. There are two ways to cancel a request: // (1) Delete the HostResolver while job is outstanding. // (2) Call HostResolver::CancelRequest() while a request is outstanding. -TEST_F(HostResolverTest, DISABLED_CancellationObserver) { +TEST_F(HostResolverTest, CancellationObserver) { // Set a blocking mapper so we control when the resolver thread finishes. scoped_refptr<WaitingHostMapper> mapper = new WaitingHostMapper(); ScopedHostMapper scoped_mapper(mapper.get()); @@ -863,7 +863,8 @@ TEST_F(HostResolverTest, DISABLED_CancellationObserver) { EXPECT_TRUE(observer.cancel_log[0] == CapturingObserver::StartOrCancelEntry(0, info1)); - + } +#if 0 // Start an async request for (host2:60) net::HostResolver::RequestInfo info2("host2", 60); rv = host_resolver.Resolve(info2, &addrlist, &callback, NULL); @@ -891,7 +892,7 @@ TEST_F(HostResolverTest, DISABLED_CancellationObserver) { net::HostResolver::RequestInfo info("host2", 60); EXPECT_TRUE(observer.cancel_log[1] == CapturingObserver::StartOrCancelEntry(1, info)); - +#endif // Unblock the host mapper to let the worker threads finish. mapper->Signal(); } |