Skip to content

Commit

Permalink
Disable precache on svelte.
Browse files Browse the repository at this point in the history
Precache was enabled for svelte in http://crrev.com/c8e7c272, when the
experiment was only on dev, in the interest in seeing the maximum percent of
users that we could impact.

There is an unconfirmed possibility that the background service may slow down
phones with low RAM/CPU. Until we verify that it does not, we would like to
avoid launching on svelte devices, in order to eliminate any potential for
harm.

This change re-disables the service on svelte devices, by checking
PrivacyPreferencesManager#shouldPrerender() instead of
PrefServiceBridge#getNetworkPredictionEnabled().

BUG=683259

Review-Url: https://codereview.chromium.org/2642733004
Cr-Commit-Position: refs/heads/master@{#445110}
  • Loading branch information
twifkak authored and Commit bot committed Jan 20, 2017
1 parent 07dcf42 commit 5fe1163
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager;
import org.chromium.chrome.browser.sync.ProfileSyncService;

import java.util.EnumSet;
Expand Down Expand Up @@ -46,7 +46,7 @@ public static PrecacheLauncher get() {
*/
private boolean mCalled;
private boolean mSyncInitialized;
private boolean mNetworkPredictionsAllowed;
private boolean mPrerenderEnabled;
private boolean mShouldRun;

/** Destroy the native PrecacheLauncher, releasing the memory that it was using. */
Expand Down Expand Up @@ -115,15 +115,13 @@ private void updateEnabledSync(Context context) {
// thread.
ThreadUtils.assertOnUiThread();

boolean networkPredictionEnabledPref =
PrefServiceBridge.getInstance().getNetworkPredictionEnabled();
boolean prerenderEnabled = PrivacyPreferencesManager.getInstance().shouldPrerender();
boolean shouldRun = nativeShouldRun();

mNetworkPredictionsAllowed = networkPredictionEnabledPref;
mPrerenderEnabled = prerenderEnabled;
mShouldRun = shouldRun;

PrecacheController.setIsPrecachingEnabled(
context, networkPredictionEnabledPref && shouldRun);
PrecacheController.setIsPrecachingEnabled(context, prerenderEnabled && shouldRun);
Log.v(TAG, "updateEnabledSync complete");
}

Expand Down Expand Up @@ -181,7 +179,7 @@ public EnumSet<FailureReason> failureReasons() {
EnumSet<FailureReason> reasons = EnumSet.noneOf(FailureReason.class);
if (!mCalled) reasons.add(FailureReason.UPDATE_PRECACHING_ENABLED_NEVER_CALLED);
if (!mSyncInitialized) reasons.add(FailureReason.SYNC_NOT_INITIALIZED);
if (!mNetworkPredictionsAllowed) {
if (!mPrerenderEnabled) {
reasons.add(FailureReason.PRERENDER_PRIVACY_PREFERENCE_NOT_ENABLED);
}
if (!mShouldRun) reasons.add(FailureReason.NATIVE_SHOULD_RUN_IS_FALSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package org.chromium.chrome.browser.precache;

import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_END_DEVICE;

import android.content.Context;
import android.support.test.filters.SmallTest;

Expand All @@ -12,6 +14,8 @@
import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager;
import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.content.browser.test.NativeLibraryTestBase;

Expand Down Expand Up @@ -108,6 +112,9 @@ public void run() {
// on the fly.
mSync = new StubProfileSyncService();
ProfileSyncService.overrideForTests(mSync);
// This is currently the default, but let's verify that, lest it ever change and we
// get confusing test failures later.
assertTrue(PrivacyPreferencesManager.getInstance().shouldPrerender());
}
});
}
Expand All @@ -120,6 +127,7 @@ protected void tearDown() throws Exception {
}

@SmallTest
@Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
@Feature({"Precache"})
public void testUpdateEnabled_SyncNotReady_ThenDisabled() {
mLauncher.updateEnabled(getTargetContext());
Expand All @@ -137,6 +145,7 @@ public void testUpdateEnabled_SyncNotReady_ThenDisabled() {
}

@SmallTest
@Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
@Feature({"Precache"})
public void testUpdateEnabled_SyncNotReady_ThenEnabled() {
mLauncher.updateEnabled(getTargetContext());
Expand All @@ -155,6 +164,7 @@ public void testUpdateEnabled_SyncNotReady_ThenEnabled() {
}

@SmallTest
@Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
@Feature({"Precache"})
public void testUpdateEnabled_Disabled_ThenEnabled() {
setEngineInitialized(true);
Expand All @@ -170,6 +180,7 @@ public void testUpdateEnabled_Disabled_ThenEnabled() {
}

@SmallTest
@Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
@Feature({"Precache"})
public void testUpdateEnabled_Enabled_ThenDisabled() {
mLauncher.setShouldRun(true);
Expand All @@ -186,6 +197,7 @@ public void testUpdateEnabled_Enabled_ThenDisabled() {
}

@SmallTest
@Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
@Feature({"Precache"})
public void testUpdateEnabledNullProfileSyncService() {
ProfileSyncService.overrideForTests(null);
Expand Down

0 comments on commit 5fe1163

Please sign in to comment.