| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/dns/host_resolver.h" | 5 #include "net/dns/host_resolver.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 HostCache* HostResolver::GetHostCache() { | 110 HostCache* HostResolver::GetHostCache() { |
| 111 return NULL; | 111 return NULL; |
| 112 } | 112 } |
| 113 | 113 |
| 114 base::Value* HostResolver::GetDnsConfigAsValue() const { | 114 base::Value* HostResolver::GetDnsConfigAsValue() const { |
| 115 return NULL; | 115 return NULL; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void HostResolver::SetMyIpAddresses(const std::string& ipv4_address, |
| 119 const std::string& ipv6_address) { |
| 120 my_ipv4_address_ = ipv4_address; |
| 121 my_ipv6_address_ = ipv6_address; |
| 122 } |
| 123 |
| 124 bool HostResolver::ResolveFromMyIpAddress(bool include_ipv6, |
| 125 AddressList* addresses) const { |
| 126 addresses->clear(); |
| 127 if (include_ipv6 && !my_ipv6_address_.empty()) { |
| 128 IPAddressNumber ipv6; |
| 129 if (ParseIPLiteralToNumber(my_ipv6_address_, &ipv6)) |
| 130 addresses->push_back(IPEndPoint(ipv6, 0)); |
| 131 } |
| 132 if (!my_ipv4_address_.empty()) { |
| 133 IPAddressNumber ipv4; |
| 134 if (ParseIPLiteralToNumber(my_ipv4_address_, &ipv4)) |
| 135 addresses->push_back(IPEndPoint(ipv4, 0)); |
| 136 } |
| 137 if (addresses->empty()) |
| 138 return false; |
| 139 addresses->SetDefaultCanonicalName(); |
| 140 return true; |
| 141 } |
| 142 |
| 118 // static | 143 // static |
| 119 scoped_ptr<HostResolver> | 144 scoped_ptr<HostResolver> |
| 120 HostResolver::CreateSystemResolver(const Options& options, NetLog* net_log) { | 145 HostResolver::CreateSystemResolver(const Options& options, NetLog* net_log) { |
| 121 scoped_ptr<HostCache> cache; | 146 scoped_ptr<HostCache> cache; |
| 122 if (options.enable_caching) | 147 if (options.enable_caching) |
| 123 cache = HostCache::CreateDefaultCache(); | 148 cache = HostCache::CreateDefaultCache(); |
| 124 return scoped_ptr<HostResolver>(new HostResolverImpl( | 149 return scoped_ptr<HostResolver>(new HostResolverImpl( |
| 125 cache.Pass(), | 150 cache.Pass(), |
| 126 GetDispatcherLimits(options), | 151 GetDispatcherLimits(options), |
| 127 HostResolverImpl::ProcTaskParams(NULL, options.max_retry_attempts), | 152 HostResolverImpl::ProcTaskParams(NULL, options.max_retry_attempts), |
| 128 net_log)); | 153 net_log)); |
| 129 } | 154 } |
| 130 | 155 |
| 131 // static | 156 // static |
| 132 scoped_ptr<HostResolver> | 157 scoped_ptr<HostResolver> |
| 133 HostResolver::CreateDefaultResolver(NetLog* net_log) { | 158 HostResolver::CreateDefaultResolver(NetLog* net_log) { |
| 134 return CreateSystemResolver(Options(), net_log); | 159 return CreateSystemResolver(Options(), net_log); |
| 135 } | 160 } |
| 136 | 161 |
| 137 HostResolver::HostResolver() { | 162 HostResolver::HostResolver() { |
| 138 } | 163 } |
| 139 | 164 |
| 140 } // namespace net | 165 } // namespace net |
| OLD | NEW |