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

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: Added missing NET_EXPORT to *PortOnAddressList. 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
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; 13 struct addrinfo;
eroman 2012/05/04 01:08:41 Delete this.
14 class GURL; 14 class GURL;
15 15
16 namespace net { 16 namespace net {
17 17
18 class IPEndPoint;
19
18 class NET_EXPORT HostPortPair { 20 class NET_EXPORT HostPortPair {
19 public: 21 public:
20 HostPortPair(); 22 HostPortPair();
21 // If |in_host| represents an IPv6 address, it should not bracket the address. 23 // If |in_host| represents an IPv6 address, it should not bracket the address.
22 HostPortPair(const std::string& in_host, uint16 in_port); 24 HostPortPair(const std::string& in_host, uint16 in_port);
23 25
24 // Creates a HostPortPair for the origin of |url|. 26 // Creates a HostPortPair for the origin of |url|.
25 static HostPortPair FromURL(const GURL& url); 27 static HostPortPair FromURL(const GURL& url);
26 28
27 // Creates a HostPortPair from an addrinfo struct. 29 // Creates a HostPortPair from an addrinfo struct.
eroman 2012/05/04 01:08:41 Update the comment.
28 static HostPortPair FromAddrInfo(const struct addrinfo* ai); 30 static HostPortPair FromIPEndPoint(const IPEndPoint& ipe);
29 31
30 // Creates a HostPortPair from a string formatted in same manner as 32 // Creates a HostPortPair from a string formatted in same manner as
31 // ToString(). 33 // ToString().
32 static HostPortPair FromString(const std::string& str); 34 static HostPortPair FromString(const std::string& str);
33 35
34 // TODO(willchan): Define a functor instead. 36 // TODO(willchan): Define a functor instead.
35 // Comparator function so this can be placed in a std::map. 37 // Comparator function so this can be placed in a std::map.
36 bool operator<(const HostPortPair& other) const { 38 bool operator<(const HostPortPair& other) const {
37 if (port_ != other.port_) 39 if (port_ != other.port_)
38 return port_ < other.port_; 40 return port_ < other.port_;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 private: 76 private:
75 // If |host_| represents an IPv6 address, this string will not contain 77 // If |host_| represents an IPv6 address, this string will not contain
76 // brackets around the address. 78 // brackets around the address.
77 std::string host_; 79 std::string host_;
78 uint16 port_; 80 uint16 port_;
79 }; 81 };
80 82
81 } // namespace net 83 } // namespace net
82 84
83 #endif // NET_BASE_HOST_PORT_PAIR_H_ 85 #endif // NET_BASE_HOST_PORT_PAIR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698