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

Unified Diff: components/safe_browsing_db/v4_protocol_manager_util.cc

Issue 2747313002: PasswordProtectionService verdict cache management (Closed)
Patch Set: comments addressed partially Created 3 years, 9 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: components/safe_browsing_db/v4_protocol_manager_util.cc
diff --git a/components/safe_browsing_db/v4_protocol_manager_util.cc b/components/safe_browsing_db/v4_protocol_manager_util.cc
index e210f9751713268c76885f328675cd344348665f..816ca18646ade66d79040c7de5a99b8aefbefc28 100644
--- a/components/safe_browsing_db/v4_protocol_manager_util.cc
+++ b/components/safe_browsing_db/v4_protocol_manager_util.cc
@@ -287,18 +287,10 @@ void V4ProtocolManagerUtil::UpdateHeaders(net::HttpRequestHeaders* headers) {
void V4ProtocolManagerUtil::UrlToFullHashes(
const GURL& url,
std::vector<FullHash>* full_hashes) {
- std::string canon_host, canon_path, canon_query;
- CanonicalizeUrl(url, &canon_host, &canon_path, &canon_query);
-
std::vector<std::string> hosts;
- if (url.HostIsIPAddress()) {
- hosts.push_back(url.host());
- } else {
- GenerateHostVariantsToCheck(canon_host, &hosts);
- }
-
std::vector<std::string> paths;
- GeneratePathVariantsToCheck(canon_path, canon_query, &paths);
+ GenerateHostAndPathVariants(url, &hosts, &paths);
+
for (const std::string& host : hosts) {
for (const std::string& path : paths) {
full_hashes->push_back(crypto::SHA256HashString(host + path));
@@ -307,6 +299,24 @@ void V4ProtocolManagerUtil::UrlToFullHashes(
}
// static
+void V4ProtocolManagerUtil::GenerateHostAndPathVariants(
+ const GURL& url,
+ std::vector<std::string>* hosts,
+ std::vector<std::string>* paths) {
+ std::string canon_host, canon_path, canon_query;
+ CanonicalizeUrl(url, &canon_host, &canon_path, &canon_query);
+
+ hosts->clear();
+ paths->clear();
+ if (url.HostIsIPAddress()) {
+ hosts->push_back(url.host());
+ } else {
+ GenerateHostVariantsToCheck(canon_host, hosts);
+ }
+ GeneratePathVariantsToCheck(canon_path, canon_query, paths);
+}
+
+// static
bool V4ProtocolManagerUtil::FullHashToHashPrefix(const FullHash& full_hash,
PrefixSize prefix_size,
HashPrefix* hash_prefix) {

Powered by Google App Engine
This is Rietveld 408576698