Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java |
index b71e2c2d6cef81763a7867617648f20445d9303c..a17a3c86ebe7bad36a745e09109e8c09606592ec 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java |
@@ -37,7 +37,6 @@ import org.chromium.chrome.R; |
import org.chromium.chrome.browser.ChromeApplication; |
import org.chromium.chrome.browser.IntentHandler; |
import org.chromium.chrome.browser.WarmupManager; |
-import org.chromium.chrome.browser.WebContentsFactory; |
import org.chromium.chrome.browser.device.DeviceClassManager; |
import org.chromium.chrome.browser.init.ChromeBrowserInitializer; |
import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; |
@@ -105,7 +104,6 @@ public class CustomTabsConnection { |
private final AtomicBoolean mWarmupHasBeenCalled = new AtomicBoolean(); |
private final AtomicBoolean mWarmupHasBeenFinished = new AtomicBoolean(); |
private ExternalPrerenderHandler mExternalPrerenderHandler; |
- private WebContents mSpareWebContents; |
// TODO(lizeb): Remove once crbug.com/630303 is fixed. |
private boolean mPageLoadMetricsEnabled; |
@@ -221,7 +219,7 @@ public class CustomTabsConnection { |
public void run() { |
if (!initialized) initializeBrowser(mApplication); |
if (mayCreateSpareWebContents && mPrerender == null && !SysUtils.isLowEndDevice()) { |
- createSpareWebContents(); |
+ WarmupManager.getInstance().createSpareWebContents(); |
} |
mWarmupHasBeenFinished.set(true); |
} |
@@ -229,13 +227,6 @@ public class CustomTabsConnection { |
return true; |
} |
- /** Creates a spare {@link WebContents}, if none exists. */ |
- private void createSpareWebContents() { |
- ThreadUtils.assertOnUiThread(); |
- if (mSpareWebContents != null) return; |
- mSpareWebContents = WebContentsFactory.createWebContentsWithWarmRenderer(false, false); |
- } |
- |
/** @return the URL converted to string, or null if it's invalid. */ |
private static String checkAndConvertUri(Uri uri) { |
if (uri == null) return null; |
@@ -270,7 +261,7 @@ public class CustomTabsConnection { |
didStartPrerender = prerenderUrl(session, url, extras, uid); |
} |
preconnectUrls(otherLikelyBundles); |
- if (!didStartPrerender) createSpareWebContents(); |
+ if (!didStartPrerender) WarmupManager.getInstance().createSpareWebContents(); |
} |
/** |
@@ -282,7 +273,7 @@ public class CustomTabsConnection { |
boolean lowConfidenceMayLaunchUrl(List<Bundle> likelyBundles) { |
ThreadUtils.assertOnUiThread(); |
if (!preconnectUrls(likelyBundles)) return false; |
- createSpareWebContents(); |
+ WarmupManager.getInstance().createSpareWebContents(); |
return true; |
} |
@@ -351,20 +342,6 @@ public class CustomTabsConnection { |
return null; |
} |
- /** @return a spare WebContents, or null. */ |
- WebContents takeSpareWebContents() { |
- ThreadUtils.assertOnUiThread(); |
- WebContents result = mSpareWebContents; |
- mSpareWebContents = null; |
- return result; |
- } |
- |
- private void destroySpareWebContents() { |
- ThreadUtils.assertOnUiThread(); |
- WebContents webContents = takeSpareWebContents(); |
- if (webContents != null) webContents.destroy(); |
- } |
- |
public boolean updateVisuals(final CustomTabsSessionToken session, Bundle bundle) { |
final Bundle actionButtonBundle = IntentUtils.safeGetBundle(bundle, |
CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE); |
@@ -744,7 +721,7 @@ public class CustomTabsConnection { |
if (throttle && !mClientManager.isPrerenderingAllowed(uid)) return false; |
// A prerender will be requested. Time to destroy the spare WebContents. |
- destroySpareWebContents(); |
+ WarmupManager.getInstance().destroySpareWebContents(); |
Intent extrasIntent = new Intent(); |
if (extras != null) extrasIntent.putExtras(extras); |
@@ -768,8 +745,6 @@ public class CustomTabsConnection { |
return true; |
} |
- |
- |
@VisibleForTesting |
void resetThrottling(Context context, int uid) { |
mClientManager.resetThrottling(uid); |