| Index: net/base/registry_controlled_domains/registry_controlled_domain.cc
|
| diff --git a/net/base/registry_controlled_domains/registry_controlled_domain.cc b/net/base/registry_controlled_domains/registry_controlled_domain.cc
|
| index e5b8e4cb8a193ff8cb593504e28a01475d071833..466614248e9caf303ce63c065c59d65e5dc8cd51 100644
|
| --- a/net/base/registry_controlled_domains/registry_controlled_domain.cc
|
| +++ b/net/base/registry_controlled_domains/registry_controlled_domain.cc
|
| @@ -71,7 +71,8 @@ const int kPrivateRule = 4;
|
|
|
| // Read next offset from pos.
|
| // Returns true if an offset could be read, false otherwise.
|
| -bool GetNextOffset(const unsigned char** pos, const unsigned char* end,
|
| +bool GetNextOffset(const unsigned char** pos,
|
| + const unsigned char* end,
|
| const unsigned char** offset) {
|
| if (*pos == end)
|
| return false;
|
| @@ -111,7 +112,8 @@ bool IsEOL(const unsigned char* offset, const unsigned char* end) {
|
|
|
| // Check if byte at offset matches first character in key.
|
| // This version matches characters not last in label.
|
| -bool IsMatch(const unsigned char* offset, const unsigned char* end,
|
| +bool IsMatch(const unsigned char* offset,
|
| + const unsigned char* end,
|
| const char* key) {
|
| CHECK_LT(offset, end);
|
| return *offset == *key;
|
| @@ -119,7 +121,8 @@ bool IsMatch(const unsigned char* offset, const unsigned char* end,
|
|
|
| // Check if byte at offset matches first character in key.
|
| // This version matches characters last in label.
|
| -bool IsEndCharMatch(const unsigned char* offset, const unsigned char* end,
|
| +bool IsEndCharMatch(const unsigned char* offset,
|
| + const unsigned char* end,
|
| const char* key) {
|
| CHECK_LT(offset, end);
|
| return *offset == (*key | 0x80);
|
| @@ -127,7 +130,8 @@ bool IsEndCharMatch(const unsigned char* offset, const unsigned char* end,
|
|
|
| // Read return value at offset.
|
| // Returns true if a return value could be read, false otherwise.
|
| -bool GetReturnValue(const unsigned char* offset, const unsigned char* end,
|
| +bool GetReturnValue(const unsigned char* offset,
|
| + const unsigned char* end,
|
| int* return_value) {
|
| CHECK_LT(offset, end);
|
| if ((*offset & 0xE0) == 0x80) {
|
| @@ -139,7 +143,9 @@ bool GetReturnValue(const unsigned char* offset, const unsigned char* end,
|
|
|
| // Lookup a domain key in a byte array generated by make_dafsa.py.
|
| // The rule type is returned if key is found, otherwise kNotFound is returned.
|
| -int LookupString(const unsigned char* graph, size_t length, const char* key,
|
| +int LookupString(const unsigned char* graph,
|
| + size_t length,
|
| + const char* key,
|
| size_t key_length) {
|
| const unsigned char* pos = graph;
|
| const unsigned char* end = graph + length;
|
| @@ -199,10 +205,9 @@ int LookupString(const unsigned char* graph, size_t length, const char* key,
|
| return kNotFound; // No match
|
| }
|
|
|
| -size_t GetRegistryLengthImpl(
|
| - const std::string& host,
|
| - UnknownRegistryFilter unknown_filter,
|
| - PrivateRegistryFilter private_filter) {
|
| +size_t GetRegistryLengthImpl(const std::string& host,
|
| + UnknownRegistryFilter unknown_filter,
|
| + PrivateRegistryFilter private_filter) {
|
| DCHECK(!host.empty());
|
|
|
| // Skip leading dots.
|
| @@ -227,7 +232,7 @@ size_t GetRegistryLengthImpl(
|
| size_t curr_start = host_check_begin;
|
| size_t next_dot = host.find('.', curr_start);
|
| if (next_dot >= host_check_len) // Catches std::string::npos as well.
|
| - return 0; // This can't have a registry + domain.
|
| + return 0; // This can't have a registry + domain.
|
| while (1) {
|
| const char* domain_str = host.data() + curr_start;
|
| size_t domain_length = host_check_len - curr_start;
|
| @@ -277,12 +282,13 @@ size_t GetRegistryLengthImpl(
|
| // No rule found in the registry. curr_start now points to the first
|
| // character of the last subcomponent of the host, so if we allow unknown
|
| // registries, return the length of this subcomponent.
|
| - return unknown_filter == INCLUDE_UNKNOWN_REGISTRIES ?
|
| - (host.length() - curr_start) : 0;
|
| + return unknown_filter == INCLUDE_UNKNOWN_REGISTRIES
|
| + ? (host.length() - curr_start)
|
| + : 0;
|
| }
|
|
|
| -std::string GetDomainAndRegistryImpl(
|
| - const std::string& host, PrivateRegistryFilter private_filter) {
|
| +std::string GetDomainAndRegistryImpl(const std::string& host,
|
| + PrivateRegistryFilter private_filter) {
|
| DCHECK(!host.empty());
|
|
|
| // Find the length of the registry for this host.
|
| @@ -294,8 +300,8 @@ std::string GetDomainAndRegistryImpl(
|
| // subcomponent length.
|
| DCHECK(host.length() >= 2);
|
| if (registry_length > (host.length() - 2)) {
|
| - NOTREACHED() <<
|
| - "Host does not have at least one subcomponent before registry!";
|
| + NOTREACHED()
|
| + << "Host does not have at least one subcomponent before registry!";
|
| return std::string();
|
| }
|
|
|
| @@ -310,19 +316,18 @@ std::string GetDomainAndRegistryImpl(
|
|
|
| } // namespace
|
|
|
| -std::string GetDomainAndRegistry(
|
| - const GURL& gurl,
|
| - PrivateRegistryFilter filter) {
|
| +std::string GetDomainAndRegistry(const GURL& gurl,
|
| + PrivateRegistryFilter filter) {
|
| const url::Component host = gurl.parsed_for_possibly_invalid_spec().host;
|
| if ((host.len <= 0) || gurl.HostIsIPAddress())
|
| return std::string();
|
| - return GetDomainAndRegistryImpl(std::string(
|
| - gurl.possibly_invalid_spec().data() + host.begin, host.len), filter);
|
| + return GetDomainAndRegistryImpl(
|
| + std::string(gurl.possibly_invalid_spec().data() + host.begin, host.len),
|
| + filter);
|
| }
|
|
|
| -std::string GetDomainAndRegistry(
|
| - const std::string& host,
|
| - PrivateRegistryFilter filter) {
|
| +std::string GetDomainAndRegistry(const std::string& host,
|
| + PrivateRegistryFilter filter) {
|
| url::CanonHostInfo host_info;
|
| const std::string canon_host(CanonicalizeHost(host, &host_info));
|
| if (canon_host.empty() || host_info.IsIPAddress())
|
| @@ -330,10 +335,9 @@ std::string GetDomainAndRegistry(
|
| return GetDomainAndRegistryImpl(canon_host, filter);
|
| }
|
|
|
| -bool SameDomainOrHost(
|
| - const GURL& gurl1,
|
| - const GURL& gurl2,
|
| - PrivateRegistryFilter filter) {
|
| +bool SameDomainOrHost(const GURL& gurl1,
|
| + const GURL& gurl2,
|
| + PrivateRegistryFilter filter) {
|
| // See if both URLs have a known domain + registry, and those values are the
|
| // same.
|
| const std::string domain1(GetDomainAndRegistry(gurl1, filter));
|
| @@ -351,10 +355,9 @@ bool SameDomainOrHost(
|
| host1.len);
|
| }
|
|
|
| -size_t GetRegistryLength(
|
| - const GURL& gurl,
|
| - UnknownRegistryFilter unknown_filter,
|
| - PrivateRegistryFilter private_filter) {
|
| +size_t GetRegistryLength(const GURL& gurl,
|
| + UnknownRegistryFilter unknown_filter,
|
| + PrivateRegistryFilter private_filter) {
|
| const url::Component host = gurl.parsed_for_possibly_invalid_spec().host;
|
| if (host.len <= 0)
|
| return std::string::npos;
|
| @@ -366,10 +369,9 @@ size_t GetRegistryLength(
|
| private_filter);
|
| }
|
|
|
| -size_t GetRegistryLength(
|
| - const std::string& host,
|
| - UnknownRegistryFilter unknown_filter,
|
| - PrivateRegistryFilter private_filter) {
|
| +size_t GetRegistryLength(const std::string& host,
|
| + UnknownRegistryFilter unknown_filter,
|
| + PrivateRegistryFilter private_filter) {
|
| url::CanonHostInfo host_info;
|
| const std::string canon_host(CanonicalizeHost(host, &host_info));
|
| if (canon_host.empty())
|
|
|