Commit a6fbd799 authored by Ian Wells's avatar Ian Wells Committed by Commit Bot

[Feed] Remove throttling and freshness checks for background fetches

Refresh suggestions in the background with more urgency to bring Feed's
background fetching in line with Zine's.

Bug: 988165
Change-Id: I412ad34a7ec6c1b6c3ec3bf5e089ee2a0854e77f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1730090
Commit-Queue: Ian Wells <iwells@chromium.org>
Reviewed-by: default avatarSky Malice <skym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683656}
parent ce314965
...@@ -569,18 +569,22 @@ FeedSchedulerHost::ShouldRefreshResult FeedSchedulerHost::ShouldRefresh( ...@@ -569,18 +569,22 @@ FeedSchedulerHost::ShouldRefreshResult FeedSchedulerHost::ShouldRefresh(
return kDontRefreshRefreshSuppressed; return kDontRefreshRefreshSuppressed;
} }
if (attempt_age < GetTriggerThreshold(trigger)) { // https://crbug.com/988165: When kThrottleBackgroundFetches == false, skip
DVLOG(2) << "Last attempt age of " << attempt_age // checks for quota and staleness for background fetching.
<< " stopped refresh from trigger " << static_cast<int>(trigger); if (kThrottleBackgroundFetches.Get() || trigger != TriggerType::kFixedTimer) {
return kDontRefreshNotStale; if (attempt_age < GetTriggerThreshold(trigger)) {
} DVLOG(2) << "Last attempt age of " << attempt_age
<< " stopped refresh from trigger " << static_cast<int>(trigger);
return kDontRefreshNotStale;
}
auto throttlerIter = throttlers_.find(user_class); auto throttlerIter = throttlers_.find(user_class);
if (throttlerIter == throttlers_.end() || if (throttlerIter == throttlers_.end() ||
!throttlerIter->second->RequestQuota()) { !throttlerIter->second->RequestQuota()) {
DVLOG(2) << "Throttler stopped refresh from trigger " DVLOG(2) << "Throttler stopped refresh from trigger "
<< static_cast<int>(trigger); << static_cast<int>(trigger);
return kDontRefreshRefreshThrottled; return kDontRefreshRefreshThrottled;
}
} }
switch (trigger) { switch (trigger) {
......
...@@ -654,6 +654,22 @@ TEST_F(FeedSchedulerHostTest, OnFixedTimerActiveSuggestionsConsumer) { ...@@ -654,6 +654,22 @@ TEST_F(FeedSchedulerHostTest, OnFixedTimerActiveSuggestionsConsumer) {
EXPECT_EQ(3, refresh_call_count()); EXPECT_EQ(3, refresh_call_count());
} }
TEST_F(FeedSchedulerHostTest, OnFixedTimerThrottlingDisabled) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeatureWithParameters(
kInterestFeedContentSuggestions,
{{kThrottleBackgroundFetches.name, "false"}});
// Every call to OnFixedTimer() should cause a fetch.
scheduler()->OnFixedTimer(base::OnceClosure());
EXPECT_EQ(1, refresh_call_count());
scheduler()->OnReceiveNewContent(test_clock()->Now());
scheduler()->OnFixedTimer(base::OnceClosure());
EXPECT_EQ(2, refresh_call_count());
scheduler()->OnReceiveNewContent(test_clock()->Now());
}
TEST_F(FeedSchedulerHostTest, ScheduleFixedTimerWakeUpOnSuccess) { TEST_F(FeedSchedulerHostTest, ScheduleFixedTimerWakeUpOnSuccess) {
// First wake up scheduled during Initialize(). // First wake up scheduled during Initialize().
EXPECT_EQ(1U, schedule_wake_up_times().size()); EXPECT_EQ(1U, schedule_wake_up_times().size());
......
...@@ -15,6 +15,8 @@ const base::FeatureParam<int> kSuppressRefreshDurationMinutes{ ...@@ -15,6 +15,8 @@ const base::FeatureParam<int> kSuppressRefreshDurationMinutes{
&kInterestFeedContentSuggestions, "suppress_refresh_duration_minutes", 30}; &kInterestFeedContentSuggestions, "suppress_refresh_duration_minutes", 30};
const base::FeatureParam<int> kTimeoutDurationSeconds{ const base::FeatureParam<int> kTimeoutDurationSeconds{
&kInterestFeedContentSuggestions, "timeout_duration_seconds", 30}; &kInterestFeedContentSuggestions, "timeout_duration_seconds", 30};
const base::FeatureParam<bool> kThrottleBackgroundFetches{
&kInterestFeedContentSuggestions, "throttle_background_fetches", true};
const base::Feature kInterestFeedNotifications{ const base::Feature kInterestFeedNotifications{
"InterestFeedNotifications", base::FEATURE_DISABLED_BY_DEFAULT}; "InterestFeedNotifications", base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -17,6 +17,7 @@ extern const base::Feature kInterestFeedContentSuggestions; ...@@ -17,6 +17,7 @@ extern const base::Feature kInterestFeedContentSuggestions;
extern const base::FeatureParam<std::string> kDisableTriggerTypes; extern const base::FeatureParam<std::string> kDisableTriggerTypes;
extern const base::FeatureParam<int> kSuppressRefreshDurationMinutes; extern const base::FeatureParam<int> kSuppressRefreshDurationMinutes;
extern const base::FeatureParam<int> kTimeoutDurationSeconds; extern const base::FeatureParam<int> kTimeoutDurationSeconds;
extern const base::FeatureParam<bool> kThrottleBackgroundFetches;
extern const base::Feature kInterestFeedNotifications; extern const base::Feature kInterestFeedNotifications;
......
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