| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/host_resolver_impl.h" | 5 #include "net/base/host_resolver_impl.h" |
| 6 #include "net/base/net_log.h" | 6 #include "net/base/net_log.h" |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <deque> | 9 #include <deque> |
| 10 | 10 |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 class HostResolverImpl::IPv6ProbeJob | 428 class HostResolverImpl::IPv6ProbeJob |
| 429 : public base::RefCountedThreadSafe<HostResolverImpl::IPv6ProbeJob> { | 429 : public base::RefCountedThreadSafe<HostResolverImpl::IPv6ProbeJob> { |
| 430 public: | 430 public: |
| 431 explicit IPv6ProbeJob(HostResolverImpl* resolver) | 431 explicit IPv6ProbeJob(HostResolverImpl* resolver) |
| 432 : resolver_(resolver), | 432 : resolver_(resolver), |
| 433 origin_loop_(MessageLoop::current()) { | 433 origin_loop_(MessageLoop::current()) { |
| 434 } | 434 } |
| 435 | 435 |
| 436 void Start() { | 436 void Start() { |
| 437 DCHECK(IsOnOriginThread()); | 437 DCHECK(IsOnOriginThread()); |
| 438 const bool IS_SLOW = true; | 438 const bool kIsSlow = true; |
| 439 WorkerPool::PostTask( | 439 WorkerPool::PostTask( |
| 440 FROM_HERE, NewRunnableMethod(this, &IPv6ProbeJob::DoProbe), IS_SLOW); | 440 FROM_HERE, NewRunnableMethod(this, &IPv6ProbeJob::DoProbe), kIsSlow); |
| 441 } | 441 } |
| 442 | 442 |
| 443 // Cancels the current job. | 443 // Cancels the current job. |
| 444 void Cancel() { | 444 void Cancel() { |
| 445 DCHECK(IsOnOriginThread()); | 445 DCHECK(IsOnOriginThread()); |
| 446 resolver_ = NULL; // Read/write ONLY on origin thread. | 446 resolver_ = NULL; // Read/write ONLY on origin thread. |
| 447 { | 447 { |
| 448 AutoLock locked(origin_loop_lock_); | 448 AutoLock locked(origin_loop_lock_); |
| 449 // Origin loop may be destroyed before we can use it! | 449 // Origin loop may be destroyed before we can use it! |
| 450 origin_loop_ = NULL; | 450 origin_loop_ = NULL; |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 if (ipv6_probe_job_.get()) { | 1088 if (ipv6_probe_job_.get()) { |
| 1089 ipv6_probe_job_->Cancel(); | 1089 ipv6_probe_job_->Cancel(); |
| 1090 ipv6_probe_job_ = NULL; | 1090 ipv6_probe_job_ = NULL; |
| 1091 } | 1091 } |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 void HostResolverImpl::IPv6ProbeSetDefaultAddressFamily( | 1094 void HostResolverImpl::IPv6ProbeSetDefaultAddressFamily( |
| 1095 AddressFamily address_family) { | 1095 AddressFamily address_family) { |
| 1096 DCHECK(address_family == ADDRESS_FAMILY_UNSPECIFIED || | 1096 DCHECK(address_family == ADDRESS_FAMILY_UNSPECIFIED || |
| 1097 address_family == ADDRESS_FAMILY_IPV4); | 1097 address_family == ADDRESS_FAMILY_IPV4); |
| 1098 if (default_address_family_ != address_family) | 1098 if (default_address_family_ != address_family) { |
| 1099 LOG(INFO) << "IPv6Probe forced AddressFamily setting to " | 1099 LOG(INFO) << "IPv6Probe forced AddressFamily setting to " |
| 1100 << ((address_family == ADDRESS_FAMILY_UNSPECIFIED) | 1100 << ((address_family == ADDRESS_FAMILY_UNSPECIFIED) |
| 1101 ? "ADDRESS_FAMILY_UNSPECIFIED" | 1101 ? "ADDRESS_FAMILY_UNSPECIFIED" |
| 1102 : "ADDRESS_FAMILY_IPV4"); | 1102 : "ADDRESS_FAMILY_IPV4"); |
| 1103 } |
| 1103 default_address_family_ = address_family; | 1104 default_address_family_ = address_family; |
| 1104 // Drop reference since the job has called us back. | 1105 // Drop reference since the job has called us back. |
| 1105 DiscardIPv6ProbeJob(); | 1106 DiscardIPv6ProbeJob(); |
| 1106 } | 1107 } |
| 1107 | 1108 |
| 1108 // static | 1109 // static |
| 1109 HostResolverImpl::JobPoolIndex HostResolverImpl::GetJobPoolIndexForRequest( | 1110 HostResolverImpl::JobPoolIndex HostResolverImpl::GetJobPoolIndexForRequest( |
| 1110 const Request* req) { | 1111 const Request* req) { |
| 1111 return POOL_NORMAL; | 1112 return POOL_NORMAL; |
| 1112 } | 1113 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 if (r == req) | 1184 if (r == req) |
| 1184 return error; | 1185 return error; |
| 1185 | 1186 |
| 1186 r->OnComplete(error, AddressList()); | 1187 r->OnComplete(error, AddressList()); |
| 1187 } | 1188 } |
| 1188 | 1189 |
| 1189 return ERR_IO_PENDING; | 1190 return ERR_IO_PENDING; |
| 1190 } | 1191 } |
| 1191 | 1192 |
| 1192 } // namespace net | 1193 } // namespace net |
| OLD | NEW |