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

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

Issue 1769783002: Migrate net::IPAddressList to net::IPAddress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « net/base/address_list_unittest.cc ('k') | net/base/ip_address_number.h » ('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) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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_ADDRESS_NET_H_ 5 #ifndef NET_BASE_IP_ADDRESS_NET_H_
6 #define NET_BASE_IP_ADDRESS_NET_H_ 6 #define NET_BASE_IP_ADDRESS_NET_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 bool operator<(const IPAddress& that) const; 98 bool operator<(const IPAddress& that) const;
99 99
100 private: 100 private:
101 // IPv4 addresses will have length kIPv4AddressSize, whereas IPv6 address 101 // IPv4 addresses will have length kIPv4AddressSize, whereas IPv6 address
102 // will have length kIPv6AddressSize. 102 // will have length kIPv6AddressSize.
103 std::vector<uint8_t> ip_address_; 103 std::vector<uint8_t> ip_address_;
104 104
105 // This class is copyable and assignable. 105 // This class is copyable and assignable.
106 }; 106 };
107 107
108 typedef std::vector<IPAddress> IPAddressList;
eroman 2016/03/08 21:04:03 Please use the new C++ way: using IPAddressList =
martijnc 2016/03/09 16:44:27 Done.
109
108 // TODO(Martijnc): These utility functions currently forward the calls to 110 // TODO(Martijnc): These utility functions currently forward the calls to
109 // the IPAddressNumber implementations. Move the implementations over when 111 // the IPAddressNumber implementations. Move the implementations over when
110 // the IPAddressNumber migration is complete. https://crbug.com/496258. 112 // the IPAddressNumber migration is complete. https://crbug.com/496258.
111 113
112 // Returns the canonical string representation of an IP address along with its 114 // Returns the canonical string representation of an IP address along with its
113 // port. For example: "192.168.0.1:99" or "[::1]:80". 115 // port. For example: "192.168.0.1:99" or "[::1]:80".
114 NET_EXPORT std::string IPAddressToStringWithPort(const IPAddress& address, 116 NET_EXPORT std::string IPAddressToStringWithPort(const IPAddress& address,
115 uint16_t port); 117 uint16_t port);
116 118
117 // Returns the address as a sequence of bytes in network-byte-order. 119 // Returns the address as a sequence of bytes in network-byte-order.
(...skipping 27 matching lines...) Expand all
145 template <size_t N> 147 template <size_t N>
146 bool IPAddressStartsWith(const IPAddress& address, const uint8_t (&prefix)[N]) { 148 bool IPAddressStartsWith(const IPAddress& address, const uint8_t (&prefix)[N]) {
147 if (address.size() < N) 149 if (address.size() < N)
148 return false; 150 return false;
149 return std::equal(prefix, prefix + N, address.bytes().begin()); 151 return std::equal(prefix, prefix + N, address.bytes().begin());
150 } 152 }
151 153
152 } // namespace net 154 } // namespace net
153 155
154 #endif // NET_BASE_IP_ADDRESS_NET_H_ 156 #endif // NET_BASE_IP_ADDRESS_NET_H_
OLDNEW
« no previous file with comments | « net/base/address_list_unittest.cc ('k') | net/base/ip_address_number.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698