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 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <ws2tcpip.h> | 8 #include <ws2tcpip.h> |
9 #include <wspiapi.h> // Needed for Win2k compat. | 9 #include <wspiapi.h> // Needed for Win2k compat. |
10 #elif defined(OS_POSIX) | 10 #elif defined(OS_POSIX) |
11 #include <netdb.h> | 11 #include <netdb.h> |
12 #include <sys/socket.h> | 12 #include <sys/socket.h> |
13 #endif | 13 #endif |
14 #if defined(OS_LINUX) | 14 #if defined(OS_LINUX) |
15 #include <resolv.h> | 15 #include <resolv.h> |
16 #endif | 16 #endif |
17 | 17 |
18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 19 #include "base/debug_util.h" |
19 #include "base/message_loop.h" | 20 #include "base/message_loop.h" |
20 #include "base/stl_util-inl.h" | 21 #include "base/stl_util-inl.h" |
21 #include "base/string_util.h" | 22 #include "base/string_util.h" |
22 #include "base/time.h" | 23 #include "base/time.h" |
23 #include "base/worker_pool.h" | 24 #include "base/worker_pool.h" |
24 #include "net/base/address_list.h" | 25 #include "net/base/address_list.h" |
25 #include "net/base/host_resolver_proc.h" | 26 #include "net/base/host_resolver_proc.h" |
26 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
27 | 28 |
28 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 job->Start(); | 361 job->Start(); |
361 } | 362 } |
362 | 363 |
363 // Completion happens during OnJobComplete(Job*). | 364 // Completion happens during OnJobComplete(Job*). |
364 return ERR_IO_PENDING; | 365 return ERR_IO_PENDING; |
365 } | 366 } |
366 | 367 |
367 // See OnJobComplete(Job*) for why it is important not to clean out | 368 // See OnJobComplete(Job*) for why it is important not to clean out |
368 // cancelled requests from Job::requests_. | 369 // cancelled requests from Job::requests_. |
369 void HostResolverImpl::CancelRequest(RequestHandle req_handle) { | 370 void HostResolverImpl::CancelRequest(RequestHandle req_handle) { |
| 371 if (shutdown_) { |
| 372 // TODO(eroman): temp hack for: http://crbug.com/16972. |
| 373 // Because we destroy outstanding requests during Shutdown() as part of |
| 374 // hack http://crbug.com/15513, |req_handle| is already cancelled. |
| 375 LOG(ERROR) << "Called HostResolverImpl::CancelRequest() after Shutdown()."; |
| 376 StackTrace().PrintBacktrace(); |
| 377 return; |
| 378 } |
370 Request* req = reinterpret_cast<Request*>(req_handle); | 379 Request* req = reinterpret_cast<Request*>(req_handle); |
371 DCHECK(req); | 380 DCHECK(req); |
372 DCHECK(req->job()); | 381 DCHECK(req->job()); |
373 // NULL out the fields of req, to mark it as cancelled. | 382 // NULL out the fields of req, to mark it as cancelled. |
374 req->MarkAsCancelled(); | 383 req->MarkAsCancelled(); |
375 NotifyObserversCancelRequest(req->id(), req->info()); | 384 NotifyObserversCancelRequest(req->id(), req->info()); |
376 } | 385 } |
377 | 386 |
378 void HostResolverImpl::AddObserver(Observer* observer) { | 387 void HostResolverImpl::AddObserver(Observer* observer) { |
379 observers_.push_back(observer); | 388 observers_.push_back(observer); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 | 483 |
475 void HostResolverImpl::NotifyObserversCancelRequest(int request_id, | 484 void HostResolverImpl::NotifyObserversCancelRequest(int request_id, |
476 const RequestInfo& info) { | 485 const RequestInfo& info) { |
477 for (ObserversList::iterator it = observers_.begin(); | 486 for (ObserversList::iterator it = observers_.begin(); |
478 it != observers_.end(); ++it) { | 487 it != observers_.end(); ++it) { |
479 (*it)->OnCancelResolution(request_id, info); | 488 (*it)->OnCancelResolution(request_id, info); |
480 } | 489 } |
481 } | 490 } |
482 | 491 |
483 } // namespace net | 492 } // namespace net |
OLD | NEW |