Commit 9a66827a authored by Gang Wu's avatar Gang Wu Committed by Commit Bot

[Feed] Add configuration to maximum GC attempts.

Bug: 995375
Change-Id: I021e31b1006bc1fb759d1a5a83e70f7097545686
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761191
Commit-Queue: Gang Wu <gangwu@chromium.org>
Reviewed-by: default avatarSky Malice <skym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688333}
parent 3b3e4de3
......@@ -72,6 +72,10 @@ public final class FeedConfiguration {
/** Default value for whether to use menu options to launch interest management page. */
public static final boolean MANAGE_INTERESTS_ENABLED_DEFAULT = false;
private static final String MAXIMUM_GC_ATTEMPTS = "maximum_gc_attempts";
/** Default value for the maximum number of times that the GC task can re-enqueue itself. */
public static final long MAXIMUM_GC_ATTEMPTS_DEFAULT = 10;
private static final String NON_CACHED_MIN_PAGE_SIZE = "non_cached_min_page_size";
/** Default value for non cached minimum page size. */
public static final long NON_CACHED_MIN_PAGE_SIZE_DEFAULT = 5;
......@@ -216,7 +220,7 @@ public final class FeedConfiguration {
(int) LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT);
}
/** return Whether to show context menu option to launch to customization page. */
/** @return Whether to show context menu option to launch to customization page. */
@VisibleForTesting
static boolean getManageInterestsEnabled() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
......@@ -224,6 +228,14 @@ public final class FeedConfiguration {
MANAGE_INTERESTS_ENABLED_DEFAULT);
}
/** @return The maximum number of times that the GC task can re-enqueue itself. */
@VisibleForTesting
static long getMaximumGcAttempts() {
return (long) ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, MAXIMUM_GC_ATTEMPTS,
(int) MAXIMUM_GC_ATTEMPTS_DEFAULT);
}
/** @return Used to decide where to place the more button. */
@VisibleForTesting
static int getNonCachedMinPageSize() {
......@@ -355,6 +367,7 @@ public final class FeedConfiguration {
FeedConfiguration.getLoggingImmediateContentThresholdMs())
.put(ConfigKey.MANAGE_INTERESTS_ENABLED,
FeedConfiguration.getManageInterestsEnabled())
.put(ConfigKey.MAXIMUM_GC_ATTEMPTS, FeedConfiguration.getMaximumGcAttempts())
.put(ConfigKey.NON_CACHED_MIN_PAGE_SIZE,
FeedConfiguration.getNonCachedMinPageSize())
.put(ConfigKey.NON_CACHED_PAGE_SIZE, FeedConfiguration.getNonCachedPageSize())
......
......@@ -58,6 +58,8 @@ public class FeedConfigurationTest {
FeedConfiguration.getLoggingImmediateContentThresholdMs());
Assert.assertEquals(FeedConfiguration.MANAGE_INTERESTS_ENABLED_DEFAULT,
FeedConfiguration.getManageInterestsEnabled());
Assert.assertEquals(FeedConfiguration.MAXIMUM_GC_ATTEMPTS_DEFAULT,
FeedConfiguration.getMaximumGcAttempts());
Assert.assertEquals(FeedConfiguration.NON_CACHED_MIN_PAGE_SIZE_DEFAULT,
FeedConfiguration.getNonCachedMinPageSize());
Assert.assertEquals(FeedConfiguration.NON_CACHED_PAGE_SIZE_DEFAULT,
......@@ -207,6 +209,16 @@ public class FeedConfigurationTest {
Assert.assertTrue(FeedConfiguration.getManageInterestsEnabled());
}
@Test
@Feature({"Feed"})
@CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:maximum_gc_attempts/5"})
public void
testMaximumGcAttempts() {
Assert.assertEquals(5, FeedConfiguration.getMaximumGcAttempts());
}
@Test
@Feature({"Feed"})
@CommandLineFlags.
......@@ -356,6 +368,8 @@ public class FeedConfigurationTest {
ConfigKey.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS, 0l));
Assert.assertFalse(
configuration.getValueOrDefault(ConfigKey.MANAGE_INTERESTS_ENABLED, true));
Assert.assertEquals((long) FeedConfiguration.MAXIMUM_GC_ATTEMPTS_DEFAULT,
configuration.getValueOrDefault(ConfigKey.MAXIMUM_GC_ATTEMPTS, 0l));
Assert.assertEquals((long) FeedConfiguration.NON_CACHED_MIN_PAGE_SIZE_DEFAULT,
configuration.getValueOrDefault(ConfigKey.NON_CACHED_MIN_PAGE_SIZE, 0));
Assert.assertEquals((long) FeedConfiguration.NON_CACHED_PAGE_SIZE_DEFAULT,
......
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