summaryrefslogtreecommitdiffstats
path: root/net/base/host_resolver.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/host_resolver.cc')
-rw-r--r--net/base/host_resolver.cc42
1 files changed, 6 insertions, 36 deletions
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc
index ca742da..5a357eb 100644
--- a/net/base/host_resolver.cc
+++ b/net/base/host_resolver.cc
@@ -184,7 +184,7 @@ class HostResolver::Request {
addresses_(addresses) {}
// Mark the request as cancelled.
- void MarkAsCancelled() {
+ void Cancel() {
job_ = NULL;
callback_ = NULL;
addresses_ = NULL;
@@ -289,26 +289,10 @@ class HostResolver::Job : public base::RefCountedThreadSafe<HostResolver::Job> {
// Cancels the current job. Callable from origin thread.
void Cancel() {
- HostResolver* resolver = resolver_;
resolver_ = NULL;
- // Mark the job as cancelled, so when worker thread completes it will
- // not try to post completion to origin loop.
- {
- AutoLock locked(origin_loop_lock_);
- origin_loop_ = NULL;
- }
-
- // We don't have to do anything further to actually cancel the requests
- // that were attached to this job (since they are unreachable now).
- // But we will call HostResolver::CancelRequest(Request*) on each one
- // in order to notify any observers.
- for (RequestsList::const_iterator it = requests_.begin();
- it != requests_.end(); ++it) {
- HostResolver::Request* req = *it;
- if (!req->was_cancelled())
- resolver->CancelRequest(req);
- }
+ AutoLock locked(origin_loop_lock_);
+ origin_loop_ = NULL;
}
// Called from origin thread.
@@ -406,7 +390,7 @@ HostResolver::HostResolver(int max_cache_entries, int cache_duration_ms)
HostResolver::~HostResolver() {
// Cancel the outstanding jobs. Those jobs may contain several attached
- // requests, which will also be cancelled.
+ // requests, which will now never be completed.
for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ++it)
it->second->Cancel();
@@ -433,12 +417,7 @@ int HostResolver::Resolve(const RequestInfo& info,
info.hostname(), base::TimeTicks::Now());
if (cache_entry) {
addresses->SetFrom(cache_entry->addrlist, info.port());
- int error = OK;
-
- // Notify registered observers.
- NotifyObserversFinishRequest(request_id, info, error);
-
- return error;
+ return OK;
}
}
@@ -499,8 +478,7 @@ void HostResolver::CancelRequest(Request* req) {
DCHECK(req);
DCHECK(req->job());
// NULL out the fields of req, to mark it as cancelled.
- req->MarkAsCancelled();
- NotifyObserversCancelRequest(req->id(), req->info());
+ req->Cancel();
}
void HostResolver::AddObserver(Observer* observer) {
@@ -591,14 +569,6 @@ 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)