Commit 6d12e160 authored by John Delaney's avatar John Delaney Committed by Commit Bot

Avoid unnecessary etld lookups in browsing data filters

What:
Adds some early exit/flow control logic in the backing filter function
which prevents doing registerable domain lookups when they are not
necessary.

Why:
Currently these lookups are performed for every origin, even if there
are no registerable domains to compare against, and if it is already
matching an origin rule. These lookups are somewhat expensive and
require several string operations.

Change-Id: I79e2af8baf9c884b7de7811080e970bcc364d274
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521101
Commit-Queue: John Delaney <johnidel@chromium.org>
Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826799}
parent 425f8559
......@@ -38,14 +38,20 @@ bool MatchesOrigin(const std::set<url::Origin>& origins,
const std::set<std::string>& registerable_domains,
BrowsingDataFilterBuilder::Mode mode,
const url::Origin& origin) {
std::string registerable_domain =
GetDomainAndRegistry(origin, INCLUDE_PRIVATE_REGISTRIES);
bool found_domain = base::Contains(
registerable_domains,
registerable_domain == "" ? origin.host() : registerable_domain);
bool is_delete_list = mode == BrowsingDataFilterBuilder::Mode::kDelete;
bool found_origin = base::Contains(origins, origin);
return ((found_domain || found_origin) ==
(mode == BrowsingDataFilterBuilder::Mode::kDelete));
if (found_origin)
return is_delete_list;
bool found_domain = false;
if (!registerable_domains.empty()) {
std::string registerable_domain =
GetDomainAndRegistry(origin, INCLUDE_PRIVATE_REGISTRIES);
found_domain = base::Contains(
registerable_domains,
registerable_domain == "" ? origin.host() : registerable_domain);
}
return found_domain == is_delete_list;
}
bool MatchesURL(const std::set<url::Origin>& origins,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment