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

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: . 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;
13 import android.text.TextUtils;
12 import android.view.ContextThemeWrapper; 14 import android.view.ContextThemeWrapper;
13 import android.view.InflateException; 15 import android.view.InflateException;
14 import android.view.LayoutInflater; 16 import android.view.LayoutInflater;
15 import android.view.View; 17 import android.view.View;
16 import android.view.ViewGroup; 18 import android.view.ViewGroup;
17 import android.view.ViewStub; 19 import android.view.ViewStub;
18 import android.widget.FrameLayout; 20 import android.widget.FrameLayout;
19 21
20 import org.chromium.base.Log; 22 import org.chromium.base.Log;
21 import org.chromium.base.SysUtils; 23 import org.chromium.base.SysUtils;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 222 }
221 } 223 }
222 224
223 /** Asynchronously preconnects to a given URL if the data reduction proxy is not in use. 225 /** Asynchronously preconnects to a given URL if the data reduction proxy is not in use.
224 * 226 *
225 * @param profile The profile to use for the preconnection. 227 * @param profile The profile to use for the preconnection.
226 * @param url The URL we want to preconnect to. 228 * @param url The URL we want to preconnect to.
227 */ 229 */
228 public void maybePreconnectUrlAndSubResources(Profile profile, String url) { 230 public void maybePreconnectUrlAndSubResources(Profile profile, String url) {
229 ThreadUtils.assertOnUiThread(); 231 ThreadUtils.assertOnUiThread();
230 if (!DataReductionProxySettings.getInstance().isDataReductionProxyEnable d()) { 232
231 // If there is already a DNS request in flight for this URL, then 233 Uri uri = Uri.parse(url);
232 // the preconnection will start by issuing a DNS request for the 234 if (uri == null) return;
233 // same domain, as the result is not cached. However, such a DNS 235 // 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 236 if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled ()
235 // wait for the answer to come back before preconnecting. Otherwise, 237 && TextUtils.equals(UrlConstants.HTTP_SCHEME, uri.normalizeSchem e().getScheme())) {
Bernhard Bauer 2017/07/10 12:13:44 Nit: TextUtils.equals feels like overkill here --
Benoit L 2017/07/10 12:35:38 Done.
236 // the preconnection logic will wait for the result of the second 238 return;
237 // DNS request, which should arrive after the result of the first 239 }
238 // one. Note that we however need to wait for the main thread to be 240
239 // available in this case, since the preconnection will be sent from 241 // If there is already a DNS request in flight for this URL, then the pr econnection will
240 // AsyncTask.onPostExecute(), which may delay it. 242 // start by issuing a DNS request for the same domain, as the result is not cached. However,
241 if (mDnsRequestsInFlight.contains(url)) { 243 // 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 244 // answer to come back before preconnecting. Otherwise, the preconnectio n logic will wait
243 // different profiles, the last one will win. 245 // for the result of the second DNS request, which should arrive after t he result of the
244 mPendingPreconnectWithProfile.put(url, profile); 246 // first one. Note that we however need to wait for the main thread to b e available in this
245 } else { 247 // case, since the preconnection will be sent from AsyncTask.onPostExecu te(), which may
246 nativePreconnectUrlAndSubresources(profile, url); 248 // delay it.
247 } 249 if (mDnsRequestsInFlight.contains(url)) {
250 // Note that if two requests come for the same URL with two differen t profiles, the last
251 // one will win.
252 mPendingPreconnectWithProfile.put(url, profile);
253 } else {
254 nativePreconnectUrlAndSubresources(profile, url);
248 } 255 }
249 } 256 }
250 257
251 /** 258 /**
252 * Creates and initializes a spare WebContents, to be used in a subsequent n avigation. 259 * Creates and initializes a spare WebContents, to be used in a subsequent n avigation.
253 * 260 *
254 * This creates a renderer that is suitable for any navigation. It can be pi cked up by any tab. 261 * 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. 262 * 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. 263 * Note that this is a no-op on low-end devices.
257 */ 264 */
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 mObserver = null; 315 mObserver = null;
309 } 316 }
310 317
311 private static void recordWebContentsStatus(int status) { 318 private static void recordWebContentsStatus(int status) {
312 RecordHistogram.recordEnumeratedHistogram( 319 RecordHistogram.recordEnumeratedHistogram(
313 WEBCONTENTS_STATUS_HISTOGRAM, status, WEBCONTENTS_STATUS_COUNT); 320 WEBCONTENTS_STATUS_HISTOGRAM, status, WEBCONTENTS_STATUS_COUNT);
314 } 321 }
315 322
316 private static native void nativePreconnectUrlAndSubresources(Profile profil e, String url); 323 private static native void nativePreconnectUrlAndSubresources(Profile profil e, String url);
317 } 324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698