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

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

Issue 2929113002: Enable spare RenderProcessHost to be preinitialized. (Closed)
Patch Set: Change creation of storage partition to not break unittests with subtle threading issues 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.net.Uri;
10 import android.os.AsyncTask; 10 import android.os.AsyncTask;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if (mDnsRequestsInFlight.contains(url)) { 248 if (mDnsRequestsInFlight.contains(url)) {
249 // Note that if two requests come for the same URL with two differen t profiles, the last 249 // Note that if two requests come for the same URL with two differen t profiles, the last
250 // one will win. 250 // one will win.
251 mPendingPreconnectWithProfile.put(url, profile); 251 mPendingPreconnectWithProfile.put(url, profile);
252 } else { 252 } else {
253 nativePreconnectUrlAndSubresources(profile, url); 253 nativePreconnectUrlAndSubresources(profile, url);
254 } 254 }
255 } 255 }
256 256
257 /** 257 /**
258 * Warms up a spare, empty RenderProcessHost that may be used for subsequent navigations.
259 *
260 * The spare RenderProcessHost will be used automatically in subsequent navi gations.
261 * There is nothing further the WarmupManager needs to do to enable that use .
262 *
263 * This uses a different mechanism than createSpareWebContents, below, and i s subject
264 * to fewer restrictions.
265 *
266 * This must be called from the UI thread.
267 */
268 public void createSpareRenderProcessHost(Profile profile) {
269 ThreadUtils.assertOnUiThread();
270 if (ChromeFeatureList.isEnabled(ChromeFeatureList.OMNIBOX_SPARE_RENDERER )) {
271 // Spare WebContents should not be used with spare RenderProcessHost s, but if one
272 // has been created, destroy it in order not to consume too many pro cesses.
273 destroySpareWebContents();
274 nativeWarmupSpareRenderer(profile);
275 }
276 }
277
278 /**
258 * Creates and initializes a spare WebContents, to be used in a subsequent n avigation. 279 * Creates and initializes a spare WebContents, to be used in a subsequent n avigation.
259 * 280 *
260 * This creates a renderer that is suitable for any navigation. It can be pi cked up by any tab. 281 * This creates a renderer that is suitable for any navigation. It can be pi cked up by any tab.
261 * Can be called multiple times, and must be called from the UI thread. 282 * Can be called multiple times, and must be called from the UI thread.
262 * Note that this is a no-op on low-end devices. 283 * Note that this is a no-op on low-end devices.
263 */ 284 */
264 public void createSpareWebContents() { 285 public void createSpareWebContents() {
265 ThreadUtils.assertOnUiThread(); 286 ThreadUtils.assertOnUiThread();
266 if (mSpareWebContents != null || SysUtils.isLowEndDevice()) return; 287 if (mSpareWebContents != null || SysUtils.isLowEndDevice()) return;
267 mSpareWebContents = WebContentsFactory.createWebContentsWithWarmRenderer (false, false); 288 mSpareWebContents = WebContentsFactory.createWebContentsWithWarmRenderer (false, false);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 mSpareWebContents = null; 334 mSpareWebContents = null;
314 mObserver = null; 335 mObserver = null;
315 } 336 }
316 337
317 private static void recordWebContentsStatus(int status) { 338 private static void recordWebContentsStatus(int status) {
318 RecordHistogram.recordEnumeratedHistogram( 339 RecordHistogram.recordEnumeratedHistogram(
319 WEBCONTENTS_STATUS_HISTOGRAM, status, WEBCONTENTS_STATUS_COUNT); 340 WEBCONTENTS_STATUS_HISTOGRAM, status, WEBCONTENTS_STATUS_COUNT);
320 } 341 }
321 342
322 private static native void nativePreconnectUrlAndSubresources(Profile profil e, String url); 343 private static native void nativePreconnectUrlAndSubresources(Profile profil e, String url);
344 private static native void nativeWarmupSpareRenderer(Profile profile);
323 } 345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698