| 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.h" | 5 #include "net/base/host_resolver.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/message_loop.h" | 19 #include "base/message_loop.h" |
| 20 #include "base/stl_util-inl.h" | 20 #include "base/stl_util-inl.h" |
| 21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
| 22 #include "base/time.h" | 22 #include "base/time.h" |
| 23 #include "base/worker_pool.h" | 23 #include "base/worker_pool.h" |
| 24 #include "net/base/address_list.h" | 24 #include "net/base/address_list.h" |
| 25 #include "net/base/dns_resolution_observer.h" | |
| 26 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 27 | 26 |
| 28 #if defined(OS_LINUX) | 27 #if defined(OS_LINUX) |
| 29 #include "base/singleton.h" | 28 #include "base/singleton.h" |
| 30 #include "base/thread_local_storage.h" | 29 #include "base/thread_local_storage.h" |
| 31 #endif | 30 #endif |
| 32 | 31 |
| 33 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 34 #include "net/base/winsock_init.h" | 33 #include "net/base/winsock_init.h" |
| 35 #endif | 34 #endif |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 474 |
| 476 // See OnJobComplete(Job*) for why it is important not to clean out | 475 // See OnJobComplete(Job*) for why it is important not to clean out |
| 477 // cancelled requests from Job::requests_. | 476 // cancelled requests from Job::requests_. |
| 478 void HostResolver::CancelRequest(Request* req) { | 477 void HostResolver::CancelRequest(Request* req) { |
| 479 DCHECK(req); | 478 DCHECK(req); |
| 480 DCHECK(req->job()); | 479 DCHECK(req->job()); |
| 481 // NULL out the fields of req, to mark it as cancelled. | 480 // NULL out the fields of req, to mark it as cancelled. |
| 482 req->Cancel(); | 481 req->Cancel(); |
| 483 } | 482 } |
| 484 | 483 |
| 485 void HostResolver::AddObserver(DnsResolutionObserver* observer) { | 484 void HostResolver::AddObserver(Observer* observer) { |
| 486 observers_.push_back(observer); | 485 observers_.push_back(observer); |
| 487 } | 486 } |
| 488 | 487 |
| 489 void HostResolver::RemoveObserver(DnsResolutionObserver* observer) { | 488 void HostResolver::RemoveObserver(Observer* observer) { |
| 490 ObserversList::iterator it = | 489 ObserversList::iterator it = |
| 491 std::find(observers_.begin(), observers_.end(), observer); | 490 std::find(observers_.begin(), observers_.end(), observer); |
| 492 | 491 |
| 493 // Observer must exist. | 492 // Observer must exist. |
| 494 DCHECK(it != observers_.end()); | 493 DCHECK(it != observers_.end()); |
| 495 | 494 |
| 496 observers_.erase(it); | 495 observers_.erase(it); |
| 497 } | 496 } |
| 498 | 497 |
| 499 void HostResolver::AddOutstandingJob(Job* job) { | 498 void HostResolver::AddOutstandingJob(Job* job) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 | 615 |
| 617 // Clear the outstanding request information. | 616 // Clear the outstanding request information. |
| 618 cur_request_ = NULL; | 617 cur_request_ = NULL; |
| 619 cur_request_callback_ = NULL; | 618 cur_request_callback_ = NULL; |
| 620 | 619 |
| 621 // Call the user's original callback. | 620 // Call the user's original callback. |
| 622 callback->Run(result); | 621 callback->Run(result); |
| 623 } | 622 } |
| 624 | 623 |
| 625 } // namespace net | 624 } // namespace net |
| OLD | NEW |