Skip to content

Commit

Permalink
[Feed] Add config values for placing synthetic token.
Browse files Browse the repository at this point in the history
Bug: 910712
Change-Id: I70b768c1215ef0f540fbccbe98d0907881388782
Reviewed-on: https://chromium-review.googlesource.com/c/1357537
Commit-Queue: Sky Malice <[email protected]>
Reviewed-by: Filip Gorski <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#613349}(cherry picked from commit ebd9b95)
Reviewed-on: https://chromium-review.googlesource.com/c/1362479
Reviewed-by: Sky Malice <[email protected]>
Cr-Commit-Position: refs/branch-heads/3626@{#56}
Cr-Branched-From: d897fb1-refs/heads/master@{#612437}
  • Loading branch information
Sky Malice authored and Sky Malice committed Dec 5, 2018
1 parent e22ebe5 commit 2039ba6
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,23 @@ private FeedConfiguration() {}
/** Default value for feed server response length prefixed. */
public static final boolean FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT = true;

private static final String INITIAL_NON_CACHED_PAGE_SIZE = "initial_non_cached_page_size";
/** Default value for initial non cached page size. */
public static final int INITIAL_NON_CACHED_PAGE_SIZE_DEFAULT = 10;

private static final String LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS =
"logging_immediate_content_threshold_ms";
/** Default value for logging immediate content threshold. */
public static final int LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT = 1000;

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 int NON_CACHED_MIN_PAGE_SIZE_DEFAULT = 5;

private static final String NON_CACHED_PAGE_SIZE = "non_cached_page_size";
/** Default value for non cached page size. */
public static final int NON_CACHED_PAGE_SIZE_DEFAULT = 20;

private static final String SESSION_LIFETIME_MS = "session_lifetime_ms";
/** Default value for session lifetime. */
public static final int SESSION_LIFETIME_MS_DEFAULT = 3600000;
Expand Down Expand Up @@ -69,12 +81,19 @@ static String getFeedServerMethod() {

/** @return Whether server response should be length prefixed. */
@VisibleForTesting
static boolean getFeedServerReponseLengthPrefixed() {
static boolean getFeedServerResponseLengthPrefixed() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS,
FEED_SERVER_RESPONSE_LENGTH_PREFIXED, FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT);
}

/** @return Used to decide where to place the more button initially. */
static int getInitialNonCachedPageSize() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, INITIAL_NON_CACHED_PAGE_SIZE,
INITIAL_NON_CACHED_PAGE_SIZE_DEFAULT);
}

/**
* @return How long before showing content after opening NTP is no longer considered immediate
* in UMA.
Expand All @@ -87,6 +106,20 @@ static long getLoggingImmediateContentThresholdMs() {
LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT);
}

/** @return Used to decide where to place the more button. */
static int getNonCachedMinPageSize() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, NON_CACHED_MIN_PAGE_SIZE,
NON_CACHED_MIN_PAGE_SIZE_DEFAULT);
}

/** @return Used to decide where to place the more button. */
static int getNonCachedPageSize() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, NON_CACHED_PAGE_SIZE,
NON_CACHED_PAGE_SIZE_DEFAULT);
}

/** @return Time until feed stops restoring the UI. */
@VisibleForTesting
static long getSessionLifetimeMs() {
Expand All @@ -100,7 +133,7 @@ static long getSessionLifetimeMs() {
* when server could potentially have more content.
*/
@VisibleForTesting
static boolean getTriggerImmedatePagination() {
static boolean getTriggerImmediatePagination() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, TRIGGER_IMMEDIATE_PAGINATION,
TRIGGER_IMMEDIATE_PAGINATION_DEFAULT);
Expand All @@ -122,12 +155,17 @@ public static Configuration createConfiguration() {
.put(ConfigKey.FEED_SERVER_ENDPOINT, FeedConfiguration.getFeedServerEndpoint())
.put(ConfigKey.FEED_SERVER_METHOD, FeedConfiguration.getFeedServerMethod())
.put(ConfigKey.FEED_SERVER_RESPONSE_LENGTH_PREFIXED,
FeedConfiguration.getFeedServerReponseLengthPrefixed())
FeedConfiguration.getFeedServerResponseLengthPrefixed())
.put(ConfigKey.INITIAL_NON_CACHED_PAGE_SIZE,
FeedConfiguration.getInitialNonCachedPageSize())
.put(ConfigKey.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS,
FeedConfiguration.getLoggingImmediateContentThresholdMs())
.put(ConfigKey.NON_CACHED_MIN_PAGE_SIZE,
FeedConfiguration.getNonCachedMinPageSize())
.put(ConfigKey.NON_CACHED_PAGE_SIZE, FeedConfiguration.getNonCachedPageSize())
.put(ConfigKey.SESSION_LIFETIME_MS, FeedConfiguration.getSessionLifetimeMs())
.put(ConfigKey.TRIGGER_IMMEDIATE_PAGINATION,
FeedConfiguration.getTriggerImmedatePagination())
FeedConfiguration.getTriggerImmediatePagination())
.put(ConfigKey.VIEW_LOG_THRESHOLD, FeedConfiguration.getViewLogThreshold())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ public void testDefaultFeedConfigurationValues() {
Assert.assertEquals(FeedConfiguration.FEED_SERVER_METHOD_DEFAULT,
FeedConfiguration.getFeedServerMethod());
Assert.assertEquals(FeedConfiguration.FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT,
FeedConfiguration.getFeedServerReponseLengthPrefixed());
FeedConfiguration.getFeedServerResponseLengthPrefixed());
Assert.assertEquals(FeedConfiguration.INITIAL_NON_CACHED_PAGE_SIZE_DEFAULT,
FeedConfiguration.getInitialNonCachedPageSize());
Assert.assertEquals(FeedConfiguration.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT,
FeedConfiguration.getLoggingImmediateContentThresholdMs());
Assert.assertEquals(FeedConfiguration.NON_CACHED_MIN_PAGE_SIZE_DEFAULT,
FeedConfiguration.getNonCachedMinPageSize());
Assert.assertEquals(FeedConfiguration.NON_CACHED_PAGE_SIZE_DEFAULT,
FeedConfiguration.getNonCachedPageSize());
Assert.assertEquals(FeedConfiguration.SESSION_LIFETIME_MS_DEFAULT,
FeedConfiguration.getSessionLifetimeMs());
Assert.assertFalse(FeedConfiguration.getTriggerImmedatePagination());
Assert.assertFalse(FeedConfiguration.getTriggerImmediatePagination());
Assert.assertEquals(FeedConfiguration.VIEW_LOG_THRESHOLD_DEFAULT,
FeedConfiguration.getViewLogThreshold(), ASSERT_EQUALS_DOUBLE_DELTA);
}
Expand Down Expand Up @@ -75,18 +81,49 @@ public void testFeedServerMethodParameter() {
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:feed_server_response_length_prefixed/false"})
public void testFeedServerResponseLengthPrefixedParameter() {
Assert.assertEquals(false, FeedConfiguration.getFeedServerReponseLengthPrefixed());
Assert.assertEquals(false, FeedConfiguration.getFeedServerResponseLengthPrefixed());
}

@Test
@Feature({"Feed"})
@CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:initial_non_cached_page_size/100"})
public void
testInitialNonCachedPageSize() {
Assert.assertEquals(100, FeedConfiguration.getInitialNonCachedPageSize());
}

@Test
@Feature({"Feed"})
@CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:logging_immediate_content_threshold_ms/5000"})
public void testLoggingImmediateContentThresholdMs() {
public void
testLoggingImmediateContentThresholdMs() {
Assert.assertEquals(5000, FeedConfiguration.getLoggingImmediateContentThresholdMs());
}

@Test
@Feature({"Feed"})
@CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:non_cached_min_page_size/100"})
public void
testNonCachedMinPageSize() {
Assert.assertEquals(100, FeedConfiguration.getNonCachedMinPageSize());
}

@Test
@Feature({"Feed"})
@CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:non_cached_page_size/100"})
public void
testNonCachedPageSize() {
Assert.assertEquals(100, FeedConfiguration.getNonCachedPageSize());
}

@Test
@Feature({"Feed"})
@CommandLineFlags.
Expand All @@ -102,7 +139,7 @@ public void testSessionLifetimeMs() {
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:trigger_immediate_pagination/true"})
public void testTriggerImmedatePagination() {
Assert.assertTrue(FeedConfiguration.getTriggerImmedatePagination());
Assert.assertTrue(FeedConfiguration.getTriggerImmediatePagination());
}

@Test
Expand All @@ -126,10 +163,16 @@ public void testCreateConfiguration() {
configuration.getValueOrDefault(ConfigKey.FEED_SERVER_METHOD, ""));
Assert.assertEquals(FeedConfiguration.FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT,
configuration.getValueOrDefault(ConfigKey.FEED_SERVER_RESPONSE_LENGTH_PREFIXED, 0));
Assert.assertEquals(Integer.valueOf(FeedConfiguration.INITIAL_NON_CACHED_PAGE_SIZE_DEFAULT),
configuration.getValueOrDefault(ConfigKey.INITIAL_NON_CACHED_PAGE_SIZE, 0));
Assert.assertEquals(
Long.valueOf(FeedConfiguration.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT),
configuration.getValueOrDefault(
ConfigKey.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS, 0l));
Assert.assertEquals(Integer.valueOf(FeedConfiguration.NON_CACHED_MIN_PAGE_SIZE_DEFAULT),
configuration.getValueOrDefault(ConfigKey.NON_CACHED_MIN_PAGE_SIZE, 0));
Assert.assertEquals(Integer.valueOf(FeedConfiguration.NON_CACHED_PAGE_SIZE_DEFAULT),
configuration.getValueOrDefault(ConfigKey.NON_CACHED_PAGE_SIZE, 0));
Assert.assertEquals(Long.valueOf(FeedConfiguration.SESSION_LIFETIME_MS_DEFAULT),
configuration.getValueOrDefault(ConfigKey.SESSION_LIFETIME_MS, 0l));
Assert.assertFalse(
Expand Down

0 comments on commit 2039ba6

Please sign in to comment.