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

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

Issue 1408803010: Add IPAddress class as a replacement for the IPAddressNumber typedef. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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_IP_ENDPOINT_H_ 5 #ifndef NET_BASE_IP_ENDPOINT_H_
6 #define NET_BASE_IP_ENDPOINT_H_ 6 #define NET_BASE_IP_ENDPOINT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "net/base/address_family.h" 12 #include "net/base/address_family.h"
13 #include "net/base/ip_address.h"
13 #include "net/base/ip_address_number.h" 14 #include "net/base/ip_address_number.h"
14 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
15 #include "net/base/sys_addrinfo.h" 16 #include "net/base/sys_addrinfo.h"
16 17
17 struct sockaddr; 18 struct sockaddr;
18 19
19 namespace net { 20 namespace net {
20 21
21 // An IPEndPoint represents the address of a transport endpoint: 22 // An IPEndPoint represents the address of a transport endpoint:
22 // * IP address (either v4 or v6) 23 // * IP address (either v4 or v6)
23 // * Port 24 // * Port
24 class NET_EXPORT IPEndPoint { 25 class NET_EXPORT IPEndPoint {
25 public: 26 public:
26 IPEndPoint(); 27 IPEndPoint();
27 ~IPEndPoint(); 28 ~IPEndPoint();
28 IPEndPoint(const IPAddressNumber& address, uint16_t port); 29 IPEndPoint(const IPAddressNumber& address, uint16_t port);
30 IPEndPoint(const IPAddress& address, uint16_t port);
29 IPEndPoint(const IPEndPoint& endpoint); 31 IPEndPoint(const IPEndPoint& endpoint);
30 32
31 const IPAddressNumber& address() const { return address_; } 33 // TODO(Martijnc): Remove the old version when all consumers are moved to
34 // IPAddress. https://crbug.com/496258
35 const IPAddressNumber& address() const { return address_.ip_address_; }
36 const IPAddress& addressNew() const { return address_; }
32 uint16_t port() const { return port_; } 37 uint16_t port() const { return port_; }
33 38
34 // Returns AddressFamily of the address. 39 // Returns AddressFamily of the address.
35 AddressFamily GetFamily() const; 40 AddressFamily GetFamily() const;
36 41
37 // Returns the sockaddr family of the address, AF_INET or AF_INET6. 42 // Returns the sockaddr family of the address, AF_INET or AF_INET6.
38 int GetSockAddrFamily() const; 43 int GetSockAddrFamily() const;
39 44
40 // Convert to a provided sockaddr struct. 45 // Convert to a provided sockaddr struct.
41 // |address| is the sockaddr to copy into. Should be at least 46 // |address| is the sockaddr to copy into. Should be at least
(...skipping 16 matching lines...) Expand all
58 // valid. 63 // valid.
59 std::string ToString() const; 64 std::string ToString() const;
60 65
61 // As above, but without port. 66 // As above, but without port.
62 std::string ToStringWithoutPort() const; 67 std::string ToStringWithoutPort() const;
63 68
64 bool operator<(const IPEndPoint& that) const; 69 bool operator<(const IPEndPoint& that) const;
65 bool operator==(const IPEndPoint& that) const; 70 bool operator==(const IPEndPoint& that) const;
66 71
67 private: 72 private:
68 IPAddressNumber address_; 73 IPAddress address_;
69 uint16_t port_; 74 uint16_t port_;
70 }; 75 };
71 76
72 } // namespace net 77 } // namespace net
73 78
74 #endif // NET_BASE_IP_ENDPOINT_H_ 79 #endif // NET_BASE_IP_ENDPOINT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698