| 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 #ifndef NET_BASE_DNSRR_RESOLVER_H_ | 5 #ifndef NET_BASE_DNSRR_RESOLVER_H_ |
| 6 #define NET_BASE_DNSRR_RESOLVER_H_ | 6 #define NET_BASE_DNSRR_RESOLVER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // confused with HostResolver and should not be used to resolve A/AAAA records. | 60 // confused with HostResolver and should not be used to resolve A/AAAA records. |
| 61 // | 61 // |
| 62 // HostResolver exists to lookup addresses and there are many details about | 62 // HostResolver exists to lookup addresses and there are many details about |
| 63 // address resolution over and above DNS (i.e. Bonjour, VPNs etc). | 63 // address resolution over and above DNS (i.e. Bonjour, VPNs etc). |
| 64 // | 64 // |
| 65 // DnsRRResolver should only be used when the data is specifically DNS data and | 65 // DnsRRResolver should only be used when the data is specifically DNS data and |
| 66 // the name is a fully qualified DNS domain. | 66 // the name is a fully qualified DNS domain. |
| 67 // | 67 // |
| 68 // A DnsRRResolver must be used from the MessageLoop which created it. | 68 // A DnsRRResolver must be used from the MessageLoop which created it. |
| 69 class DnsRRResolver : public base::NonThreadSafe, | 69 class DnsRRResolver : public base::NonThreadSafe, |
| 70 public NetworkChangeNotifier::Observer { | 70 public NetworkChangeNotifier::IPAddressObserver { |
| 71 public: | 71 public: |
| 72 typedef intptr_t Handle; | 72 typedef intptr_t Handle; |
| 73 | 73 |
| 74 enum { | 74 enum { |
| 75 kInvalidHandle = 0, | 75 kInvalidHandle = 0, |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 enum { | 78 enum { |
| 79 // Try harder to get a DNSSEC signed response. This doesn't mean that the | 79 // Try harder to get a DNSSEC signed response. This doesn't mean that the |
| 80 // RRResponse will always have the dnssec bit set. | 80 // RRResponse will always have the dnssec bit set. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 98 // immediately because it was improperly formed. | 98 // immediately because it was improperly formed. |
| 99 Handle Resolve(const std::string& name, uint16 rrtype, | 99 Handle Resolve(const std::string& name, uint16 rrtype, |
| 100 uint16 flags, CompletionCallback* callback, | 100 uint16 flags, CompletionCallback* callback, |
| 101 RRResponse* response, int priority, | 101 RRResponse* response, int priority, |
| 102 const BoundNetLog& netlog); | 102 const BoundNetLog& netlog); |
| 103 | 103 |
| 104 // CancelResolve cancels an inflight lookup. The callback for this lookup | 104 // CancelResolve cancels an inflight lookup. The callback for this lookup |
| 105 // must not have already been called. | 105 // must not have already been called. |
| 106 void CancelResolve(Handle handle); | 106 void CancelResolve(Handle handle); |
| 107 | 107 |
| 108 // Implementation of NetworkChangeNotifier::Observer | 108 // Implementation of NetworkChangeNotifier::IPAddressObserver |
| 109 virtual void OnIPAddressChanged(); | 109 virtual void OnIPAddressChanged(); |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 friend class RRResolverWorker; | 112 friend class RRResolverWorker; |
| 113 | 113 |
| 114 void HandleResult(const std::string& name, uint16 rrtype, int result, | 114 void HandleResult(const std::string& name, uint16 rrtype, int result, |
| 115 const RRResponse& response); | 115 const RRResponse& response); |
| 116 | 116 |
| 117 // cache_ maps from a request to a cached response. The cached answer may | 117 // cache_ maps from a request to a cached response. The cached answer may |
| 118 // have expired and the size of |cache_| must be <= kMaxCacheEntries. | 118 // have expired and the size of |cache_| must be <= kMaxCacheEntries. |
| 119 // < name , rrtype> | 119 // < name , rrtype> |
| 120 std::map<std::pair<std::string, uint16>, RRResponse> cache_; | 120 std::map<std::pair<std::string, uint16>, RRResponse> cache_; |
| 121 // inflight_ maps from a request to an active resolution which is taking | 121 // inflight_ maps from a request to an active resolution which is taking |
| 122 // place. | 122 // place. |
| 123 std::map<std::pair<std::string, uint16>, RRResolverJob*> inflight_; | 123 std::map<std::pair<std::string, uint16>, RRResolverJob*> inflight_; |
| 124 | 124 |
| 125 uint64 requests_; | 125 uint64 requests_; |
| 126 uint64 cache_hits_; | 126 uint64 cache_hits_; |
| 127 uint64 inflight_joins_; | 127 uint64 inflight_joins_; |
| 128 | 128 |
| 129 bool in_destructor_; | 129 bool in_destructor_; |
| 130 | 130 |
| 131 DISALLOW_COPY_AND_ASSIGN(DnsRRResolver); | 131 DISALLOW_COPY_AND_ASSIGN(DnsRRResolver); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 } // namespace net | 134 } // namespace net |
| 135 | 135 |
| 136 #endif // NET_BASE_DNSRR_RESOLVER_H_ | 136 #endif // NET_BASE_DNSRR_RESOLVER_H_ |
| OLD | NEW |