| Index: content/public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java b/content/public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java
|
| index d4dd6f06e5c6ca3af6b930b5c095d851494f8fd4..f9871f77a15acb1c9e4a865e34c095b576b02cc6 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Copyright 2012 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -13,35 +13,13 @@ import org.chromium.content.app.ContentMain;
|
| import org.chromium.content.app.LibraryLoader;
|
| import org.chromium.content.common.ProcessInitException;
|
|
|
| -// NOTE: This file hasn't been fully upstreamed, please don't merge to downstream.
|
| @JNINamespace("content")
|
| public class AndroidBrowserProcess {
|
| -
|
| private static final String TAG = "BrowserProcessMain";
|
|
|
| // Prevents initializing the process more than once.
|
| private static boolean sInitialized = false;
|
|
|
| - // Computes the actual max renderer processes used.
|
| - private static int normalizeMaxRendererProcesses(Context context, int maxRendererProcesses) {
|
| - if (maxRendererProcesses == MAX_RENDERERS_AUTOMATIC) {
|
| - // We use the device's memory class to decide the maximum renderer
|
| - // processes. For the baseline devices the memory class is 16 and we will
|
| - // limit it to one render process. For the devices with memory class 24,
|
| - // we allow two render processes.
|
| - ActivityManager am = (ActivityManager)context.getSystemService(
|
| - Context.ACTIVITY_SERVICE);
|
| - maxRendererProcesses = Math.max(((am.getMemoryClass() - 8) / 8), 1);
|
| - }
|
| - if (maxRendererProcesses > MAX_RENDERERS_LIMIT) {
|
| - Log.w(TAG, "Excessive maxRendererProcesses value: " + maxRendererProcesses);
|
| - return MAX_RENDERERS_LIMIT;
|
| - }
|
| - return Math.max(0, maxRendererProcesses);
|
| - }
|
| -
|
| - // Automatically decide the number of renderer processes to use based on device memory class.
|
| - public static final int MAX_RENDERERS_AUTOMATIC = -1;
|
| // Use single-process mode that runs the renderer on a separate thread in the main application.
|
| public static final int MAX_RENDERERS_SINGLE_PROCESS = 0;
|
|
|
| @@ -64,39 +42,36 @@ public class AndroidBrowserProcess {
|
| * @param maxRendererProcesses Limit on the number of renderers to use. Each tab runs in its own
|
| * process until the maximum number of processes is reached. The special value of
|
| * MAX_RENDERERS_SINGLE_PROCESS requests single-process mode where the renderer will run in the
|
| - * application process in a separate thread. If the special value MAX_RENDERERS_AUTOMATIC is
|
| - * used then the number of renderers will be determined based on the device memory class. The
|
| - * maximum number of allowed renderers is capped by MAX_RENDERERS_LIMIT.
|
| -
|
| + * application process in a separate thread. The maximum number of allowed renderers is capped
|
| + * by MAX_RENDERERS_LIMIT.
|
| + *
|
| * @return Whether the process actually needed to be initialized (false if already running).
|
| */
|
| public static boolean init(Context context, int maxRendererProcesses)
|
| throws ProcessInitException {
|
| + assert maxRendererProcesses >= 0;
|
| + assert maxRendererProcesses <= MAX_RENDERERS_LIMIT;
|
| if (sInitialized) return false;
|
| sInitialized = true;
|
| + Log.i(TAG, "Initializing chromium process, renderers=" + maxRendererProcesses);
|
|
|
| - // Normally Main.java will have kicked this off asynchronously for Chrome. But
|
| - // other ContentView apps like tests also need them so we make sure we've
|
| - // extracted resources here. We can still make it a little async (wait until
|
| - // the library is loaded).
|
| + // Normally Main.java will have kicked this off asynchronously for Chrome. But other
|
| + // ContentView apps like tests also need them so we make sure we've extracted resources
|
| + // here. We can still make it a little async (wait until the library is loaded).
|
| ResourceExtractor resourceExtractor = ResourceExtractor.get(context);
|
| resourceExtractor.startExtractingResources();
|
|
|
| - // Normally Main.java will have already loaded the library asynchronously, we only
|
| - // need to load it here if we arrived via another flow, e.g. bookmark access & sync setup.
|
| + // Normally Main.java will have already loaded the library asynchronously, we only need to
|
| + // load it here if we arrived via another flow, e.g. bookmark access & sync setup.
|
| LibraryLoader.ensureInitialized();
|
| // TODO(yfriedman): Remove dependency on a command line flag for this.
|
| DeviceUtils.addDeviceSpecificUserAgentSwitch(context);
|
|
|
| Context appContext = context.getApplicationContext();
|
| -
|
| - int maxRenderers = normalizeMaxRendererProcesses(appContext, maxRendererProcesses);
|
| - Log.i(TAG, "Initializing chromium process, renderers=" + maxRenderers);
|
| -
|
| // Now we really need to have the resources ready.
|
| resourceExtractor.waitForCompletion();
|
|
|
| - nativeSetCommandLineFlags(maxRenderers,
|
| + nativeSetCommandLineFlags(maxRendererProcesses,
|
| nativeIsPluginEnabled() ? getPlugins(context) : null);
|
| ContentMain.initApplicationContext(appContext);
|
| int result = ContentMain.start();
|
| @@ -112,8 +87,8 @@ public class AndroidBrowserProcess {
|
| resourceExtractor.startExtractingResources();
|
| resourceExtractor.waitForCompletion();
|
|
|
| - // Having a single renderer should be sufficient for tests.
|
| - // We can't have more than MAX_RENDERERS_LIMIT.
|
| + // Having a single renderer should be sufficient for tests. We can't have more than
|
| + // MAX_RENDERERS_LIMIT.
|
| nativeSetCommandLineFlags(1 /* maxRenderers */, null);
|
| }
|
|
|
| @@ -124,9 +99,8 @@ public class AndroidBrowserProcess {
|
| private static native void nativeSetCommandLineFlags(int maxRenderProcesses,
|
| String pluginDescriptor);
|
|
|
| - // Is this an official build of Chrome? Only native code knows
|
| - // for sure. Official build knowledge is needed very early in
|
| - // process startup.
|
| + // Is this an official build of Chrome? Only native code knows for sure. Official build
|
| + // knowledge is needed very early in process startup.
|
| private static native boolean nativeIsOfficialBuild();
|
|
|
| private static native boolean nativeIsPluginEnabled();
|
|
|