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

Side by Side 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 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; 5 package org.chromium.chrome.browser;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.Context; 8 import android.content.Context;
9 import android.net.Uri;
9 import android.os.AsyncTask; 10 import android.os.AsyncTask;
10 import android.os.StrictMode; 11 import android.os.StrictMode;
11 import android.os.SystemClock; 12 import android.os.SystemClock;
12 import android.view.ContextThemeWrapper; 13 import android.view.ContextThemeWrapper;
13 import android.view.InflateException; 14 import android.view.InflateException;
14 import android.view.LayoutInflater; 15 import android.view.LayoutInflater;
15 import android.view.View; 16 import android.view.View;
16 import android.view.ViewGroup; 17 import android.view.ViewGroup;
17 import android.view.ViewStub; 18 import android.view.ViewStub;
18 import android.widget.FrameLayout; 19 import android.widget.FrameLayout;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 221 }
221 } 222 }
222 223
223 /** Asynchronously preconnects to a given URL if the data reduction proxy is not in use. 224 /** Asynchronously preconnects to a given URL if the data reduction proxy is not in use.
224 * 225 *
225 * @param profile The profile to use for the preconnection. 226 * @param profile The profile to use for the preconnection.
226 * @param url The URL we want to preconnect to. 227 * @param url The URL we want to preconnect to.
227 */ 228 */
228 public void maybePreconnectUrlAndSubResources(Profile profile, String url) { 229 public void maybePreconnectUrlAndSubResources(Profile profile, String url) {
229 ThreadUtils.assertOnUiThread(); 230 ThreadUtils.assertOnUiThread();
230 if (!DataReductionProxySettings.getInstance().isDataReductionProxyEnable d()) { 231
231 // If there is already a DNS request in flight for this URL, then 232 Uri uri = Uri.parse(url);
232 // the preconnection will start by issuing a DNS request for the 233 if (uri == null) return;
233 // same domain, as the result is not cached. However, such a DNS 234 // HTTP connections will not be used when the data reduction proxy is en abled.
234 // request has already been sent from this class, so it is better to 235 if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled ()
235 // wait for the answer to come back before preconnecting. Otherwise, 236 && UrlConstants.HTTP_SCHEME.equals(uri.normalizeScheme().getSche me())) {
236 // the preconnection logic will wait for the result of the second 237 return;
237 // DNS request, which should arrive after the result of the first 238 }
238 // one. Note that we however need to wait for the main thread to be 239
239 // available in this case, since the preconnection will be sent from 240 // If there is already a DNS request in flight for this URL, then the pr econnection will
240 // AsyncTask.onPostExecute(), which may delay it. 241 // start by issuing a DNS request for the same domain, as the result is not cached. However,
241 if (mDnsRequestsInFlight.contains(url)) { 242 // such a DNS request has already been sent from this class, so it is be tter to wait for the
242 // Note that if two requests come for the same URL with two 243 // answer to come back before preconnecting. Otherwise, the preconnectio n logic will wait
243 // different profiles, the last one will win. 244 // for the result of the second DNS request, which should arrive after t he result of the
244 mPendingPreconnectWithProfile.put(url, profile); 245 // first one. Note that we however need to wait for the main thread to b e available in this
245 } else { 246 // case, since the preconnection will be sent from AsyncTask.onPostExecu te(), which may
246 nativePreconnectUrlAndSubresources(profile, url); 247 // delay it.
247 } 248 if (mDnsRequestsInFlight.contains(url)) {
249 // Note that if two requests come for the same URL with two differen t profiles, the last
250 // one will win.
251 mPendingPreconnectWithProfile.put(url, profile);
252 } else {
253 nativePreconnectUrlAndSubresources(profile, url);
248 } 254 }
249 } 255 }
250 256
251 /** 257 /**
252 * Creates and initializes a spare WebContents, to be used in a subsequent n avigation. 258 * Creates and initializes a spare WebContents, to be used in a subsequent n avigation.
253 * 259 *
254 * This creates a renderer that is suitable for any navigation. It can be pi cked up by any tab. 260 * This creates a renderer that is suitable for any navigation. It can be pi cked up by any tab.
255 * Can be called multiple times, and must be called from the UI thread. 261 * Can be called multiple times, and must be called from the UI thread.
256 * Note that this is a no-op on low-end devices. 262 * Note that this is a no-op on low-end devices.
257 */ 263 */
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 mObserver = null; 314 mObserver = null;
309 } 315 }
310 316
311 private static void recordWebContentsStatus(int status) { 317 private static void recordWebContentsStatus(int status) {
312 RecordHistogram.recordEnumeratedHistogram( 318 RecordHistogram.recordEnumeratedHistogram(
313 WEBCONTENTS_STATUS_HISTOGRAM, status, WEBCONTENTS_STATUS_COUNT); 319 WEBCONTENTS_STATUS_HISTOGRAM, status, WEBCONTENTS_STATUS_COUNT);
314 } 320 }
315 321
316 private static native void nativePreconnectUrlAndSubresources(Profile profil e, String url); 322 private static native void nativePreconnectUrlAndSubresources(Profile profil e, String url);
317 } 323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698