Commit c0724101 authored by Joe DeBlasio's avatar Joe DeBlasio Committed by Chromium LUCI CQ

[Lookalikes] Avoid unnecessary call into SiteEngagementService.

This CL removes an unnecessary call to IsEngagementAtLeast() in
OnFetchEngagedSites(). This call unnecessarily recomputed the score
for many URLs, even of which required acquiring a lock. This was
causing jank, as many threads could call OnFetchEngagedSites() at
once.

This fix is a bandaid to reduce jank quickly. A follow-up CL will
hopefully refactor LookalikeUrlService a bit to ensure that only
one call to GetAllDetailsInBackground (which calls
OnFetchEngagedSites) is outstanding at a time.

Bug: 1157596
Change-Id: I66a4946b3cf8b1b1800f019a35f56ea9f55b6d92
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2617874
Commit-Queue: Mustafa Emre Acer <meacer@chromium.org>
Reviewed-by: default avatarMustafa Emre Acer <meacer@chromium.org>
Auto-Submit: Joe DeBlasio <jdeblasio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841761}
parent 90e072a1
......@@ -23,6 +23,7 @@
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/lookalikes/core/lookalike_url_util.h"
#include "components/site_engagement/content/site_engagement_score.h"
#include "components/url_formatter/spoof_checks/top_domains/top_domain_util.h"
#include "components/url_formatter/url_formatter.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
......@@ -120,16 +121,14 @@ void LookalikeUrlService::SetClockForTesting(base::Clock* clock) {
void LookalikeUrlService::OnFetchEngagedSites(
EngagedSitesCallback callback,
std::vector<site_engagement::mojom::SiteEngagementDetails> details) {
site_engagement::SiteEngagementService* service =
site_engagement::SiteEngagementService::Get(profile_);
engaged_sites_.clear();
for (const site_engagement::mojom::SiteEngagementDetails& detail : details) {
if (!detail.origin.SchemeIsHTTPOrHTTPS()) {
continue;
}
// Ignore sites with an engagement score below threshold.
if (!service->IsEngagementAtLeast(detail.origin,
blink::mojom::EngagementLevel::MEDIUM)) {
if (detail.total_score <
site_engagement::SiteEngagementScore::GetMediumEngagementBoundary()) {
continue;
}
const DomainInfo domain_info = GetDomainInfo(detail.origin);
......
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