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

Side by Side Diff: net/base/host_port_pair.h

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: get_canonical_name -> canonical_name. iterator to indexing Created 8 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « net/base/address_list_unittest.cc ('k') | net/base/host_port_pair.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
12 12
13 struct addrinfo;
14 class GURL; 13 class GURL;
15 14
16 namespace net { 15 namespace net {
17 16
17 class IPEndPoint;
18
18 class NET_EXPORT HostPortPair { 19 class NET_EXPORT HostPortPair {
19 public: 20 public:
20 HostPortPair(); 21 HostPortPair();
21 // If |in_host| represents an IPv6 address, it should not bracket the address. 22 // If |in_host| represents an IPv6 address, it should not bracket the address.
22 HostPortPair(const std::string& in_host, uint16 in_port); 23 HostPortPair(const std::string& in_host, uint16 in_port);
23 24
24 // Creates a HostPortPair for the origin of |url|. 25 // Creates a HostPortPair for the origin of |url|.
25 static HostPortPair FromURL(const GURL& url); 26 static HostPortPair FromURL(const GURL& url);
26 27
27 // Creates a HostPortPair from an addrinfo struct. 28 // Creates a HostPortPair from an IPEndPoint.
28 static HostPortPair FromAddrInfo(const struct addrinfo* ai); 29 static HostPortPair FromIPEndPoint(const IPEndPoint& ipe);
29 30
30 // Creates a HostPortPair from a string formatted in same manner as 31 // Creates a HostPortPair from a string formatted in same manner as
31 // ToString(). 32 // ToString().
32 static HostPortPair FromString(const std::string& str); 33 static HostPortPair FromString(const std::string& str);
33 34
34 // TODO(willchan): Define a functor instead. 35 // TODO(willchan): Define a functor instead.
35 // Comparator function so this can be placed in a std::map. 36 // Comparator function so this can be placed in a std::map.
36 bool operator<(const HostPortPair& other) const { 37 bool operator<(const HostPortPair& other) const {
37 if (port_ != other.port_) 38 if (port_ != other.port_)
38 return port_ < other.port_; 39 return port_ < other.port_;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 private: 75 private:
75 // If |host_| represents an IPv6 address, this string will not contain 76 // If |host_| represents an IPv6 address, this string will not contain
76 // brackets around the address. 77 // brackets around the address.
77 std::string host_; 78 std::string host_;
78 uint16 port_; 79 uint16 port_;
79 }; 80 };
80 81
81 } // namespace net 82 } // namespace net
82 83
83 #endif // NET_BASE_HOST_PORT_PAIR_H_ 84 #endif // NET_BASE_HOST_PORT_PAIR_H_
OLDNEW
« no previous file with comments | « net/base/address_list_unittest.cc ('k') | net/base/host_port_pair.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698