| 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 #ifndef NET_BASE_HOST_PORT_PAIR_H_ | 5 #ifndef NET_BASE_HOST_PORT_PAIR_H_ |
| 6 #define NET_BASE_HOST_PORT_PAIR_H_ | 6 #define NET_BASE_HOST_PORT_PAIR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 | 12 |
| 13 struct HostPortPair { | 13 struct HostPortPair { |
| 14 HostPortPair(); | 14 HostPortPair(); |
| 15 // If |in_host| represents an IPv6 address, it should not bracket the address. | 15 // If |in_host| represents an IPv6 address, it should not bracket the address. |
| 16 HostPortPair(const std::string& in_host, uint16 in_port); | 16 HostPortPair(const std::string& in_host, uint16 in_port); |
| 17 | 17 |
| 18 // TODO(willchan): Define a functor instead. |
| 18 // Comparator function so this can be placed in a std::map. | 19 // Comparator function so this can be placed in a std::map. |
| 19 bool operator<(const HostPortPair& other) const { | 20 bool operator<(const HostPortPair& other) const { |
| 20 if (host != other.host) | 21 if (port != other.port) |
| 21 return host < other.host; | 22 return port < other.port; |
| 22 return port < other.port; | 23 return host < other.host; |
| 23 } | 24 } |
| 24 | 25 |
| 25 // ToString() will convert the HostPortPair to "host:port". If |host| is an | 26 // ToString() will convert the HostPortPair to "host:port". If |host| is an |
| 26 // IPv6 literal, it will add brackets around |host|. | 27 // IPv6 literal, it will add brackets around |host|. |
| 27 std::string ToString() const; | 28 std::string ToString() const; |
| 28 | 29 |
| 29 // If |host| represents an IPv6 address, this string will not contain brackets | 30 // If |host| represents an IPv6 address, this string will not contain brackets |
| 30 // around the address. | 31 // around the address. |
| 31 std::string host; | 32 std::string host; |
| 32 uint16 port; | 33 uint16 port; |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 } // namespace net | 36 } // namespace net |
| 36 | 37 |
| 37 #endif // NET_BASE_HOST_PORT_PAIR_H_ | 38 #endif // NET_BASE_HOST_PORT_PAIR_H_ |
| OLD | NEW |