| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 std::string FormatAddrinfoDetails(const struct addrinfo& ai, | 128 std::string FormatAddrinfoDetails(const struct addrinfo& ai, |
| 129 const char* indent) { | 129 const char* indent) { |
| 130 std::string ai_flags = FormatAddrinfoFlags(ai.ai_flags); | 130 std::string ai_flags = FormatAddrinfoFlags(ai.ai_flags); |
| 131 const char* ai_family = FormatAddrinfoFamily(ai.ai_family); | 131 const char* ai_family = FormatAddrinfoFamily(ai.ai_family); |
| 132 const char* ai_socktype = FormatAddrinfoSocktype(ai.ai_socktype); | 132 const char* ai_socktype = FormatAddrinfoSocktype(ai.ai_socktype); |
| 133 const char* ai_protocol = FormatAddrinfoProtocol(ai.ai_protocol); | 133 const char* ai_protocol = FormatAddrinfoProtocol(ai.ai_protocol); |
| 134 std::string ai_addr = net::NetAddressToString(&ai); | 134 std::string ai_addr = net::NetAddressToString(&ai); |
| 135 std::string ai_canonname; | 135 std::string ai_canonname; |
| 136 if (ai.ai_canonname) { | 136 if (ai.ai_canonname) { |
| 137 ai_canonname = StringPrintf("%s ai_canonname: %s\n", | 137 ai_canonname = base::StringPrintf("%s ai_canonname: %s\n", |
| 138 indent, | 138 indent, |
| 139 ai.ai_canonname); | 139 ai.ai_canonname); |
| 140 } | 140 } |
| 141 return StringPrintf("%saddrinfo {\n" | 141 return base::StringPrintf("%saddrinfo {\n" |
| 142 "%s ai_flags: %s\n" | 142 "%s ai_flags: %s\n" |
| 143 "%s ai_family: %s\n" | 143 "%s ai_family: %s\n" |
| 144 "%s ai_socktype: %s\n" | 144 "%s ai_socktype: %s\n" |
| 145 "%s ai_protocol: %s\n" | 145 "%s ai_protocol: %s\n" |
| 146 "%s ai_addrlen: %d\n" | 146 "%s ai_addrlen: %d\n" |
| 147 "%s ai_addr: %s\n" | 147 "%s ai_addr: %s\n" |
| 148 "%s" | 148 "%s" |
| 149 "%s}\n", | 149 "%s}\n", |
| 150 indent, | 150 indent, |
| 151 indent, ai_flags.c_str(), | 151 indent, ai_flags.c_str(), |
| 152 indent, ai_family, | 152 indent, ai_family, |
| 153 indent, ai_socktype, | 153 indent, ai_socktype, |
| 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 StringAppendF(&ret_string, "AddressList {\n"); |
| 165 StringAppendF(&ret_string, " Host: %s\n", host.c_str()); | 165 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) { |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 base::TimeDelta::FromSeconds(0)); | 452 base::TimeDelta::FromSeconds(0)); |
| 453 | 453 |
| 454 scoped_refptr<net::HostResolver> host_resolver( | 454 scoped_refptr<net::HostResolver> host_resolver( |
| 455 new net::HostResolverImpl(NULL, cache, 100u, NULL)); | 455 new net::HostResolverImpl(NULL, cache, 100u, NULL)); |
| 456 ResolverInvoker invoker(host_resolver.get()); | 456 ResolverInvoker invoker(host_resolver.get()); |
| 457 invoker.ResolveAll(hosts_and_times, options.async); | 457 invoker.ResolveAll(hosts_and_times, options.async); |
| 458 | 458 |
| 459 CommandLine::Reset(); | 459 CommandLine::Reset(); |
| 460 return 0; | 460 return 0; |
| 461 } | 461 } |
| OLD | NEW |