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

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

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: rch feedbak 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/ip_address.h ('k') | net/base/ip_address_unittest.cc » ('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 #include "net/base/ip_address.h" 5 #include "net/base/ip_address.h"
6 6
7 #include "net/base/ip_address_number.h" 7 #include "net/base/ip_address_number.h"
8 #include "url/gurl.h" 8 #include "url/gurl.h"
9 #include "url/url_canon_ip.h" 9 #include "url/url_canon_ip.h"
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 static const uint8_t kLocalhostIPv6[] = {0, 0, 0, 0, 0, 0, 0, 0, 82 static const uint8_t kLocalhostIPv6[] = {0, 0, 0, 0, 0, 0, 0, 0,
83 0, 0, 0, 0, 0, 0, 0, 1}; 83 0, 0, 0, 0, 0, 0, 0, 1};
84 return IPAddress(kLocalhostIPv6); 84 return IPAddress(kLocalhostIPv6);
85 } 85 }
86 86
87 // static 87 // static
88 IPAddress IPAddress::AllZeros(size_t num_zero_bytes) { 88 IPAddress IPAddress::AllZeros(size_t num_zero_bytes) {
89 return IPAddress(std::vector<uint8_t>(num_zero_bytes)); 89 return IPAddress(std::vector<uint8_t>(num_zero_bytes));
90 } 90 }
91 91
92 // static
93 IPAddress IPAddress::IPv4AllZeros() {
94 return AllZeros(kIPv4AddressSize);
95 }
96
97 // static
98 IPAddress IPAddress::IPv6AllZeros() {
99 return AllZeros(kIPv6AddressSize);
100 }
101
92 bool IPAddress::operator==(const IPAddress& that) const { 102 bool IPAddress::operator==(const IPAddress& that) const {
93 return ip_address_ == that.ip_address_; 103 return ip_address_ == that.ip_address_;
94 } 104 }
95 105
96 bool IPAddress::operator!=(const IPAddress& that) const { 106 bool IPAddress::operator!=(const IPAddress& that) const {
97 return ip_address_ != that.ip_address_; 107 return ip_address_ != that.ip_address_;
98 } 108 }
99 109
100 bool IPAddress::operator<(const IPAddress& that) const { 110 bool IPAddress::operator<(const IPAddress& that) const {
101 // Sort IPv4 before IPv6. 111 // Sort IPv4 before IPv6.
(...skipping 29 matching lines...) Expand all
131 141
132 unsigned CommonPrefixLength(const IPAddress& a1, const IPAddress& a2) { 142 unsigned CommonPrefixLength(const IPAddress& a1, const IPAddress& a2) {
133 return CommonPrefixLength(a1.bytes(), a2.bytes()); 143 return CommonPrefixLength(a1.bytes(), a2.bytes());
134 } 144 }
135 145
136 unsigned MaskPrefixLength(const IPAddress& mask) { 146 unsigned MaskPrefixLength(const IPAddress& mask) {
137 return MaskPrefixLength(mask.bytes()); 147 return MaskPrefixLength(mask.bytes());
138 } 148 }
139 149
140 } // namespace net 150 } // namespace net
OLDNEW
« no previous file with comments | « net/base/ip_address.h ('k') | net/base/ip_address_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698