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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/BrowserStartupController.java

Issue 1936353002: Add a flag to not start GPU process on browser startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change willStartGpuProcess to shouldStartGpuProcess Created 4 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Handler; 8 import android.os.Handler;
9 9
10 import org.chromium.base.Log; 10 import org.chromium.base.Log;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // Helper constants for {@link #executeEnqueuedCallbacks(int, boolean)}. 55 // Helper constants for {@link #executeEnqueuedCallbacks(int, boolean)}.
56 @VisibleForTesting 56 @VisibleForTesting
57 static final int STARTUP_SUCCESS = -1; 57 static final int STARTUP_SUCCESS = -1;
58 @VisibleForTesting 58 @VisibleForTesting
59 static final int STARTUP_FAILURE = 1; 59 static final int STARTUP_FAILURE = 1;
60 60
61 private static BrowserStartupController sInstance; 61 private static BrowserStartupController sInstance;
62 62
63 private static boolean sBrowserMayStartAsynchronously = false; 63 private static boolean sBrowserMayStartAsynchronously = false;
64 private static boolean sStartGpuProcessOnBrowserStartup = true;
64 65
65 private static void setAsynchronousStartup(boolean enable) { 66 private static void setAsynchronousStartup(boolean enable) {
66 sBrowserMayStartAsynchronously = enable; 67 sBrowserMayStartAsynchronously = enable;
67 } 68 }
68 69
69 @VisibleForTesting 70 @VisibleForTesting
70 @CalledByNative 71 @CalledByNative
71 static boolean browserMayStartAsynchonously() { 72 static boolean browserMayStartAsynchonously() {
72 return sBrowserMayStartAsynchronously; 73 return sBrowserMayStartAsynchronously;
73 } 74 }
74 75
75 @VisibleForTesting 76 @VisibleForTesting
76 @CalledByNative 77 @CalledByNative
77 static void browserStartupComplete(int result) { 78 static void browserStartupComplete(int result) {
78 if (sInstance != null) { 79 if (sInstance != null) {
79 sInstance.executeEnqueuedCallbacks(result, NOT_ALREADY_STARTED); 80 sInstance.executeEnqueuedCallbacks(result, NOT_ALREADY_STARTED);
80 } 81 }
81 } 82 }
82 83
84 @CalledByNative
85 static boolean startGpuProcessOnBrowserStartup() {
86 return sStartGpuProcessOnBrowserStartup;
87 }
88
83 // A list of callbacks that should be called when the async startup of the b rowser process is 89 // A list of callbacks that should be called when the async startup of the b rowser process is
84 // complete. 90 // complete.
85 private final List<StartupCallback> mAsyncStartupCallbacks; 91 private final List<StartupCallback> mAsyncStartupCallbacks;
86 92
87 // The context is set on creation, but the reference is cleared after the br owser process 93 // The context is set on creation, but the reference is cleared after the br owser process
88 // initialization has been started, since it is not needed anymore. This is to ensure the 94 // initialization has been started, since it is not needed anymore. This is to ensure the
89 // context is not leaked. 95 // context is not leaked.
90 private final Context mContext; 96 private final Context mContext;
91 97
92 // Whether the async startup of the browser process has started. 98 // Whether the async startup of the browser process has started.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 145 }
140 return sInstance; 146 return sInstance;
141 } 147 }
142 148
143 /** 149 /**
144 * Start the browser process asynchronously. This will set up a queue of UI thread tasks to 150 * Start the browser process asynchronously. This will set up a queue of UI thread tasks to
145 * initialize the browser process. 151 * initialize the browser process.
146 * <p/> 152 * <p/>
147 * Note that this can only be called on the UI thread. 153 * Note that this can only be called on the UI thread.
148 * 154 *
155 * @param startGpuProcess Whether to start the GPU process if it is not star ted.
149 * @param callback the callback to be called when browser startup is complet e. 156 * @param callback the callback to be called when browser startup is complet e.
150 */ 157 */
151 public void startBrowserProcessesAsync(final StartupCallback callback) 158 public void startBrowserProcessesAsync(boolean startGpuProcess, final Startu pCallback callback)
152 throws ProcessInitException { 159 throws ProcessInitException {
153 assert ThreadUtils.runningOnUiThread() : "Tried to start the browser on the wrong thread."; 160 assert ThreadUtils.runningOnUiThread() : "Tried to start the browser on the wrong thread.";
154 if (mStartupDone) { 161 if (mStartupDone) {
155 // Browser process initialization has already been completed, so we can immediately post 162 // Browser process initialization has already been completed, so we can immediately post
156 // the callback. 163 // the callback.
157 postStartupCompleted(callback); 164 postStartupCompleted(callback);
158 return; 165 return;
159 } 166 }
160 167
161 // Browser process has not been fully started yet, so we defer executing the callback. 168 // Browser process has not been fully started yet, so we defer executing the callback.
162 mAsyncStartupCallbacks.add(callback); 169 mAsyncStartupCallbacks.add(callback);
163 170
164 if (!mHasStartedInitializingBrowserProcess) { 171 if (!mHasStartedInitializingBrowserProcess) {
165 // This is the first time we have been asked to start the browser pr ocess. We set the 172 // This is the first time we have been asked to start the browser pr ocess. We set the
166 // flag that indicates that we have kicked off starting the browser process. 173 // flag that indicates that we have kicked off starting the browser process.
167 mHasStartedInitializingBrowserProcess = true; 174 mHasStartedInitializingBrowserProcess = true;
168 175
169 setAsynchronousStartup(true); 176 setAsynchronousStartup(true);
177 sStartGpuProcessOnBrowserStartup = startGpuProcess;
170 prepareToStartBrowserProcess(false, new Runnable() { 178 prepareToStartBrowserProcess(false, new Runnable() {
171 @Override 179 @Override
172 public void run() { 180 public void run() {
173 ThreadUtils.assertOnUiThread(); 181 ThreadUtils.assertOnUiThread();
174 if (contentStart() > 0) { 182 if (contentStart() > 0) {
175 // Failed. The callbacks may not have run, so run them. 183 // Failed. The callbacks may not have run, so run them.
176 enqueueCallbackExecution(STARTUP_FAILURE, NOT_ALREADY_ST ARTED); 184 enqueueCallbackExecution(STARTUP_FAILURE, NOT_ALREADY_ST ARTED);
177 } 185 }
178 } 186 }
179 }); 187 });
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // Normally Main.java will have already loaded the library asynchronousl y, we only need 291 // Normally Main.java will have already loaded the library asynchronousl y, we only need
284 // to load it here if we arrived via another flow, e.g. bookmark access & sync setup. 292 // to load it here if we arrived via another flow, e.g. bookmark access & sync setup.
285 LibraryLoader.get(mLibraryProcessType).ensureInitialized(mContext); 293 LibraryLoader.get(mLibraryProcessType).ensureInitialized(mContext);
286 294
287 Runnable postResourceExtraction = new Runnable() { 295 Runnable postResourceExtraction = new Runnable() {
288 @Override 296 @Override
289 public void run() { 297 public void run() {
290 if (!mPostResourceExtractionTasksCompleted) { 298 if (!mPostResourceExtractionTasksCompleted) {
291 // TODO(yfriedman): Remove dependency on a command line flag for this. 299 // TODO(yfriedman): Remove dependency on a command line flag for this.
292 DeviceUtils.addDeviceSpecificUserAgentSwitch(mContext); 300 DeviceUtils.addDeviceSpecificUserAgentSwitch(mContext);
293
294 nativeSetCommandLineFlags( 301 nativeSetCommandLineFlags(
295 singleProcess, nativeIsPluginEnabled() ? getPlugins( ) : null); 302 singleProcess, nativeIsPluginEnabled() ? getPlugins( ) : null);
296 mPostResourceExtractionTasksCompleted = true; 303 mPostResourceExtractionTasksCompleted = true;
297 } 304 }
298 305
299 if (completionCallback != null) completionCallback.run(); 306 if (completionCallback != null) completionCallback.run();
300 } 307 }
301 }; 308 };
302 309
303 if (completionCallback == null) { 310 if (completionCallback == null) {
(...skipping 22 matching lines...) Expand all
326 333
327 private static native void nativeSetCommandLineFlags( 334 private static native void nativeSetCommandLineFlags(
328 boolean singleProcess, String pluginDescriptor); 335 boolean singleProcess, String pluginDescriptor);
329 336
330 // Is this an official build of Chrome? Only native code knows for sure. Off icial build 337 // Is this an official build of Chrome? Only native code knows for sure. Off icial build
331 // knowledge is needed very early in process startup. 338 // knowledge is needed very early in process startup.
332 private static native boolean nativeIsOfficialBuild(); 339 private static native boolean nativeIsOfficialBuild();
333 340
334 private static native boolean nativeIsPluginEnabled(); 341 private static native boolean nativeIsPluginEnabled();
335 } 342 }
OLDNEW
« content/browser/browser_main_loop.cc ('K') | « content/browser/browser_main_loop.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698