| 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 // hrseolv is a command line utility which runs the HostResolver in the | 5 // hrseolv is a command line utility which runs the HostResolver in the |
| 6 // Chromium network stack. | 6 // Chromium network stack. |
| 7 // | 7 // |
| 8 // The user specifies the hosts to lookup and when to look them up. | 8 // The user specifies the hosts to lookup and when to look them up. |
| 9 // The hosts must be specified in order. | 9 // The hosts must be specified in order. |
| 10 // The hosts can be contained in a file or on the command line. If no | 10 // The hosts can be contained in a file or on the command line. If no |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 if (!flag_names.empty()) { | 66 if (!flag_names.empty()) { |
| 67 flag_names += "|"; | 67 flag_names += "|"; |
| 68 } | 68 } |
| 69 flag_names += flag_name.name; | 69 flag_names += flag_name.name; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 if (ai_flags) { | 72 if (ai_flags) { |
| 73 if (!flag_names.empty()) { | 73 if (!flag_names.empty()) { |
| 74 flag_names += "|"; | 74 flag_names += "|"; |
| 75 } | 75 } |
| 76 StringAppendF(&flag_names, "0x%x", ai_flags); | 76 base::StringAppendF(&flag_names, "0x%x", ai_flags); |
| 77 } | 77 } |
| 78 return flag_names; | 78 return flag_names; |
| 79 } | 79 } |
| 80 | 80 |
| 81 const char* GetNameOfFlag(const FlagName* flag_names, | 81 const char* GetNameOfFlag(const FlagName* flag_names, |
| 82 unsigned int num_flag_names, | 82 unsigned int num_flag_names, |
| 83 int flag) { | 83 int flag) { |
| 84 for (unsigned int i = 0; i < num_flag_names; ++i) { | 84 for (unsigned int i = 0; i < num_flag_names; ++i) { |
| 85 const FlagName& flag_name = flag_names[i]; | 85 const FlagName& flag_name = flag_names[i]; |
| 86 if (flag_name.flag == flag) { | 86 if (flag_name.flag == flag) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 indent, ai_protocol, | 154 indent, ai_protocol, |
| 155 indent, ai.ai_addrlen, | 155 indent, ai.ai_addrlen, |
| 156 indent, ai_addr.c_str(), | 156 indent, ai_addr.c_str(), |
| 157 ai_canonname.c_str(), | 157 ai_canonname.c_str(), |
| 158 indent); | 158 indent); |
| 159 } | 159 } |
| 160 | 160 |
| 161 std::string FormatAddressList(const net::AddressList& address_list, | 161 std::string FormatAddressList(const net::AddressList& address_list, |
| 162 const std::string& host) { | 162 const std::string& host) { |
| 163 std::string ret_string; | 163 std::string ret_string; |
| 164 StringAppendF(&ret_string, "AddressList {\n"); | 164 base::StringAppendF(&ret_string, "AddressList {\n"); |
| 165 StringAppendF(&ret_string, " Host: %s\n", host.c_str()); | 165 base::StringAppendF(&ret_string, " Host: %s\n", host.c_str()); |
| 166 for (const struct addrinfo* it = address_list.head(); | 166 for (const struct addrinfo* it = address_list.head(); |
| 167 it != NULL; | 167 it != NULL; |
| 168 it = it->ai_next) { | 168 it = it->ai_next) { |
| 169 StringAppendF(&ret_string, "%s", FormatAddrinfoDetails(*it, " ").c_str()); | 169 base::StringAppendF(&ret_string, "%s", |
| 170 FormatAddrinfoDetails(*it, " ").c_str()); |
| 170 } | 171 } |
| 171 StringAppendF(&ret_string, "}\n"); | 172 base::StringAppendF(&ret_string, "}\n"); |
| 172 return ret_string; | 173 return ret_string; |
| 173 } | 174 } |
| 174 | 175 |
| 175 class ResolverInvoker; | 176 class ResolverInvoker; |
| 176 | 177 |
| 177 // DelayedResolve contains state for a DNS resolution to be performed later. | 178 // DelayedResolve contains state for a DNS resolution to be performed later. |
| 178 class DelayedResolve : public base::RefCounted<DelayedResolve> { | 179 class DelayedResolve : public base::RefCounted<DelayedResolve> { |
| 179 public: | 180 public: |
| 180 DelayedResolve(const std::string& host, bool is_async, | 181 DelayedResolve(const std::string& host, bool is_async, |
| 181 net::HostResolver* resolver, | 182 net::HostResolver* resolver, |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 base::TimeDelta::FromMilliseconds(options.cache_ttl), | 452 base::TimeDelta::FromMilliseconds(options.cache_ttl), |
| 452 base::TimeDelta::FromSeconds(0)); | 453 base::TimeDelta::FromSeconds(0)); |
| 453 | 454 |
| 454 net::HostResolverImpl host_resolver(NULL, cache, 100u, NULL); | 455 net::HostResolverImpl host_resolver(NULL, cache, 100u, NULL); |
| 455 ResolverInvoker invoker(&host_resolver); | 456 ResolverInvoker invoker(&host_resolver); |
| 456 invoker.ResolveAll(hosts_and_times, options.async); | 457 invoker.ResolveAll(hosts_and_times, options.async); |
| 457 | 458 |
| 458 CommandLine::Reset(); | 459 CommandLine::Reset(); |
| 459 return 0; | 460 return 0; |
| 460 } | 461 } |
| OLD | NEW |