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.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc
index ca742da..4f0ede5 100644
--- a/net/base/host_resolver.cc
+++ b/net/base/host_resolver.cc
@@ -398,7 +398,8 @@ class HostResolver::Job : public base::RefCountedThreadSafe<HostResolver::Job> {
//-----------------------------------------------------------------------------
HostResolver::HostResolver(int max_cache_entries, int cache_duration_ms)
- : cache_(max_cache_entries, cache_duration_ms), next_request_id_(0) {
+ : cache_(max_cache_entries, cache_duration_ms), next_request_id_(0),
+ shutdown_(false) {
#if defined(OS_WIN)
EnsureWinsockInit();
#endif
@@ -421,6 +422,9 @@ int HostResolver::Resolve(const RequestInfo& info,
AddressList* addresses,
CompletionCallback* callback,
Request** out_req) {
+ if (shutdown_)
+ return ERR_UNEXPECTED;
+
// Choose a unique ID number for observers to see.
int request_id = next_request_id_++;
@@ -517,6 +521,15 @@ void HostResolver::RemoveObserver(Observer* observer) {
observers_.erase(it);
}
+void HostResolver::Shutdown() {
+ shutdown_ = true;
+
+ // Cancel the outstanding jobs.
+ for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ++it)
+ it->second->Cancel();
+ jobs_.clear();
+}
+
void HostResolver::AddOutstandingJob(Job* job) {
scoped_refptr<Job>& found_job = jobs_[job->host()];
DCHECK(!found_job);