Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: net/base/host_resolver.cc

Issue 150001: Ensure that even if the HostResolver outlives the IO thread, its jobs will no... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/host_resolver.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_resolver.cc
===================================================================
--- net/base/host_resolver.cc (revision 19453)
+++ net/base/host_resolver.cc (working copy)
@@ -398,7 +398,8 @@
//-----------------------------------------------------------------------------
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 @@
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 @@
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);
« no previous file with comments | « net/base/host_resolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698