Commit 5d467a2b authored by Xinghui Lu's avatar Xinghui Lu Committed by Commit Bot

Skip clean up if stored RealTimeUrlCheck verdict count is 0.

In incognito mode, the stored verdict count is always 0 because real
time URL check is disabled. Therefore,
CleanUpExpiredRealTimeUrlCheckVerdicts can return early to avoid the
jank.

Bug: 1095078
Change-Id: Ic6c8a5ee441d18cd26e4591186699a7597c158fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404743
Commit-Queue: Xinghui Lu <xinghuilu@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805991}
parent ae0ad3ad
......@@ -617,6 +617,9 @@ void VerdictCacheManager::CleanUpExpiredPhishGuardVerdicts() {
}
void VerdictCacheManager::CleanUpExpiredRealTimeUrlCheckVerdicts() {
if (stored_verdict_count_real_time_url_check_ == 0) {
return;
}
ContentSettingsForOneType safe_browsing_url_check_data_settings;
content_settings_->GetSettingsForOneType(
ContentSettingsType::SAFE_BROWSING_URL_CHECK_DATA, std::string(),
......
......@@ -149,7 +149,7 @@ class VerdictCacheManager : public history::HistoryServiceObserver,
base::Optional<size_t> stored_verdict_count_password_entry_;
// Number of verdict stored for this profile for real time url check pings.
// This is only used for testing and logging metrics.
// This is used for testing, logging metrics and cleaning up during shutdown.
int stored_verdict_count_real_time_url_check_ = 0;
ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
......
......@@ -326,6 +326,9 @@ TEST_F(VerdictCacheManagerTest, TestCleanUpExpiredVerdict) {
ASSERT_EQ(2u, cache_manager_->GetStoredPhishGuardVerdictCount(
LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE));
// Prepare 2 verdicts for SAFE_BROWSING_URL_CHECK_DATA:
// (1) "www.example.com/" expired
// (2) "www.example.com/path" valid
RTLookupResponse response;
AddThreatInfoToResponse(response, RTLookupResponse::ThreatInfo::DANGEROUS,
RTLookupResponse::ThreatInfo::SOCIAL_ENGINEERING, 0,
......@@ -388,6 +391,18 @@ TEST_F(VerdictCacheManagerTest, TestCleanUpExpiredVerdict) {
GURL("https://bar.com/xyz/index.jsp"),
LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE,
password_type, &actual_verdict));
RTLookupResponse::ThreatInfo actual_real_time_threat_info;
// No cached SAFE_BROWSING_URL_CHECK_DATA verdict for www.example.com/.
EXPECT_EQ(
RTLookupResponse::ThreatInfo::VERDICT_TYPE_UNSPECIFIED,
cache_manager_->GetCachedRealTimeUrlVerdict(
GURL("https://www.example.com/"), &actual_real_time_threat_info));
// Has cached SAFE_BROWSING_URL_CHECK_DATA verdict for www.example.com/path.
EXPECT_EQ(
RTLookupResponse::ThreatInfo::DANGEROUS,
cache_manager_->GetCachedRealTimeUrlVerdict(
GURL("https://www.example.com/path"), &actual_real_time_threat_info));
}
TEST_F(VerdictCacheManagerTest, TestCleanUpExpiredVerdictWithInvalidEntry) {
......
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