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

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

Issue 2970003003: customtabs: Extract a redirect endpoint, and maybe connect to it. (Closed)
Patch Set: Typo. Created 3 years, 5 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
Index: chrome/android/java/src/org/chromium/chrome/browser/WarmupManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/WarmupManager.java b/chrome/android/java/src/org/chromium/chrome/browser/WarmupManager.java
index 7c6ccb38bc737891664f5ace3b09ebee4922aeba..5dbfe4437126df8340fa28a92fa3806cee9ed633 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/WarmupManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/WarmupManager.java
@@ -6,6 +6,7 @@ package org.chromium.chrome.browser;
import android.annotation.SuppressLint;
import android.content.Context;
+import android.net.Uri;
import android.os.AsyncTask;
import android.os.StrictMode;
import android.os.SystemClock;
@@ -227,24 +228,29 @@ public final class WarmupManager {
*/
public void maybePreconnectUrlAndSubResources(Profile profile, String url) {
ThreadUtils.assertOnUiThread();
- if (!DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()) {
- // If there is already a DNS request in flight for this URL, then
- // the preconnection will start by issuing a DNS request for the
- // same domain, as the result is not cached. However, such a DNS
- // request has already been sent from this class, so it is better to
- // wait for the answer to come back before preconnecting. Otherwise,
- // the preconnection logic will wait for the result of the second
- // DNS request, which should arrive after the result of the first
- // one. Note that we however need to wait for the main thread to be
- // available in this case, since the preconnection will be sent from
- // AsyncTask.onPostExecute(), which may delay it.
- if (mDnsRequestsInFlight.contains(url)) {
- // Note that if two requests come for the same URL with two
- // different profiles, the last one will win.
- mPendingPreconnectWithProfile.put(url, profile);
- } else {
- nativePreconnectUrlAndSubresources(profile, url);
- }
+
+ Uri uri = Uri.parse(url);
+ if (uri == null) return;
+ // HTTP connections will not be used when the data reduction proxy is enabled.
+ if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()
+ && UrlConstants.HTTP_SCHEME.equals(uri.normalizeScheme().getScheme())) {
+ return;
+ }
+
+ // If there is already a DNS request in flight for this URL, then the preconnection will
+ // start by issuing a DNS request for the same domain, as the result is not cached. However,
+ // such a DNS request has already been sent from this class, so it is better to wait for the
+ // answer to come back before preconnecting. Otherwise, the preconnection logic will wait
+ // for the result of the second DNS request, which should arrive after the result of the
+ // first one. Note that we however need to wait for the main thread to be available in this
+ // case, since the preconnection will be sent from AsyncTask.onPostExecute(), which may
+ // delay it.
+ if (mDnsRequestsInFlight.contains(url)) {
+ // Note that if two requests come for the same URL with two different profiles, the last
+ // one will win.
+ mPendingPreconnectWithProfile.put(url, profile);
+ } else {
+ nativePreconnectUrlAndSubresources(profile, url);
}
}

Powered by Google App Engine
This is Rietveld 408576698