| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <Winsock2.h> | 8 #include <Winsock2.h> |
| 9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
| 10 #include <netdb.h> | 10 #include <netdb.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include <cmath> | 13 #include <cmath> |
| 14 #include <deque> | 14 #include <deque> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 19 #include "base/debug_util.h" | 19 #include "base/debug/debugger.h" |
| 20 #include "base/debug/stack_trace.h" |
| 20 #include "base/lock.h" | 21 #include "base/lock.h" |
| 21 #include "base/message_loop.h" | 22 #include "base/message_loop.h" |
| 22 #include "base/metrics/field_trial.h" | 23 #include "base/metrics/field_trial.h" |
| 23 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
| 24 #include "base/stl_util-inl.h" | 25 #include "base/stl_util-inl.h" |
| 25 #include "base/string_util.h" | 26 #include "base/string_util.h" |
| 26 #include "base/time.h" | 27 #include "base/time.h" |
| 27 #include "base/utf_string_conversions.h" | 28 #include "base/utf_string_conversions.h" |
| 28 #include "base/values.h" | 29 #include "base/values.h" |
| 29 #include "base/worker_pool.h" | 30 #include "base/worker_pool.h" |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 | 1047 |
| 1047 // See OnJobComplete(Job*) for why it is important not to clean out | 1048 // See OnJobComplete(Job*) for why it is important not to clean out |
| 1048 // cancelled requests from Job::requests_. | 1049 // cancelled requests from Job::requests_. |
| 1049 void HostResolverImpl::CancelRequest(RequestHandle req_handle) { | 1050 void HostResolverImpl::CancelRequest(RequestHandle req_handle) { |
| 1050 DCHECK(CalledOnValidThread()); | 1051 DCHECK(CalledOnValidThread()); |
| 1051 if (shutdown_) { | 1052 if (shutdown_) { |
| 1052 // TODO(eroman): temp hack for: http://crbug.com/18373 | 1053 // TODO(eroman): temp hack for: http://crbug.com/18373 |
| 1053 // Because we destroy outstanding requests during Shutdown(), | 1054 // Because we destroy outstanding requests during Shutdown(), |
| 1054 // |req_handle| is already cancelled. | 1055 // |req_handle| is already cancelled. |
| 1055 LOG(ERROR) << "Called HostResolverImpl::CancelRequest() after Shutdown()."; | 1056 LOG(ERROR) << "Called HostResolverImpl::CancelRequest() after Shutdown()."; |
| 1056 StackTrace().PrintBacktrace(); | 1057 base::debug::StackTrace().PrintBacktrace(); |
| 1057 return; | 1058 return; |
| 1058 } | 1059 } |
| 1059 Request* req = reinterpret_cast<Request*>(req_handle); | 1060 Request* req = reinterpret_cast<Request*>(req_handle); |
| 1060 DCHECK(req); | 1061 DCHECK(req); |
| 1061 | 1062 |
| 1062 scoped_ptr<Request> request_deleter; // Frees at end of function. | 1063 scoped_ptr<Request> request_deleter; // Frees at end of function. |
| 1063 | 1064 |
| 1064 if (!req->job()) { | 1065 if (!req->job()) { |
| 1065 // If the request was not attached to a job yet, it must have been | 1066 // If the request was not attached to a job yet, it must have been |
| 1066 // enqueued into a pool. Remove it from that pool's queue. | 1067 // enqueued into a pool. Remove it from that pool's queue. |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 job_pools_[i]->ResetNumOutstandingJobs(); | 1429 job_pools_[i]->ResetNumOutstandingJobs(); |
| 1429 JobMap jobs; | 1430 JobMap jobs; |
| 1430 jobs.swap(jobs_); | 1431 jobs.swap(jobs_); |
| 1431 for (JobMap::iterator it = jobs.begin(); it != jobs.end(); ++it) { | 1432 for (JobMap::iterator it = jobs.begin(); it != jobs.end(); ++it) { |
| 1432 AbortJob(it->second); | 1433 AbortJob(it->second); |
| 1433 it->second->Cancel(); | 1434 it->second->Cancel(); |
| 1434 } | 1435 } |
| 1435 } | 1436 } |
| 1436 | 1437 |
| 1437 } // namespace net | 1438 } // namespace net |
| OLD | NEW |