| 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 #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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <tuple> | 11 #include <tuple> |
| 12 | 12 |
| 13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 14 #include "url/scheme_host_port.h" |
| 14 | 15 |
| 15 class GURL; | 16 class GURL; |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 | 19 |
| 19 class IPEndPoint; | 20 class IPEndPoint; |
| 20 | 21 |
| 21 class NET_EXPORT HostPortPair { | 22 class NET_EXPORT HostPortPair { |
| 22 public: | 23 public: |
| 23 HostPortPair(); | 24 HostPortPair(); |
| 24 // If |in_host| represents an IPv6 address, it should not bracket the address. | 25 // If |in_host| represents an IPv6 address, it should not bracket the address. |
| 25 HostPortPair(const std::string& in_host, uint16_t in_port); | 26 HostPortPair(const std::string& in_host, uint16_t in_port); |
| 26 | 27 |
| 27 // Creates a HostPortPair for the origin of |url|. | 28 // Creates a HostPortPair for the origin of |url|. |
| 28 static HostPortPair FromURL(const GURL& url); | 29 static HostPortPair FromURL(const GURL& url); |
| 29 | 30 |
| 31 // Creates a HostPortPair from SchemeHostPort. |
| 32 static HostPortPair FromSchemeHostPort(const url::SchemeHostPort& origin); |
| 33 |
| 30 // Creates a HostPortPair from an IPEndPoint. | 34 // Creates a HostPortPair from an IPEndPoint. |
| 31 static HostPortPair FromIPEndPoint(const IPEndPoint& ipe); | 35 static HostPortPair FromIPEndPoint(const IPEndPoint& ipe); |
| 32 | 36 |
| 33 // Creates a HostPortPair from a string formatted in same manner as | 37 // Creates a HostPortPair from a string formatted in same manner as |
| 34 // ToString(). | 38 // ToString(). |
| 35 static HostPortPair FromString(const std::string& str); | 39 static HostPortPair FromString(const std::string& str); |
| 36 | 40 |
| 37 // TODO(willchan): Define a functor instead. | 41 // TODO(willchan): Define a functor instead. |
| 38 // Comparator function so this can be placed in a std::map. | 42 // Comparator function so this can be placed in a std::map. |
| 39 bool operator<(const HostPortPair& other) const { | 43 bool operator<(const HostPortPair& other) const { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 private: | 75 private: |
| 72 // If |host_| represents an IPv6 address, this string will not contain | 76 // If |host_| represents an IPv6 address, this string will not contain |
| 73 // brackets around the address. | 77 // brackets around the address. |
| 74 std::string host_; | 78 std::string host_; |
| 75 uint16_t port_; | 79 uint16_t port_; |
| 76 }; | 80 }; |
| 77 | 81 |
| 78 } // namespace net | 82 } // namespace net |
| 79 | 83 |
| 80 #endif // NET_BASE_HOST_PORT_PAIR_H_ | 84 #endif // NET_BASE_HOST_PORT_PAIR_H_ |
| OLD | NEW |