diff options
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/host_resolver.h | 4 | ||||
-rw-r--r-- | net/base/host_resolver_impl.cc | 9 | ||||
-rw-r--r-- | net/base/host_resolver_impl.h | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h index e4bf847..d798688 100644 --- a/net/base/host_resolver.h +++ b/net/base/host_resolver.h @@ -32,7 +32,7 @@ class NetworkChangeNotifier; // request at a time is to create a SingleRequestHostResolver wrapper around // HostResolver (which will automatically cancel the single request when it // goes out of scope). -class HostResolver : public base::RefCountedThreadSafe<HostResolver> { +class HostResolver : public base::RefCounted<HostResolver> { public: // The parameters for doing a Resolve(). |hostname| and |port| are required, // the rest are optional (and have reasonable defaults). @@ -179,7 +179,7 @@ class HostResolver : public base::RefCountedThreadSafe<HostResolver> { virtual HostResolverImpl* GetAsHostResolverImpl() { return NULL; } protected: - friend class base::RefCountedThreadSafe<HostResolver>; + friend class base::RefCounted<HostResolver>; HostResolver() { } diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc index 1f89af4..f3bc5c1 100644 --- a/net/base/host_resolver_impl.cc +++ b/net/base/host_resolver_impl.cc @@ -755,6 +755,8 @@ int HostResolverImpl::Resolve(const RequestInfo& info, CompletionCallback* callback, RequestHandle* out_req, const BoundNetLog& net_log) { + DCHECK(CalledOnValidThread()); + if (shutdown_) return ERR_UNEXPECTED; @@ -840,6 +842,7 @@ int HostResolverImpl::Resolve(const RequestInfo& info, // See OnJobComplete(Job*) for why it is important not to clean out // cancelled requests from Job::requests_. void HostResolverImpl::CancelRequest(RequestHandle req_handle) { + DCHECK(CalledOnValidThread()); if (shutdown_) { // TODO(eroman): temp hack for: http://crbug.com/18373 // Because we destroy outstanding requests during Shutdown(), @@ -869,10 +872,12 @@ void HostResolverImpl::CancelRequest(RequestHandle req_handle) { } void HostResolverImpl::AddObserver(HostResolver::Observer* observer) { + DCHECK(CalledOnValidThread()); observers_.push_back(observer); } void HostResolverImpl::RemoveObserver(HostResolver::Observer* observer) { + DCHECK(CalledOnValidThread()); ObserversList::iterator it = std::find(observers_.begin(), observers_.end(), observer); @@ -883,18 +888,21 @@ void HostResolverImpl::RemoveObserver(HostResolver::Observer* observer) { } void HostResolverImpl::SetDefaultAddressFamily(AddressFamily address_family) { + DCHECK(CalledOnValidThread()); ipv6_probe_monitoring_ = false; DiscardIPv6ProbeJob(); default_address_family_ = address_family; } void HostResolverImpl::ProbeIPv6Support() { + DCHECK(CalledOnValidThread()); DCHECK(!ipv6_probe_monitoring_); ipv6_probe_monitoring_ = true; OnIPAddressChanged(); // Give initial setup call. } void HostResolverImpl::Shutdown() { + DCHECK(CalledOnValidThread()); shutdown_ = true; // Cancel the outstanding jobs. @@ -907,6 +915,7 @@ void HostResolverImpl::Shutdown() { void HostResolverImpl::SetPoolConstraints(JobPoolIndex pool_index, size_t max_outstanding_jobs, size_t max_pending_requests) { + DCHECK(CalledOnValidThread()); CHECK_GE(pool_index, 0); CHECK_LT(pool_index, POOL_COUNT); CHECK(jobs_.empty()) << "Can only set constraints during setup"; diff --git a/net/base/host_resolver_impl.h b/net/base/host_resolver_impl.h index 417cc77..a0e34ca 100644 --- a/net/base/host_resolver_impl.h +++ b/net/base/host_resolver_impl.h @@ -8,6 +8,7 @@ #include <string> #include <vector> +#include "base/non_thread_safe.h" #include "base/scoped_ptr.h" #include "net/base/capturing_net_log.h" #include "net/base/host_cache.h" @@ -49,6 +50,7 @@ namespace net { // Requests are ordered in the queue based on their priority. class HostResolverImpl : public HostResolver, + public NonThreadSafe, public NetworkChangeNotifier::Observer { public: // The index into |job_pools_| for the various job pools. Pools with a higher |