Commit 0b0d3249 authored by skym's avatar skym Committed by Commit bot

Force sessions invalidations on for Android clients with foreign tabs suggestions feature.

When the foreign tabs suggestion feature is enabled (its currently at 0%, can be enabled via command line or flag page, hope to dial up in future), it suggests pages that are the most recent open tabs on other devices. These suggestions show up on the NewTabPage (currently only on Android). These suggestions really just display data from Sync's SESSION data type. This data type is typically enabled for syncing on most devices, but invalidations are disabled on Android clients for improved battery performance. Invalidations are the main mechanism that Sync uses to know when it needs to call GetUpdates and get the most recent data.

Disabling SESSION invalidations typically doesn't harm Android users. SESSION data is only used on a few UI surfaces, and when those surfaces are loaded we temporarily re-register for SESSION invalidations. Unfortunately, this approach doesn't work very well here because visiting the NewTabPage is such a frequent user action. This would result in a lot of traffic and wasted network usage to the invalidations server.

Having stale data means having your local client won't know about open tabs on other devices, and suggestions not being made when you know they should. This causes and inconsistent and less useful experience for the user. By forcing SESSION invalidations to on for anyone that has the foreign tabs suggestion feature enabled, it ensures we have fresh data and are able to suggestion the most value (most recent) pages. The main cost is that we lose the battery life saving of the aforementioned optimization.

BUG=649881

Review-Url: https://codereview.chromium.org/2478243006
Cr-Commit-Position: refs/heads/master@{#430362}
parent 01ae00b9
......@@ -58,6 +58,7 @@ public abstract class ChromeFeatureList {
public static final String IMPORTANT_SITES_IN_CBD = "ImportantSitesInCBD";
public static final String NO_CREDIT_CARD_ABORT = "NoCreditCardAbort";
public static final String NTP_FAKE_OMNIBOX_TEXT = "NTPFakeOmniboxText";
public static final String NTP_FOREIGN_SESSIONS_SUGGESTIONS = "NTPForeignSessionsSuggestions";
public static final String NTP_SNIPPETS = "NTPSnippets";
public static final String NTP_SNIPPETS_INCREASED_VISIBILITY = "NTPSnippetsIncreasedVisibility";
public static final String NTP_SNIPPETS_SAVE_TO_OFFLINE = "NTPSaveToOffline";
......
......@@ -16,6 +16,7 @@ import org.chromium.base.ApplicationState;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.FieldTrialList;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.components.invalidation.InvalidationClientService;
import org.chromium.components.signin.ChromeSigninController;
......@@ -283,7 +284,12 @@ public class InvalidationController implements ApplicationStatus.ApplicationStat
// that local session data is current and can be used to perform checks.
boolean requireInvalidationsForInstrumentation =
FieldTrialList.findFullName("PageRevisitInstrumentation").equals("Enabled");
boolean canDisableSessionInvalidations = !requireInvalidationsForInstrumentation;
// If the NTP is trying to suggest foreign tabs, then recieving invalidations is
// vital, otherwise data is stale and less useful.
boolean requireInvalidationsForSuggestions = ChromeFeatureList.isEnabled(
ChromeFeatureList.NTP_FOREIGN_SESSIONS_SUGGESTIONS);
boolean canDisableSessionInvalidations = !requireInvalidationsForInstrumentation
&& !requireInvalidationsForSuggestions;
boolean canUseGcmUpstream =
FieldTrialList.findFullName("InvalidationsGCMUpstream").equals("Enabled");
......
......@@ -54,6 +54,7 @@ const base::Feature* kFeaturesExposedToJava[] = {
&kWebApks,
&ntp_snippets::kContentSuggestionsFeature,
&ntp_snippets::kIncreasedVisibility,
&ntp_snippets::kForeignSessionsSuggestionsFeature,
&ntp_snippets::kOfflineBadgeFeature,
&ntp_snippets::kSaveToOfflineFeature,
&ntp_snippets::kSectionDismissalFeature,
......
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