OLD | NEW |
---|---|
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 #include "net/base/net_util.h" | 5 #include "net/base/net_util.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 27 matching lines...) Expand all Loading... | |
38 #include "base/lazy_instance.h" | 38 #include "base/lazy_instance.h" |
39 #include "base/logging.h" | 39 #include "base/logging.h" |
40 #include "base/strings/string_number_conversions.h" | 40 #include "base/strings/string_number_conversions.h" |
41 #include "base/strings/string_piece.h" | 41 #include "base/strings/string_piece.h" |
42 #include "base/strings/string_split.h" | 42 #include "base/strings/string_split.h" |
43 #include "base/strings/string_util.h" | 43 #include "base/strings/string_util.h" |
44 #include "base/strings/stringprintf.h" | 44 #include "base/strings/stringprintf.h" |
45 #include "base/strings/utf_string_conversions.h" | 45 #include "base/strings/utf_string_conversions.h" |
46 #include "base/sys_byteorder.h" | 46 #include "base/sys_byteorder.h" |
47 #include "base/values.h" | 47 #include "base/values.h" |
48 #include "url/gurl.h" | |
49 #include "url/url_canon.h" | |
50 #include "url/url_canon_ip.h" | |
51 #include "url/url_parse.h" | |
52 #include "net/base/dns_util.h" | 48 #include "net/base/dns_util.h" |
53 #include "net/base/net_module.h" | 49 #include "net/base/net_module.h" |
54 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 50 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
55 #include "net/grit/net_resources.h" | 51 #include "net/grit/net_resources.h" |
56 #include "net/http/http_content_disposition.h" | 52 #include "net/http/http_content_disposition.h" |
53 #include "url/gurl.h" | |
54 #include "url/origin.h" | |
55 #include "url/url_canon.h" | |
56 #include "url/url_canon_ip.h" | |
57 #include "url/url_parse.h" | |
57 | 58 |
58 #if defined(OS_ANDROID) | 59 #if defined(OS_ANDROID) |
59 #include "net/android/network_library.h" | 60 #include "net/android/network_library.h" |
60 #endif | 61 #endif |
61 #if defined(OS_WIN) | 62 #if defined(OS_WIN) |
62 #include "net/base/winsock_init.h" | 63 #include "net/base/winsock_init.h" |
63 #endif | 64 #endif |
64 | 65 |
65 namespace net { | 66 namespace net { |
66 | 67 |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 host_and_port.begin(), host_and_port.end(), host, port); | 404 host_and_port.begin(), host_and_port.end(), host, port); |
404 } | 405 } |
405 | 406 |
406 std::string GetHostAndPort(const GURL& url) { | 407 std::string GetHostAndPort(const GURL& url) { |
407 // For IPv6 literals, GURL::host() already includes the brackets so it is | 408 // For IPv6 literals, GURL::host() already includes the brackets so it is |
408 // safe to just append a colon. | 409 // safe to just append a colon. |
409 return base::StringPrintf("%s:%d", url.host().c_str(), | 410 return base::StringPrintf("%s:%d", url.host().c_str(), |
410 url.EffectiveIntPort()); | 411 url.EffectiveIntPort()); |
411 } | 412 } |
412 | 413 |
414 std::string GetHostAndPort(const url::Origin& origin) { | |
415 // For IPv6 literals, GURL::host() already includes the brackets so it is | |
416 // safe to just append a colon. | |
417 return base::StringPrintf("%s:%d", origin.host().c_str(), origin.port()); | |
Ryan Sleevi
2015/05/22 02:50:03
Except Origin.host == HostNoBrackets() == BAY SPLO
| |
418 } | |
419 | |
413 std::string GetHostAndOptionalPort(const GURL& url) { | 420 std::string GetHostAndOptionalPort(const GURL& url) { |
414 // For IPv6 literals, GURL::host() already includes the brackets | 421 // For IPv6 literals, GURL::host() already includes the brackets |
415 // so it is safe to just append a colon. | 422 // so it is safe to just append a colon. |
416 if (url.has_port()) | 423 if (url.has_port()) |
417 return base::StringPrintf("%s:%s", url.host().c_str(), url.port().c_str()); | 424 return base::StringPrintf("%s:%s", url.host().c_str(), url.port().c_str()); |
418 return url.host(); | 425 return url.host(); |
419 } | 426 } |
420 | 427 |
421 bool IsHostnameNonUnique(const std::string& hostname) { | 428 bool IsHostnameNonUnique(const std::string& hostname) { |
422 // CanonicalizeHost requires surrounding brackets to parse an IPv6 address. | 429 // CanonicalizeHost requires surrounding brackets to parse an IPv6 address. |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1089 | 1096 |
1090 unsigned MaskPrefixLength(const IPAddressNumber& mask) { | 1097 unsigned MaskPrefixLength(const IPAddressNumber& mask) { |
1091 IPAddressNumber all_ones(mask.size(), 0xFF); | 1098 IPAddressNumber all_ones(mask.size(), 0xFF); |
1092 return CommonPrefixLength(mask, all_ones); | 1099 return CommonPrefixLength(mask, all_ones); |
1093 } | 1100 } |
1094 | 1101 |
1095 ScopedWifiOptions::~ScopedWifiOptions() { | 1102 ScopedWifiOptions::~ScopedWifiOptions() { |
1096 } | 1103 } |
1097 | 1104 |
1098 } // namespace net | 1105 } // namespace net |
OLD | NEW |