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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/ClientManager.java

Issue 2748013004: CustomTabs: Base version for prerender switch (Closed)
Patch Set: Tiny rework of startSpeculation Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/ClientManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ClientManager.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ClientManager.java
index 212f0ef590ac27fc24a108704e65a6e4995cdbff..86c7219a3508ac89ba69fac1d4d3714875467eaf 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ClientManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/ClientManager.java
@@ -131,6 +131,7 @@ class ClientManager {
private KeepAliveServiceConnection mKeepAliveConnection;
private String mPredictedUrl;
private long mLastMayLaunchUrlTimestamp;
+ private int mSpeculationMode;
public SessionParams(Context context, int uid, DisconnectCallback callback,
PostMessageHandler postMessageHandler) {
@@ -138,6 +139,7 @@ class ClientManager {
packageName = getPackageName(context, uid);
disconnectCallback = callback;
this.postMessageHandler = postMessageHandler;
+ this.mSpeculationMode = CustomTabsConnection.SpeculationParams.PRERENDER;
}
private static String getPackageName(Context context, int uid) {
@@ -450,6 +452,25 @@ class ClientManager {
if (params != null) params.mShouldPrerenderOnCellular = prerender;
}
+ /**
+ * Sets the speculation mode to be used by default for given session.
+ */
+ public synchronized void setSpeculationModeForSession(
+ CustomTabsSessionToken session, int speculationMode) {
+ SessionParams params = mSessionParams.get(session);
+ if (params != null) params.mSpeculationMode = speculationMode;
+ }
+
+ /**
+ * Get the speculation mode to be used by default for the given session.
+ * If no value has been set will default to PRERENDER mode.
+ */
+ public synchronized int getSpeculationModeForSession(CustomTabsSessionToken session) {
+ SessionParams params = mSessionParams.get(session);
+ return params == null ? CustomTabsConnection.SpeculationParams.PRERENDER
+ : params.mSpeculationMode;
+ }
+
/** Tries to bind to a client to keep it alive, and returns true for success. */
public synchronized boolean keepAliveForSession(CustomTabsSessionToken session, Intent intent) {
// When an application is bound to a service, its priority is raised to
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698