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

Unified Diff: net/base/registry_controlled_domains/registry_controlled_domain.cc

Issue 2393163002: Factor out SameHost() in registry_controlled_domains
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
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 ca367f7214297509d21ea2f3e0bb8284e2ef855a..48e95508664313e955fbd585c6d673b07d47f119 100644
--- a/net/base/registry_controlled_domains/registry_controlled_domain.cc
+++ b/net/base/registry_controlled_domains/registry_controlled_domain.cc
@@ -202,6 +202,16 @@ std::string GetDomainAndRegistry(base::StringPiece host,
return GetDomainAndRegistryImpl(canon_host, filter).as_string();
}
+bool SameHost(const GURL& gurl1, const GURL& gurl2) {
+ const url::Component host1 = gurl1.parsed_for_possibly_invalid_spec().host;
+ const url::Component host2 = gurl2.parsed_for_possibly_invalid_spec().host;
+ if ((host1.len <= 0) || (host1.len != host2.len))
+ return false;
+ return !strncmp(gurl1.possibly_invalid_spec().data() + host1.begin,
+ gurl2.possibly_invalid_spec().data() + host2.begin,
+ host1.len);
+}
+
bool SameDomainOrHost(
const GURL& gurl1,
const GURL& gurl2,
@@ -216,13 +226,7 @@ bool SameDomainOrHost(
return domain1 == domain2;
// No domains. See if the hosts are identical.
- const url::Component host1 = gurl1.parsed_for_possibly_invalid_spec().host;
- const url::Component host2 = gurl2.parsed_for_possibly_invalid_spec().host;
- if ((host1.len <= 0) || (host1.len != host2.len))
- return false;
- return !strncmp(gurl1.possibly_invalid_spec().data() + host1.begin,
- gurl2.possibly_invalid_spec().data() + host2.begin,
- host1.len);
+ return SameHost(gurl1, gurl2);
}
bool SameDomainOrHost(const url::Origin& origin1,

Powered by Google App Engine
This is Rietveld 408576698