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

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

Issue 6488010: Propagate the remote socket address to URLRequest and to ViewHostMsg_FrameNavigate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use HostPortPair everywhere Created 9 years, 10 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) 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 11
12 struct addrinfo;
12 class GURL; 13 class GURL;
13 14
14 namespace net { 15 namespace net {
15 16
16 class HostPortPair { 17 class HostPortPair {
17 public: 18 public:
18 HostPortPair(); 19 HostPortPair();
19 // If |in_host| represents an IPv6 address, it should not bracket the address. 20 // If |in_host| represents an IPv6 address, it should not bracket the address.
20 HostPortPair(const std::string& in_host, uint16 in_port); 21 HostPortPair(const std::string& in_host, uint16 in_port);
21 22
22 // Creates a HostPortPair for the origin of |url|. 23 // Creates a HostPortPair for the origin of |url|.
23 static HostPortPair FromURL(const GURL& url); 24 static HostPortPair FromURL(const GURL& url);
24 25
26 // Creates a HostPortPair from an addrinfo struct.
27 static HostPortPair FromAddrInfo(const struct addrinfo* ai);
eroman 2011/02/18 02:48:30 You might consider having this operate on the head
Brian Ryner 2011/02/18 04:41:59 I think I'll stick with addrinfo, since it's a lit
28
25 // TODO(willchan): Define a functor instead. 29 // TODO(willchan): Define a functor instead.
26 // Comparator function so this can be placed in a std::map. 30 // Comparator function so this can be placed in a std::map.
27 bool operator<(const HostPortPair& other) const { 31 bool operator<(const HostPortPair& other) const {
28 if (port_ != other.port_) 32 if (port_ != other.port_)
29 return port_ < other.port_; 33 return port_ < other.port_;
30 return host_ < other.host_; 34 return host_ < other.host_;
31 } 35 }
32 36
33 // Equality test of contents. (Probably another violation of style guide). 37 // Equality test of contents. (Probably another violation of style guide).
34 bool Equals(const HostPortPair& other) const { 38 bool Equals(const HostPortPair& other) const {
(...skipping 26 matching lines...) Expand all
61 private: 65 private:
62 // If |host_| represents an IPv6 address, this string will not contain 66 // If |host_| represents an IPv6 address, this string will not contain
63 // brackets around the address. 67 // brackets around the address.
64 std::string host_; 68 std::string host_;
65 uint16 port_; 69 uint16 port_;
66 }; 70 };
67 71
68 } // namespace net 72 } // namespace net
69 73
70 #endif // NET_BASE_HOST_PORT_PAIR_H_ 74 #endif // NET_BASE_HOST_PORT_PAIR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698