| 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/cancelable_callback.h" | 11 #include "base/cancelable_callback.h" |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 46 int port; | 47 int port; |
| 47 if (!ParseHostAndPort(ip_address_and_port, &ip, &port)) | 48 if (!ParseHostAndPort(ip_address_and_port, &ip, &port)) |
| 48 return false; | 49 return false; |
| 49 if (port == -1) | 50 if (port == -1) |
| 50 port = dns_protocol::kDefaultPort; | 51 port = dns_protocol::kDefaultPort; |
| 51 | 52 |
| 52 net::IPAddressNumber ip_number; | 53 net::IPAddressNumber ip_number; |
| 53 if (!net::ParseIPLiteralToNumber(ip, &ip_number)) | 54 if (!net::ParseIPLiteralToNumber(ip, &ip_number)) |
| 54 return false; | 55 return false; |
| 55 | 56 |
| 56 *ip_end_point = net::IPEndPoint(ip_number, port); | 57 *ip_end_point = net::IPEndPoint(ip_number, static_cast<uint16>(port)); |
| 57 return true; | 58 return true; |
| 58 } | 59 } |
| 59 | 60 |
| 60 // Convert DnsConfig to human readable text omitting the hosts member. | 61 // Convert DnsConfig to human readable text omitting the hosts member. |
| 61 std::string DnsConfigToString(const DnsConfig& dns_config) { | 62 std::string DnsConfigToString(const DnsConfig& dns_config) { |
| 62 std::string output; | 63 std::string output; |
| 63 output.append("search "); | 64 output.append("search "); |
| 64 for (size_t i = 0; i < dns_config.search.size(); ++i) { | 65 for (size_t i = 0; i < dns_config.search.size(); ++i) { |
| 65 output.append(dns_config.search[i] + " "); | 66 output.append(dns_config.search[i] + " "); |
| 66 } | 67 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 83 } | 84 } |
| 84 | 85 |
| 85 // Convert DnsConfig hosts member to a human readable text. | 86 // Convert DnsConfig hosts member to a human readable text. |
| 86 std::string DnsHostsToString(const DnsHosts& dns_hosts) { | 87 std::string DnsHostsToString(const DnsHosts& dns_hosts) { |
| 87 std::string output; | 88 std::string output; |
| 88 for (DnsHosts::const_iterator i = dns_hosts.begin(); | 89 for (DnsHosts::const_iterator i = dns_hosts.begin(); |
| 89 i != dns_hosts.end(); | 90 i != dns_hosts.end(); |
| 90 ++i) { | 91 ++i) { |
| 91 const DnsHostsKey& key = i->first; | 92 const DnsHostsKey& key = i->first; |
| 92 std::string host_name = key.first; | 93 std::string host_name = key.first; |
| 93 output.append(IPEndPoint(i->second, -1).ToStringWithoutPort()); | 94 output.append(IPEndPoint(i->second, 0).ToStringWithoutPort()); |
| 94 output.append(" ").append(host_name).append("\n"); | 95 output.append(" ").append(host_name).append("\n"); |
| 95 } | 96 } |
| 96 return output; | 97 return output; |
| 97 } | 98 } |
| 98 | 99 |
| 99 struct ReplayLogEntry { | 100 struct ReplayLogEntry { |
| 100 base::TimeDelta start_time; | 101 base::TimeDelta start_time; |
| 101 std::string domain_name; | 102 std::string domain_name; |
| 102 }; | 103 }; |
| 103 | 104 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 } | 508 } |
| 508 | 509 |
| 509 } // empty namespace | 510 } // empty namespace |
| 510 | 511 |
| 511 } // namespace net | 512 } // namespace net |
| 512 | 513 |
| 513 int main(int argc, const char* argv[]) { | 514 int main(int argc, const char* argv[]) { |
| 514 net::GDig dig; | 515 net::GDig dig; |
| 515 return dig.Main(argc, argv); | 516 return dig.Main(argc, argv); |
| 516 } | 517 } |
| OLD | NEW |