Index: net/proxy/proxy_resolver_v8.cc |
diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc |
index 80ae06b7e55540b16ad7e8b0204012ef22610e7f..50c2043c04d07bf781659f68e2aa960f0a60885d 100644 |
--- a/net/proxy/proxy_resolver_v8.cc |
+++ b/net/proxy/proxy_resolver_v8.cc |
@@ -21,7 +21,7 @@ |
#include "gin/array_buffer.h" |
#include "gin/public/isolate_holder.h" |
#include "gin/v8_initializer.h" |
-#include "net/base/ip_address_number.h" |
+#include "net/base/ip_address.h" |
#include "net/base/net_errors.h" |
#include "net/proxy/proxy_info.h" |
#include "net/proxy/proxy_resolver_script.h" |
@@ -244,26 +244,25 @@ bool GetHostnameArgument(const v8::FunctionCallbackInfo<v8::Value>& args, |
return success; |
} |
-// Wrapper for passing around IP address strings and IPAddressNumber objects. |
-struct IPAddress { |
- IPAddress(const std::string& ip_string, const IPAddressNumber& ip_number) |
- : string_value(ip_string), |
- ip_address_number(ip_number) { |
- } |
+// Wrapper for passing around IP address strings and IPAddress objects. |
+struct IPAddressInfo { |
+ IPAddressInfo(const std::string& ip_string, const IPAddress& ip_address) |
+ : string_value(ip_string), ip_address(ip_address) {} |
// Used for sorting IP addresses in ascending order in SortIpAddressList(). |
// IP6 addresses are placed ahead of IPv4 addresses. |
- bool operator<(const IPAddress& rhs) const { |
- const IPAddressNumber& ip1 = this->ip_address_number; |
- const IPAddressNumber& ip2 = rhs.ip_address_number; |
+ bool operator<(const IPAddressInfo& rhs) const { |
+ const IPAddress& ip1 = this->ip_address; |
+ const IPAddress& ip2 = rhs.ip_address; |
if (ip1.size() != ip2.size()) |
return ip1.size() > ip2.size(); // IPv6 before IPv4. |
DCHECK(ip1.size() == ip2.size()); |
- return memcmp(&ip1[0], &ip2[0], ip1.size()) < 0; // Ascending order. |
+ return memcmp(ip1.bytes().data(), ip2.bytes().data(), ip1.size()) < |
eroman
2016/03/18 19:59:45
Since IPAddress already has an operator<() we can
martijnc
2016/03/18 21:41:11
Done.
|
+ 0; // Ascending order. |
} |
std::string string_value; |
- IPAddressNumber ip_address_number; |
+ IPAddress ip_address; |
}; |
// Handler for "sortIpAddressList(IpAddressList)". |ip_address_list| is a |
@@ -284,13 +283,13 @@ bool SortIpAddressList(const std::string& ip_address_list, |
return false; |
// Split-up IP addresses and store them in a vector. |
- std::vector<IPAddress> ip_vector; |
- IPAddressNumber ip_num; |
+ std::vector<IPAddressInfo> ip_vector; |
+ IPAddress ip_address; |
base::StringTokenizer str_tok(cleaned_ip_address_list, ";"); |
while (str_tok.GetNext()) { |
- if (!ParseIPLiteralToNumber(str_tok.token(), &ip_num)) |
+ if (!ip_address.AssignFromIPLiteral(str_tok.token())) |
return false; |
- ip_vector.push_back(IPAddress(str_tok.token(), ip_num)); |
+ ip_vector.push_back(IPAddressInfo(str_tok.token(), ip_address)); |
} |
if (ip_vector.empty()) // Can happen if we have something like |
@@ -320,23 +319,23 @@ bool SortIpAddressList(const std::string& ip_address_list, |
// format, or if an address and prefix of different types are used (e.g. IPv6 |
// address and IPv4 prefix). |
bool IsInNetEx(const std::string& ip_address, const std::string& ip_prefix) { |
- IPAddressNumber address; |
- if (!ParseIPLiteralToNumber(ip_address, &address)) |
+ IPAddress address; |
+ if (!address.AssignFromIPLiteral(ip_address)) |
return false; |
- IPAddressNumber prefix; |
+ IPAddress prefix; |
size_t prefix_length_in_bits; |
- if (!ParseCIDRBlock(ip_prefix, &prefix, &prefix_length_in_bits)) |
+ if (!ParseCIDRBlock(ip_prefix, prefix, prefix_length_in_bits)) |
return false; |
// Both |address| and |prefix| must be of the same type (IPv4 or IPv6). |
if (address.size() != prefix.size()) |
return false; |
- DCHECK((address.size() == 4 && prefix.size() == 4) || |
- (address.size() == 16 && prefix.size() == 16)); |
+ DCHECK((address.IsIPv4() && prefix.IsIPv4()) || |
+ (address.IsIPv6() && prefix.IsIPv6())); |
- return IPNumberMatchesPrefix(address, prefix, prefix_length_in_bits); |
+ return IPAddressMatchesPrefix(address, prefix, prefix_length_in_bits); |
} |
// Consider only single component domains like 'foo' as plain host names. |
@@ -346,8 +345,8 @@ bool IsPlainHostName(const std::string& hostname_utf8) { |
// IPv6 literals might not contain any periods, however are not considered |
// plain host names. |
- IPAddressNumber unused; |
- return !ParseIPLiteralToNumber(hostname_utf8, &unused); |
+ IPAddress unused; |
+ return !unused.AssignFromIPLiteral(hostname_utf8); |
} |
// All instances of ProxyResolverV8 share the same v8::Isolate. This isolate is |