 Chromium Code Reviews
 Chromium Code Reviews Issue 1146813010:
  Introduce moderate binding  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1146813010:
  Introduce moderate binding  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: chrome/android/java_staging/src/org/chromium/chrome/browser/DeferredStartupHandler.java | 
| diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/DeferredStartupHandler.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/DeferredStartupHandler.java | 
| index bd54eaa535c10a8bb4bbbac55816a91cd438cbf3..16c3e68586e784293e7f6bedacd39bb88fe27d4a 100644 | 
| --- a/chrome/android/java_staging/src/org/chromium/chrome/browser/DeferredStartupHandler.java | 
| +++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/DeferredStartupHandler.java | 
| @@ -5,7 +5,9 @@ | 
| package org.chromium.chrome.browser; | 
| import android.os.AsyncTask; | 
| +import android.text.TextUtils; | 
| +import org.chromium.base.FieldTrialList; | 
| import org.chromium.base.PowerMonitor; | 
| import org.chromium.base.ThreadUtils; | 
| import org.chromium.base.TraceEvent; | 
| @@ -20,11 +22,20 @@ import org.chromium.chrome.browser.precache.PrecacheLauncher; | 
| import org.chromium.chrome.browser.preferences.ChromePreferenceManager; | 
| import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager; | 
| import org.chromium.chrome.browser.share.ShareHelper; | 
| +import org.chromium.components.variations.VariationsAssociatedData; | 
| +import org.chromium.content.browser.ChildProcessLauncher; | 
| /** | 
| * Handler for application level tasks to be completed on deferred startup. | 
| */ | 
| public class DeferredStartupHandler { | 
| + // Constants for trial of moderate binding support. | 
| + private static final String MODERATE_BINDING_TRIAL_NAME = "MobileModerateBinding"; | 
| + private static final String MODERATE_BINDING_LOW_REDUCE_RATIO_PARAM = "low_reduce_ratio"; | 
| + private static final String MODERATE_BINDING_HIGH_REDUCE_RATIO_PARAM = "high_reduce_ratio"; | 
| + private static final String MODERATE_BINDING_DISABLED_VALUE = "Disabled"; | 
| + private static final float DEFAULUT_MODERATE_BINDING_REDUCE_RATIO = 0.25f; | 
| 
Yaron
2015/06/11 16:54:34
DEFAULT_
 
Jaekyun Seok (inactive)
2015/06/12 06:50:20
Done.
 | 
| + | 
| private static DeferredStartupHandler sDeferredStartupHandler; | 
| private boolean mDeferredStartupComplete; | 
| @@ -105,6 +116,34 @@ public class DeferredStartupHandler { | 
| // Clear any media notifications that existed when Chrome was last killed. | 
| MediaNotificationService.clearMediaNotifications(application); | 
| + String trialName = FieldTrialList.findFullName(MODERATE_BINDING_TRIAL_NAME); | 
| 
Yaron
2015/06/11 16:54:34
extract all this to static helper function
 
Jaekyun Seok (inactive)
2015/06/12 06:50:19
Done.
 | 
| + if (!TextUtils.isEmpty(trialName) | 
| + && !MODERATE_BINDING_DISABLED_VALUE.equalsIgnoreCase(trialName)) { | 
| + String lowReduceRatioValue = VariationsAssociatedData.getVariationParamValue( | 
| + MODERATE_BINDING_TRIAL_NAME, MODERATE_BINDING_LOW_REDUCE_RATIO_PARAM); | 
| + String highReduceRatioValue = VariationsAssociatedData.getVariationParamValue( | 
| + MODERATE_BINDING_TRIAL_NAME, MODERATE_BINDING_HIGH_REDUCE_RATIO_PARAM); | 
| + float lowReduceRatio = DEFAULUT_MODERATE_BINDING_REDUCE_RATIO; | 
| + float highReduceRatio = DEFAULUT_MODERATE_BINDING_REDUCE_RATIO * 2; | 
| + if (!TextUtils.isEmpty(lowReduceRatioValue)) { | 
| + try { | 
| + lowReduceRatio = Float.parseFloat(lowReduceRatioValue); | 
| + } catch (NumberFormatException e) { | 
| + // Ignore exception. | 
| + } | 
| + } | 
| + if (!TextUtils.isEmpty(highReduceRatioValue)) { | 
| + try { | 
| + highReduceRatio = Float.parseFloat(highReduceRatioValue); | 
| + } catch (NumberFormatException e) { | 
| + // Ignore exception. | 
| + } | 
| + } | 
| + if (highReduceRatio > 1f) highReduceRatio = 1f; | 
| + if (lowReduceRatio > highReduceRatio) lowReduceRatio = highReduceRatio; | 
| + ChildProcessLauncher.startModerateBinding(lowReduceRatio, highReduceRatio); | 
| + } | 
| + | 
| mDeferredStartupComplete = true; | 
| } |