Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java

Issue 2748013004: CustomTabs: Base version for prerender switch (Closed)
Patch Set: Tiny rework of startSpeculation Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.customtabs; 5 package org.chromium.chrome.browser.customtabs;
6 6
7 import android.app.ActivityManager; 7 import android.app.ActivityManager;
8 import android.app.Application; 8 import android.app.Application;
9 import android.app.PendingIntent; 9 import android.app.PendingIntent;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 @VisibleForTesting 87 @VisibleForTesting
88 static final int NO_PRERENDERING = 1; 88 static final int NO_PRERENDERING = 1;
89 @VisibleForTesting 89 @VisibleForTesting
90 static final int PREFETCH_ONLY = 2; 90 static final int PREFETCH_ONLY = 2;
91 91
92 private static AtomicReference<CustomTabsConnection> sInstance = new AtomicR eference<>(); 92 private static AtomicReference<CustomTabsConnection> sInstance = new AtomicR eference<>();
93 93
94 /** Holds the parameters for the current speculation. */ 94 /** Holds the parameters for the current speculation. */
95 @VisibleForTesting 95 @VisibleForTesting
96 static final class SpeculationParams { 96 static final class SpeculationParams {
97 @VisibleForTesting
98 static final int NO_SPECULATION = 0;
99 @VisibleForTesting
100 static final int PREFETCH = 1;
101 @VisibleForTesting
102 static final int PRERENDER = 2;
103
97 public final CustomTabsSessionToken session; 104 public final CustomTabsSessionToken session;
98 public final String url; 105 public final String url;
106 public final int speculationMode;
99 107
100 // Only for prerender. 108 // Only for prerender.
101 public final WebContents webContents; 109 public final WebContents webContents;
102 public final String referrer; 110 public final String referrer;
103 public final Bundle extras; 111 public final Bundle extras;
104 112
105 public final boolean prefetchOnly; 113 static SpeculationParams forPrefetch(CustomTabsSessionToken session, Str ing url) {
114 return new SpeculationParams(session, url, PREFETCH, null, null, nul l);
115 }
106 116
107 static SpeculationParams forPrerender(CustomTabsSessionToken session, St ring url, 117 static SpeculationParams forPrerender(CustomTabsSessionToken session, St ring url,
108 WebContents webcontents, String referrer, Bundle extras) { 118 WebContents webcontents, String referrer, Bundle extras) {
109 return new SpeculationParams(session, url, webcontents, referrer, ex tras, false); 119 return new SpeculationParams(session, url, PRERENDER, webcontents, r eferrer, extras);
110 } 120 }
111 121
112 static SpeculationParams forPrefetch(CustomTabsSessionToken session, Str ing url) { 122 private SpeculationParams(CustomTabsSessionToken session, String url, in t speculationMode,
113 return new SpeculationParams(session, url, null, null, null, true); 123 WebContents webContents, String referrer, Bundle extras) {
114 }
115
116 private SpeculationParams(CustomTabsSessionToken session, String url,
117 WebContents webContents, String referrer, Bundle extras, boolean prefetchOnly) {
118 this.session = session; 124 this.session = session;
119 this.url = url; 125 this.url = url;
126 this.speculationMode = speculationMode;
120 this.webContents = webContents; 127 this.webContents = webContents;
121 this.referrer = referrer; 128 this.referrer = referrer;
122 this.extras = extras; 129 this.extras = extras;
123 this.prefetchOnly = prefetchOnly;
124 } 130 }
125 } 131 }
126 132
127 @VisibleForTesting 133 @VisibleForTesting
128 SpeculationParams mSpeculation; 134 SpeculationParams mSpeculation;
129 protected final Application mApplication; 135 protected final Application mApplication;
130 protected final ClientManager mClientManager; 136 protected final ClientManager mClientManager;
131 private final boolean mLogRequests; 137 private final boolean mLogRequests;
132 private final AtomicBoolean mWarmupHasBeenCalled = new AtomicBoolean(); 138 private final AtomicBoolean mWarmupHasBeenCalled = new AtomicBoolean();
133 private final AtomicBoolean mWarmupHasBeenFinished = new AtomicBoolean(); 139 private final AtomicBoolean mWarmupHasBeenFinished = new AtomicBoolean();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 if (mForcePrerenderForTesting) mClientManager.setPrerenderCellularForSes sion(session, true); 188 if (mForcePrerenderForTesting) mClientManager.setPrerenderCellularForSes sion(session, true);
183 logCall("newSession()", success); 189 logCall("newSession()", success);
184 return success; 190 return success;
185 } 191 }
186 192
187 private boolean newSessionInternal(CustomTabsSessionToken session) { 193 private boolean newSessionInternal(CustomTabsSessionToken session) {
188 if (session == null) return false; 194 if (session == null) return false;
189 ClientManager.DisconnectCallback onDisconnect = new ClientManager.Discon nectCallback() { 195 ClientManager.DisconnectCallback onDisconnect = new ClientManager.Discon nectCallback() {
190 @Override 196 @Override
191 public void run(CustomTabsSessionToken session) { 197 public void run(CustomTabsSessionToken session) {
192 cancelPrerender(session); 198 cancelSpeculation(session);
193 } 199 }
194 }; 200 };
195 PostMessageHandler handler = new PostMessageHandler(session); 201 PostMessageHandler handler = new PostMessageHandler(session);
196 return mClientManager.newSession(session, Binder.getCallingUid(), onDisc onnect, handler); 202 return mClientManager.newSession(session, Binder.getCallingUid(), onDisc onnect, handler);
197 } 203 }
198 204
199 /** Warmup activities that should only happen once. */ 205 /** Warmup activities that should only happen once. */
200 @SuppressFBWarnings("DM_EXIT") 206 @SuppressFBWarnings("DM_EXIT")
201 private static void initializeBrowser(final Application app) { 207 private static void initializeBrowser(final Application app) {
202 ThreadUtils.assertOnUiThread(); 208 ThreadUtils.assertOnUiThread();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 /** 314 /**
309 * High confidence mayLaunchUrl() call, that is: 315 * High confidence mayLaunchUrl() call, that is:
310 * - Tries to prerender if possible. 316 * - Tries to prerender if possible.
311 * - An empty URL cancels the current prerender if any. 317 * - An empty URL cancels the current prerender if any.
312 * - If prerendering is not possible, makes sure that there is a spare rende rer. 318 * - If prerendering is not possible, makes sure that there is a spare rende rer.
313 */ 319 */
314 private void highConfidenceMayLaunchUrl(CustomTabsSessionToken session, 320 private void highConfidenceMayLaunchUrl(CustomTabsSessionToken session,
315 int uid, String url, Bundle extras, List<Bundle> otherLikelyBundles) { 321 int uid, String url, Bundle extras, List<Bundle> otherLikelyBundles) {
316 ThreadUtils.assertOnUiThread(); 322 ThreadUtils.assertOnUiThread();
317 if (TextUtils.isEmpty(url)) { 323 if (TextUtils.isEmpty(url)) {
318 cancelPrerender(session); 324 cancelSpeculation(session);
319 return; 325 return;
320 } 326 }
321 327
322 WarmupManager warmupManager = WarmupManager.getInstance();
323 Profile profile = Profile.getLastUsedProfile();
324
325 url = DataReductionProxySettings.getInstance().maybeRewriteWebliteUrl(ur l); 328 url = DataReductionProxySettings.getInstance().maybeRewriteWebliteUrl(ur l);
326 int debugOverrideValue = NO_OVERRIDE; 329 int debugOverrideValue = NO_OVERRIDE;
327 if (extras != null) debugOverrideValue = extras.getInt(DEBUG_OVERRIDE_KE Y, NO_OVERRIDE); 330 if (extras != null) debugOverrideValue = extras.getInt(DEBUG_OVERRIDE_KE Y, NO_OVERRIDE);
328 331
329 boolean didStartPrerender = false, didStartPrefetch = false; 332 int speculationMode = getSpeculationMode(session, debugOverrideValue);
330 boolean mayPrerender = mayPrerender(session); 333 if (maySpeculate(session)) startSpeculation(session, url, speculationMod e, extras, uid);
331 if (mayPrerender) {
332 if (debugOverrideValue == PREFETCH_ONLY) {
333 didStartPrefetch = new ResourcePrefetchPredictor(profile).startP refetching(url);
334 if (didStartPrefetch) mSpeculation = SpeculationParams.forPrefet ch(session, url);
335 } else if (debugOverrideValue != NO_PRERENDERING) {
336 didStartPrerender = prerenderUrl(session, url, extras, uid);
337 }
338 }
339 preconnectUrls(otherLikelyBundles); 334 preconnectUrls(otherLikelyBundles);
340 if (!didStartPrefetch) warmupManager.maybePreconnectUrlAndSubResources(p rofile, url);
341 if (!didStartPrerender) warmupManager.createSpareWebContents();
342 } 335 }
343 336
344 /** 337 /**
345 * Low confidence mayLaunchUrl() call, that is: 338 * Low confidence mayLaunchUrl() call, that is:
346 * - Preconnects to the ordered list of URLs. 339 * - Preconnects to the ordered list of URLs.
347 * - Makes sure that there is a spare renderer. 340 * - Makes sure that there is a spare renderer.
348 */ 341 */
349 @VisibleForTesting 342 @VisibleForTesting
350 boolean lowConfidenceMayLaunchUrl(List<Bundle> likelyBundles) { 343 boolean lowConfidenceMayLaunchUrl(List<Bundle> likelyBundles) {
351 ThreadUtils.assertOnUiThread(); 344 ThreadUtils.assertOnUiThread();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 * @param url The URL the WebContents is for. 573 * @param url The URL the WebContents is for.
581 * @param referrer The referrer to use for |url|. 574 * @param referrer The referrer to use for |url|.
582 * @return The prerendered WebContents, or null. 575 * @return The prerendered WebContents, or null.
583 */ 576 */
584 WebContents takePrerenderedUrl(CustomTabsSessionToken session, String url, S tring referrer) { 577 WebContents takePrerenderedUrl(CustomTabsSessionToken session, String url, S tring referrer) {
585 ThreadUtils.assertOnUiThread(); 578 ThreadUtils.assertOnUiThread();
586 if (mSpeculation == null || session == null || !session.equals(mSpeculat ion.session)) { 579 if (mSpeculation == null || session == null || !session.equals(mSpeculat ion.session)) {
587 return null; 580 return null;
588 } 581 }
589 582
590 if (mSpeculation.prefetchOnly) { 583 if (mSpeculation.speculationMode == SpeculationParams.PREFETCH) {
591 Profile profile = Profile.getLastUsedProfile(); 584 cancelSpeculation(session);
592 new ResourcePrefetchPredictor(profile).stopPrefetching(mSpeculation. url);
593 mSpeculation = null;
594 return null; 585 return null;
595 } 586 }
596 587
597 WebContents webContents = mSpeculation.webContents; 588 WebContents webContents = mSpeculation.webContents;
598 String prerenderedUrl = mSpeculation.url; 589 String prerenderedUrl = mSpeculation.url;
599 String prerenderReferrer = mSpeculation.referrer; 590 String prerenderReferrer = mSpeculation.referrer;
600 if (referrer == null) referrer = ""; 591 if (referrer == null) referrer = "";
601 boolean ignoreFragments = mClientManager.getIgnoreFragmentsForSession(se ssion); 592 boolean ignoreFragments = mClientManager.getIgnoreFragmentsForSession(se ssion);
602 boolean urlsMatch = TextUtils.equals(prerenderedUrl, url) 593 boolean urlsMatch = TextUtils.equals(prerenderedUrl, url)
603 || (ignoreFragments 594 || (ignoreFragments
604 && UrlUtilities.urlsMatchIgnoringFragments(prerenderedUr l, url)); 595 && UrlUtilities.urlsMatchIgnoringFragments(prerenderedUr l, url));
605 WebContents result = null; 596 WebContents result = null;
606 if (urlsMatch && TextUtils.equals(prerenderReferrer, referrer)) { 597 if (urlsMatch && TextUtils.equals(prerenderReferrer, referrer)) {
607 result = webContents; 598 result = webContents;
608 mSpeculation = null; 599 mSpeculation = null;
609 } else { 600 } else {
610 cancelPrerender(session); 601 cancelSpeculation(session);
611 } 602 }
612 if (!mClientManager.usesDefaultSessionParameters(session) && webContents != null) { 603 if (!mClientManager.usesDefaultSessionParameters(session) && webContents != null) {
613 RecordHistogram.recordBooleanHistogram( 604 RecordHistogram.recordBooleanHistogram(
614 "CustomTabs.NonDefaultSessionPrerenderMatched", result != nu ll); 605 "CustomTabs.NonDefaultSessionPrerenderMatched", result != nu ll);
615 } 606 }
616 607
617 return result; 608 return result;
618 } 609 }
619 610
620 /** Returns the URL prerendered for a session, or null. */ 611 /** Returns the URL prerendered for a session, or null. */
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 mClientManager.setPrerenderCellularForSession(session, value); 656 mClientManager.setPrerenderCellularForSession(session, value);
666 } 657 }
667 658
668 /** 659 /**
669 * See {@link ClientManager#setSendNavigationInfoForSession(CustomTabsSessio nToken, boolean)}. 660 * See {@link ClientManager#setSendNavigationInfoForSession(CustomTabsSessio nToken, boolean)}.
670 */ 661 */
671 void setSendNavigationInfoForSession(CustomTabsSessionToken session, boolean send) { 662 void setSendNavigationInfoForSession(CustomTabsSessionToken session, boolean send) {
672 mClientManager.setSendNavigationInfoForSession(session, send); 663 mClientManager.setSendNavigationInfoForSession(session, send);
673 } 664 }
674 665
666 void setSpeculationModeForSession(CustomTabsSessionToken session, int specul ationMode) {
667 mClientManager.setSpeculationModeForSession(session, speculationMode);
668 }
669
670 int getSpeculationModeForSession(CustomTabsSessionToken session) {
671 return mClientManager.getSpeculationModeForSession(session);
672 }
673
675 /** 674 /**
676 * Extracts the creator package name from the intent. 675 * Extracts the creator package name from the intent.
677 * @param intent The intent to get the package name from. 676 * @param intent The intent to get the package name from.
678 * @return the package name which can be null. 677 * @return the package name which can be null.
679 */ 678 */
680 String extractCreatorPackage(Intent intent) { 679 String extractCreatorPackage(Intent intent) {
681 return null; 680 return null;
682 } 681 }
683 682
684 /** 683 /**
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 @VisibleForTesting 879 @VisibleForTesting
881 void cleanUpSession(final CustomTabsSessionToken session) { 880 void cleanUpSession(final CustomTabsSessionToken session) {
882 ThreadUtils.runOnUiThread(new Runnable() { 881 ThreadUtils.runOnUiThread(new Runnable() {
883 @Override 882 @Override
884 public void run() { 883 public void run() {
885 mClientManager.cleanupSession(session); 884 mClientManager.cleanupSession(session);
886 } 885 }
887 }); 886 });
888 } 887 }
889 888
890 private boolean mayPrerender(CustomTabsSessionToken session) { 889 private boolean maySpeculate(CustomTabsSessionToken session) {
891 if (!DeviceClassManager.enablePrerendering()) return false; 890 if (!DeviceClassManager.enablePrerendering()) return false;
892 // TODO(yusufo): The check for prerender in PrivacyManager now checks fo r the network 891 // TODO(yusufo): The check for prerender in PrivacyManager now checks fo r the network
893 // connection type as well, we should either change that or add another check for custom 892 // connection type as well, we should either change that or add another check for custom
894 // tabs. Then PrivacyManager should be used to make the below check. 893 // tabs. Then PrivacyManager should be used to make the below check.
895 if (!PrefServiceBridge.getInstance().getNetworkPredictionEnabled()) retu rn false; 894 if (!PrefServiceBridge.getInstance().getNetworkPredictionEnabled()) retu rn false;
896 if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled ()) return false; 895 if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled ()) return false;
897 ConnectivityManager cm = 896 ConnectivityManager cm =
898 (ConnectivityManager) mApplication.getApplicationContext().getSy stemService( 897 (ConnectivityManager) mApplication.getApplicationContext().getSy stemService(
899 Context.CONNECTIVITY_SERVICE); 898 Context.CONNECTIVITY_SERVICE);
900 return !cm.isActiveNetworkMetered() || shouldPrerenderOnCellularForSessi on(session); 899 return !cm.isActiveNetworkMetered() || shouldPrerenderOnCellularForSessi on(session);
901 } 900 }
902 901
903 /** Cancels a prerender for a given session, or any session if null. */ 902 /** Cancels the speculation for a given session, or any session if null. */
904 void cancelPrerender(CustomTabsSessionToken session) { 903 void cancelSpeculation(CustomTabsSessionToken session) {
905 ThreadUtils.assertOnUiThread(); 904 ThreadUtils.assertOnUiThread();
906 if (mSpeculation != null && (session == null || session.equals(mSpeculat ion.session)) 905 if (mSpeculation == null) return;
907 && mSpeculation.webContents != null) { 906 if (session == null || session.equals(mSpeculation.session)) {
908 mExternalPrerenderHandler.cancelCurrentPrerender(); 907 switch (mSpeculation.speculationMode) {
909 mSpeculation.webContents.destroy(); 908 case SpeculationParams.PRERENDER:
909 if (mSpeculation.webContents == null) return;
910 mExternalPrerenderHandler.cancelCurrentPrerender();
911 mSpeculation.webContents.destroy();
912 break;
913 case SpeculationParams.PREFETCH:
914 Profile profile = Profile.getLastUsedProfile();
915 new ResourcePrefetchPredictor(profile).stopPrefetching(mSpec ulation.url);
916 break;
917 default:
918 return;
919 }
910 mSpeculation = null; 920 mSpeculation = null;
911 } 921 }
912 } 922 }
913 923
924 /*
925 * This function will do as much as it can to have a subsequent navigation
926 * to the specified url sped up.
927 */
928 private void startSpeculation(CustomTabsSessionToken session, String url, in t speculationMode,
929 Bundle extras, int uid) {
930 WarmupManager warmupManager = WarmupManager.getInstance();
931 Profile profile = Profile.getLastUsedProfile();
932 boolean preconnect = true, createSpareWebContents = true;
933 switch (speculationMode) {
934 case SpeculationParams.PREFETCH:
935 boolean didPrefetch = new ResourcePrefetchPredictor(profile).sta rtPrefetching(url);
936 if (didPrefetch) mSpeculation = SpeculationParams.forPrefetch(se ssion, url);
937 preconnect = !didPrefetch;
938 break;
939 case SpeculationParams.PRERENDER:
940 boolean didPrerender = prerenderUrl(session, url, extras, uid);
941 createSpareWebContents = !didPrerender;
942 break;
943 default:
944 break;
945 }
946 if (preconnect) warmupManager.maybePreconnectUrlAndSubResources(profile, url);
947 if (createSpareWebContents) warmupManager.createSpareWebContents();
948 }
949
914 /** 950 /**
915 * Tries to request a prerender for a given URL. 951 * Tries to request a prerender for a given URL.
916 * 952 *
917 * @param session Session the request comes from. 953 * @param session Session the request comes from.
918 * @param url URL to prerender. 954 * @param url URL to prerender.
919 * @param extras extra parameters. 955 * @param extras extra parameters.
920 * @param uid UID of the caller. 956 * @param uid UID of the caller.
921 * @return true if a prerender has been initiated. 957 * @return true if a prerender has been initiated.
922 */ 958 */
923 private boolean prerenderUrl( 959 private boolean prerenderUrl(
924 CustomTabsSessionToken session, String url, Bundle extras, int uid) { 960 CustomTabsSessionToken session, String url, Bundle extras, int uid) {
925 ThreadUtils.assertOnUiThread(); 961 ThreadUtils.assertOnUiThread();
926 // Ignores mayPrerender() for an empty URL, since it cancels an existing prerender.
927 if (!mayPrerender(session) && !TextUtils.isEmpty(url)) return false;
928 if (!mWarmupHasBeenCalled.get()) return false; 962 if (!mWarmupHasBeenCalled.get()) return false;
929 // Last one wins and cancels the previous prerender. 963
930 cancelPrerender(null);
931 if (TextUtils.isEmpty(url)) return false;
932 boolean throttle = !shouldPrerenderOnCellularForSession(session); 964 boolean throttle = !shouldPrerenderOnCellularForSession(session);
933 if (throttle && !mClientManager.isPrerenderingAllowed(uid)) return false ; 965 if (throttle && !mClientManager.isPrerenderingAllowed(uid)) return false ;
934 966
935 // A prerender will be requested. Time to destroy the spare WebContents. 967 // A prerender will be requested. Time to destroy the spare WebContents.
936 WarmupManager.getInstance().destroySpareWebContents(); 968 WarmupManager.getInstance().destroySpareWebContents();
937 969
938 Intent extrasIntent = new Intent(); 970 Intent extrasIntent = new Intent();
939 if (extras != null) extrasIntent.putExtras(extras); 971 if (extras != null) extrasIntent.putExtras(extras);
940 if (IntentHandler.getExtraHeadersFromIntent(extrasIntent) != null) retur n false; 972 if (IntentHandler.getExtraHeadersFromIntent(extrasIntent) != null) retur n false;
941 if (mExternalPrerenderHandler == null) { 973 if (mExternalPrerenderHandler == null) {
942 mExternalPrerenderHandler = new ExternalPrerenderHandler(); 974 mExternalPrerenderHandler = new ExternalPrerenderHandler();
943 } 975 }
944 Rect contentBounds = ExternalPrerenderHandler.estimateContentSize(mAppli cation, true); 976 Rect contentBounds = ExternalPrerenderHandler.estimateContentSize(mAppli cation, true);
945 String referrer = IntentHandler.getReferrerUrlIncludingExtraHeaders(extr asIntent); 977 String referrer = IntentHandler.getReferrerUrlIncludingExtraHeaders(extr asIntent);
946 if (referrer == null && getReferrerForSession(session) != null) { 978 if (referrer == null && getReferrerForSession(session) != null) {
947 referrer = getReferrerForSession(session).getUrl(); 979 referrer = getReferrerForSession(session).getUrl();
948 } 980 }
949 if (referrer == null) referrer = ""; 981 if (referrer == null) referrer = "";
950 Pair<WebContents, WebContents> webContentsPair = mExternalPrerenderHandl er.addPrerender( 982 Pair<WebContents, WebContents> webContentsPair =
951 Profile.getLastUsedProfile(), url, referrer, 983 mExternalPrerenderHandler.addPrerender(Profile.getLastUsedProfil e(), url, referrer,
952 contentBounds, 984 contentBounds, shouldPrerenderOnCellularForSession(sessi on));
953 shouldPrerenderOnCellularForSession(session));
954 if (webContentsPair == null) return false; 985 if (webContentsPair == null) return false;
955 WebContents dummyWebContents = webContentsPair.first; 986 WebContents dummyWebContents = webContentsPair.first;
956 if (webContentsPair.second != null) { 987 if (webContentsPair.second != null) {
957 mClientManager.resetPostMessageHandlerForSession(session, webContent sPair.second); 988 mClientManager.resetPostMessageHandlerForSession(session, webContent sPair.second);
958 } 989 }
959 if (throttle) mClientManager.registerPrerenderRequest(uid, url); 990 if (throttle) mClientManager.registerPrerenderRequest(uid, url);
960 mSpeculation = SpeculationParams.forPrerender( 991 mSpeculation =
961 session, url, dummyWebContents, referrer, extras); 992 SpeculationParams.forPrerender(session, url, dummyWebContents, r eferrer, extras);
962 993
963 RecordHistogram.recordBooleanHistogram("CustomTabs.PrerenderSessionUsesD efaultParameters", 994 RecordHistogram.recordBooleanHistogram("CustomTabs.PrerenderSessionUsesD efaultParameters",
964 mClientManager.usesDefaultSessionParameters(session)); 995 mClientManager.usesDefaultSessionParameters(session));
965 996
966 return true; 997 return true;
967 } 998 }
968 999
969 @VisibleForTesting 1000 @VisibleForTesting
970 void resetThrottling(Context context, int uid) { 1001 void resetThrottling(Context context, int uid) {
971 mClientManager.resetThrottling(uid); 1002 mClientManager.resetThrottling(uid);
972 } 1003 }
973 1004
974 @VisibleForTesting 1005 @VisibleForTesting
975 void ban(Context context, int uid) { 1006 void ban(Context context, int uid) {
976 mClientManager.ban(uid); 1007 mClientManager.ban(uid);
977 } 1008 }
978 1009
979 @VisibleForTesting 1010 @VisibleForTesting
980 void setForcePrerender(boolean force) { 1011 void setForcePrerender(boolean force) {
981 mForcePrerenderForTesting = force; 1012 mForcePrerenderForTesting = force;
982 } 1013 }
1014
1015 private int getSpeculationMode(CustomTabsSessionToken session, int debugOver rideValue) {
1016 switch (debugOverrideValue) {
1017 case PREFETCH_ONLY:
1018 return SpeculationParams.PREFETCH;
1019 case NO_PRERENDERING:
1020 return SpeculationParams.NO_SPECULATION;
1021 default:
1022 return getSpeculationModeForSession(session);
1023 }
1024 }
983 } 1025 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698