| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_DNS_ASYNC_HOST_RESOLVER_H_ | 5 #ifndef NET_DNS_ASYNC_HOST_RESOLVER_H_ |
| 6 #define NET_DNS_ASYNC_HOST_RESOLVER_H_ | 6 #define NET_DNS_ASYNC_HOST_RESOLVER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "base/observer_list.h" | |
| 13 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 14 #include "net/base/address_family.h" | 13 #include "net/base/address_family.h" |
| 15 #include "net/base/host_cache.h" | 14 #include "net/base/host_cache.h" |
| 16 #include "net/base/host_resolver.h" | 15 #include "net/base/host_resolver.h" |
| 17 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
| 18 #include "net/base/net_log.h" | 17 #include "net/base/net_log.h" |
| 19 #include "net/base/rand_callback.h" | 18 #include "net/base/rand_callback.h" |
| 20 #include "net/dns/dns_transaction.h" | 19 #include "net/dns/dns_transaction.h" |
| 21 | 20 |
| 22 namespace net { | 21 namespace net { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 40 // HostResolver interface | 39 // HostResolver interface |
| 41 virtual int Resolve(const RequestInfo& info, | 40 virtual int Resolve(const RequestInfo& info, |
| 42 AddressList* addresses, | 41 AddressList* addresses, |
| 43 OldCompletionCallback* callback, | 42 OldCompletionCallback* callback, |
| 44 RequestHandle* out_req, | 43 RequestHandle* out_req, |
| 45 const BoundNetLog& source_net_log) OVERRIDE; | 44 const BoundNetLog& source_net_log) OVERRIDE; |
| 46 virtual int ResolveFromCache(const RequestInfo& info, | 45 virtual int ResolveFromCache(const RequestInfo& info, |
| 47 AddressList* addresses, | 46 AddressList* addresses, |
| 48 const BoundNetLog& source_net_log) OVERRIDE; | 47 const BoundNetLog& source_net_log) OVERRIDE; |
| 49 virtual void CancelRequest(RequestHandle req_handle) OVERRIDE; | 48 virtual void CancelRequest(RequestHandle req_handle) OVERRIDE; |
| 50 virtual void AddObserver(HostResolver::Observer* observer) OVERRIDE; | |
| 51 virtual void RemoveObserver(HostResolver::Observer* observer) OVERRIDE; | |
| 52 virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE; | 49 virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE; |
| 53 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; | 50 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; |
| 54 virtual HostCache* GetHostCache() OVERRIDE; | 51 virtual HostCache* GetHostCache() OVERRIDE; |
| 55 | 52 |
| 56 // DnsTransaction::Delegate interface | 53 // DnsTransaction::Delegate interface |
| 57 virtual void OnTransactionComplete( | 54 virtual void OnTransactionComplete( |
| 58 int result, | 55 int result, |
| 59 const DnsTransaction* transaction, | 56 const DnsTransaction* transaction, |
| 60 const IPAddressList& ip_addresses) OVERRIDE; | 57 const IPAddressList& ip_addresses) OVERRIDE; |
| 61 | 58 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // Callback to be passed to DnsTransaction for generating DNS query ids. | 135 // Callback to be passed to DnsTransaction for generating DNS query ids. |
| 139 RandIntCallback rand_int_cb_; | 136 RandIntCallback rand_int_cb_; |
| 140 | 137 |
| 141 // Cache of host resolution results. | 138 // Cache of host resolution results. |
| 142 scoped_ptr<HostCache> cache_; | 139 scoped_ptr<HostCache> cache_; |
| 143 | 140 |
| 144 // Also passed to DnsTransaction; it's a dependency injection to aid | 141 // Also passed to DnsTransaction; it's a dependency injection to aid |
| 145 // testing, outside of unit tests, its value is always NULL. | 142 // testing, outside of unit tests, its value is always NULL. |
| 146 ClientSocketFactory* factory_; | 143 ClientSocketFactory* factory_; |
| 147 | 144 |
| 148 // The observers to notify when a request starts/ends. | 145 // Monotonically increasing ID number to assign to the next request. |
| 149 ObserverList<HostResolver::Observer> observers_; | |
| 150 | |
| 151 // Monotonically increasing ID number to assign to the next request. | |
| 152 // Observers are the only consumers of this ID number. | 146 // Observers are the only consumers of this ID number. |
| 153 int next_request_id_; | 147 int next_request_id_; |
| 154 | 148 |
| 155 NetLog* net_log_; | 149 NetLog* net_log_; |
| 156 | 150 |
| 157 DISALLOW_COPY_AND_ASSIGN(AsyncHostResolver); | 151 DISALLOW_COPY_AND_ASSIGN(AsyncHostResolver); |
| 158 }; | 152 }; |
| 159 | 153 |
| 160 } // namespace net | 154 } // namespace net |
| 161 | 155 |
| 162 #endif // NET_DNS_ASYNC_HOST_RESOLVER_H_ | 156 #endif // NET_DNS_ASYNC_HOST_RESOLVER_H_ |
| OLD | NEW |