Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.os.AsyncTask; | 9 import android.os.AsyncTask; |
| 10 import android.os.StrictMode; | 10 import android.os.StrictMode; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 // Note that if two requests come for the same URL with two | 242 // Note that if two requests come for the same URL with two |
| 243 // different profiles, the last one will win. | 243 // different profiles, the last one will win. |
| 244 mPendingPreconnectWithProfile.put(url, profile); | 244 mPendingPreconnectWithProfile.put(url, profile); |
| 245 } else { | 245 } else { |
| 246 nativePreconnectUrlAndSubresources(profile, url); | 246 nativePreconnectUrlAndSubresources(profile, url); |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 | 250 |
| 251 /** | 251 /** |
| 252 * Warms up a spare, empty RenderProcessHost that may be used for subsequent navigations. | |
| 253 * | |
| 254 * The spare RenderProcessHost will be used automatically in subsequent navi gations. | |
| 255 * There is nothing further the WarmupManager needs to do to enable that use . | |
| 256 * | |
| 257 * This uses a different mechanism than createSpareWebContents, below, and i s subject | |
| 258 * to fewer restrictions. | |
| 259 * | |
| 260 * This must be called from the UI thread. | |
| 261 */ | |
| 262 public void createSpareRenderProcessHost(Profile profile) { | |
| 263 ThreadUtils.assertOnUiThread(); | |
|
Ted C
2017/06/30 16:16:56
should we be excluding low end devices here?
i.e.
mattcary
2017/07/03 08:03:02
We manage the logic on when to create a spare rend
Ted C
2017/07/05 03:54:05
I looked at that as well, and I'm not seeing where
| |
| 264 // Spare WebContents should not be used with spare RenderProcessHosts, b ut if one | |
| 265 // has been created, destroy it in order not to consume too many process es. | |
| 266 destroySpareWebContents(); | |
| 267 nativeWarmupSpareRenderer(profile); | |
| 268 } | |
| 269 | |
| 270 /** | |
| 252 * Creates and initializes a spare WebContents, to be used in a subsequent n avigation. | 271 * Creates and initializes a spare WebContents, to be used in a subsequent n avigation. |
| 253 * | 272 * |
| 254 * This creates a renderer that is suitable for any navigation. It can be pi cked up by any tab. | 273 * 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. | 274 * 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. | 275 * Note that this is a no-op on low-end devices. |
| 257 */ | 276 */ |
| 258 public void createSpareWebContents() { | 277 public void createSpareWebContents() { |
| 259 ThreadUtils.assertOnUiThread(); | 278 ThreadUtils.assertOnUiThread(); |
| 260 if (mSpareWebContents != null || SysUtils.isLowEndDevice()) return; | 279 if (mSpareWebContents != null || SysUtils.isLowEndDevice()) return; |
| 261 mSpareWebContents = WebContentsFactory.createWebContentsWithWarmRenderer (false, false); | 280 mSpareWebContents = WebContentsFactory.createWebContentsWithWarmRenderer (false, false); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 mSpareWebContents = null; | 326 mSpareWebContents = null; |
| 308 mObserver = null; | 327 mObserver = null; |
| 309 } | 328 } |
| 310 | 329 |
| 311 private static void recordWebContentsStatus(int status) { | 330 private static void recordWebContentsStatus(int status) { |
| 312 RecordHistogram.recordEnumeratedHistogram( | 331 RecordHistogram.recordEnumeratedHistogram( |
| 313 WEBCONTENTS_STATUS_HISTOGRAM, status, WEBCONTENTS_STATUS_COUNT); | 332 WEBCONTENTS_STATUS_HISTOGRAM, status, WEBCONTENTS_STATUS_COUNT); |
| 314 } | 333 } |
| 315 | 334 |
| 316 private static native void nativePreconnectUrlAndSubresources(Profile profil e, String url); | 335 private static native void nativePreconnectUrlAndSubresources(Profile profil e, String url); |
| 336 private static native void nativeWarmupSpareRenderer(Profile profile); | |
| 317 } | 337 } |
| OLD | NEW |