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

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

Issue 1809863002: Update some callers to use more direct ways of constructing IPAddress from well known literals. (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 | « no previous file | net/base/ip_address.cc » ('j') | net/http/http_network_transaction_unittest.cc » ('J')
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 // Returns an IPAddress instance representing the 127.0.0.1 address. 89 // Returns an IPAddress instance representing the 127.0.0.1 address.
90 static IPAddress IPv4Localhost(); 90 static IPAddress IPv4Localhost();
91 91
92 // Returns an IPAddress instance representing the ::1 address. 92 // Returns an IPAddress instance representing the ::1 address.
93 static IPAddress IPv6Localhost(); 93 static IPAddress IPv6Localhost();
94 94
95 // Returns an IPAddress made up of |num_zero_bytes| zeros. 95 // Returns an IPAddress made up of |num_zero_bytes| zeros.
96 static IPAddress AllZeros(size_t num_zero_bytes); 96 static IPAddress AllZeros(size_t num_zero_bytes);
97 97
98 // Returns an IPAddress instance representing the 0.0.0.0 address.
99 static IPAddress IPv4AllZeros();
100
101 // Returns an IPAddress instance representing the :: address.
102 static IPAddress IPv6AllZeros();
103
98 bool operator==(const IPAddress& that) const; 104 bool operator==(const IPAddress& that) const;
99 bool operator!=(const IPAddress& that) const; 105 bool operator!=(const IPAddress& that) const;
100 bool operator<(const IPAddress& that) const; 106 bool operator<(const IPAddress& that) const;
101 107
102 private: 108 private:
103 // IPv4 addresses will have length kIPv4AddressSize, whereas IPv6 address 109 // IPv4 addresses will have length kIPv4AddressSize, whereas IPv6 address
104 // will have length kIPv6AddressSize. 110 // will have length kIPv6AddressSize.
105 std::vector<uint8_t> ip_address_; 111 std::vector<uint8_t> ip_address_;
106 112
107 // This class is copyable and assignable. 113 // This class is copyable and assignable.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 template <size_t N> 161 template <size_t N>
156 bool IPAddressStartsWith(const IPAddress& address, const uint8_t (&prefix)[N]) { 162 bool IPAddressStartsWith(const IPAddress& address, const uint8_t (&prefix)[N]) {
157 if (address.size() < N) 163 if (address.size() < N)
158 return false; 164 return false;
159 return std::equal(prefix, prefix + N, address.bytes().begin()); 165 return std::equal(prefix, prefix + N, address.bytes().begin());
160 } 166 }
161 167
162 } // namespace net 168 } // namespace net
163 169
164 #endif // NET_BASE_IP_ADDRESS_NET_H_ 170 #endif // NET_BASE_IP_ADDRESS_NET_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/ip_address.cc » ('j') | net/http/http_network_transaction_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698