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

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

Issue 1151843002: DO NOT LAND Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More. Created 5 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
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 7
8 #include <string> 8 #include <string>
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "net/base/net_export.h" 10 #include "net/base/net_export.h"
11 #include "url/origin.h"
11 12
12 class GURL; 13 class GURL;
13 14
14 namespace net { 15 namespace net {
15 16
16 class IPEndPoint; 17 class IPEndPoint;
17 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 IPEndPoint. 28 // Creates a HostPortPair from an IPEndPoint.
28 static HostPortPair FromIPEndPoint(const IPEndPoint& ipe); 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
35 // Creates a HostPortPair from an Origin.
36 static HostPortPair FromOrigin(const url::Origin& origin);
37
34 // TODO(willchan): Define a functor instead. 38 // TODO(willchan): Define a functor instead.
35 // Comparator function so this can be placed in a std::map. 39 // Comparator function so this can be placed in a std::map.
36 bool operator<(const HostPortPair& other) const { 40 bool operator<(const HostPortPair& other) const {
37 if (port_ != other.port_) 41 if (port_ != other.port_)
38 return port_ < other.port_; 42 return port_ < other.port_;
39 return host_ < other.host_; 43 return host_ < other.host_;
40 } 44 }
41 45
42 // Equality test of contents. (Probably another violation of style guide). 46 // Equality test of contents. (Probably another violation of style guide).
43 bool Equals(const HostPortPair& other) const { 47 bool Equals(const HostPortPair& other) const {
(...skipping 30 matching lines...) Expand all
74 private: 78 private:
75 // If |host_| represents an IPv6 address, this string will not contain 79 // If |host_| represents an IPv6 address, this string will not contain
76 // brackets around the address. 80 // brackets around the address.
77 std::string host_; 81 std::string host_;
78 uint16 port_; 82 uint16 port_;
79 }; 83 };
80 84
81 } // namespace net 85 } // namespace net
82 86
83 #endif // NET_BASE_HOST_PORT_PAIR_H_ 87 #endif // NET_BASE_HOST_PORT_PAIR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698