| 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 8d379ba91b7f486df8d6593bf76ff13de8b5f885..ca367f7214297509d21ea2f3e0bb8284e2ef855a 100644
|
| --- a/net/base/registry_controlled_domains/registry_controlled_domain.cc
|
| +++ b/net/base/registry_controlled_domains/registry_controlled_domain.cc
|
| @@ -148,22 +148,23 @@ size_t GetRegistryLengthImpl(base::StringPiece host,
|
| (host.length() - curr_start) : 0;
|
| }
|
|
|
| -std::string GetDomainAndRegistryImpl(base::StringPiece host,
|
| - PrivateRegistryFilter private_filter) {
|
| +base::StringPiece GetDomainAndRegistryImpl(
|
| + base::StringPiece host,
|
| + PrivateRegistryFilter private_filter) {
|
| DCHECK(!host.empty());
|
|
|
| // Find the length of the registry for this host.
|
| const size_t registry_length =
|
| GetRegistryLengthImpl(host, INCLUDE_UNKNOWN_REGISTRIES, private_filter);
|
| if ((registry_length == std::string::npos) || (registry_length == 0))
|
| - return std::string(); // No registry.
|
| + return base::StringPiece(); // No registry.
|
| // The "2" in this next line is 1 for the dot, plus a 1-char minimum preceding
|
| // subcomponent length.
|
| DCHECK(host.length() >= 2);
|
| if (registry_length > (host.length() - 2)) {
|
| NOTREACHED() <<
|
| "Host does not have at least one subcomponent before registry!";
|
| - return std::string();
|
| + return base::StringPiece();
|
| }
|
|
|
| // Move past the dot preceding the registry, and search for the next previous
|
| @@ -171,8 +172,8 @@ std::string GetDomainAndRegistryImpl(base::StringPiece host,
|
| // no dot.
|
| const size_t dot = host.rfind('.', host.length() - registry_length - 2);
|
| if (dot == std::string::npos)
|
| - return host.as_string();
|
| - return host.substr(dot + 1).as_string();
|
| + return host;
|
| + return host.substr(dot + 1);
|
| }
|
|
|
| } // namespace
|
| @@ -180,9 +181,15 @@ std::string GetDomainAndRegistryImpl(base::StringPiece host,
|
| std::string GetDomainAndRegistry(
|
| const GURL& gurl,
|
| PrivateRegistryFilter filter) {
|
| + return GetDomainAndRegistryAsStringPiece(gurl, filter).as_string();
|
| +}
|
| +
|
| +base::StringPiece GetDomainAndRegistryAsStringPiece(
|
| + const GURL& gurl,
|
| + PrivateRegistryFilter filter) {
|
| base::StringPiece host = gurl.host_piece();
|
| if (host.empty() || gurl.HostIsIPAddress())
|
| - return std::string();
|
| + return base::StringPiece();
|
| return GetDomainAndRegistryImpl(host, filter);
|
| }
|
|
|
| @@ -192,7 +199,7 @@ std::string GetDomainAndRegistry(base::StringPiece host,
|
| const std::string canon_host(CanonicalizeHost(host, &host_info));
|
| if (canon_host.empty() || host_info.IsIPAddress())
|
| return std::string();
|
| - return GetDomainAndRegistryImpl(canon_host, filter);
|
| + return GetDomainAndRegistryImpl(canon_host, filter).as_string();
|
| }
|
|
|
| bool SameDomainOrHost(
|
| @@ -201,8 +208,10 @@ bool SameDomainOrHost(
|
| PrivateRegistryFilter filter) {
|
| // See if both URLs have a known domain + registry, and those values are the
|
| // same.
|
| - const std::string domain1(GetDomainAndRegistry(gurl1, filter));
|
| - const std::string domain2(GetDomainAndRegistry(gurl2, filter));
|
| + const base::StringPiece domain1 =
|
| + GetDomainAndRegistryAsStringPiece(gurl1, filter);
|
| + const base::StringPiece domain2 =
|
| + GetDomainAndRegistryAsStringPiece(gurl2, filter);
|
| if (!domain1.empty() || !domain2.empty())
|
| return domain1 == domain2;
|
|
|
|
|