Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: net/tools/gdig/gdig.cc

Issue 718273002: Use uint16 for port numbers, net/ edition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/bind.h" 9 #include "base/bind.h"
10 #include "base/cancelable_callback.h" 10 #include "base/cancelable_callback.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 int port; 46 int port;
47 if (!ParseHostAndPort(ip_address_and_port, &ip, &port)) 47 if (!ParseHostAndPort(ip_address_and_port, &ip, &port))
48 return false; 48 return false;
49 if (port == -1) 49 if (port == -1)
50 port = dns_protocol::kDefaultPort; 50 port = dns_protocol::kDefaultPort;
51 51
52 net::IPAddressNumber ip_number; 52 net::IPAddressNumber ip_number;
53 if (!net::ParseIPLiteralToNumber(ip, &ip_number)) 53 if (!net::ParseIPLiteralToNumber(ip, &ip_number))
54 return false; 54 return false;
55 55
56 *ip_end_point = net::IPEndPoint(ip_number, port); 56 *ip_end_point = net::IPEndPoint(ip_number, static_cast<uint16>(port));
57 return true; 57 return true;
58 } 58 }
59 59
60 // Convert DnsConfig to human readable text omitting the hosts member. 60 // Convert DnsConfig to human readable text omitting the hosts member.
61 std::string DnsConfigToString(const DnsConfig& dns_config) { 61 std::string DnsConfigToString(const DnsConfig& dns_config) {
62 std::string output; 62 std::string output;
63 output.append("search "); 63 output.append("search ");
64 for (size_t i = 0; i < dns_config.search.size(); ++i) { 64 for (size_t i = 0; i < dns_config.search.size(); ++i) {
65 output.append(dns_config.search[i] + " "); 65 output.append(dns_config.search[i] + " ");
66 } 66 }
(...skipping 16 matching lines...) Expand all
83 } 83 }
84 84
85 // Convert DnsConfig hosts member to a human readable text. 85 // Convert DnsConfig hosts member to a human readable text.
86 std::string DnsHostsToString(const DnsHosts& dns_hosts) { 86 std::string DnsHostsToString(const DnsHosts& dns_hosts) {
87 std::string output; 87 std::string output;
88 for (DnsHosts::const_iterator i = dns_hosts.begin(); 88 for (DnsHosts::const_iterator i = dns_hosts.begin();
89 i != dns_hosts.end(); 89 i != dns_hosts.end();
90 ++i) { 90 ++i) {
91 const DnsHostsKey& key = i->first; 91 const DnsHostsKey& key = i->first;
92 std::string host_name = key.first; 92 std::string host_name = key.first;
93 output.append(IPEndPoint(i->second, -1).ToStringWithoutPort()); 93 output.append(IPEndPoint(i->second, 0).ToStringWithoutPort());
94 output.append(" ").append(host_name).append("\n"); 94 output.append(" ").append(host_name).append("\n");
95 } 95 }
96 return output; 96 return output;
97 } 97 }
98 98
99 struct ReplayLogEntry { 99 struct ReplayLogEntry {
100 base::TimeDelta start_time; 100 base::TimeDelta start_time;
101 std::string domain_name; 101 std::string domain_name;
102 }; 102 };
103 103
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } 507 }
508 508
509 } // empty namespace 509 } // empty namespace
510 510
511 } // namespace net 511 } // namespace net
512 512
513 int main(int argc, const char* argv[]) { 513 int main(int argc, const char* argv[]) {
514 net::GDig dig; 514 net::GDig dig;
515 return dig.Main(argc, argv); 515 return dig.Main(argc, argv);
516 } 516 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698