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

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

Issue 2247143004: Remove app context init from LibraryLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better formatting. Created 4 years, 3 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 import android.os.StrictMode; 9 import android.os.StrictMode;
10 10
11 import org.chromium.base.ContextUtils;
11 import org.chromium.base.Log; 12 import org.chromium.base.Log;
12 import org.chromium.base.ResourceExtractor; 13 import org.chromium.base.ResourceExtractor;
13 import org.chromium.base.ThreadUtils; 14 import org.chromium.base.ThreadUtils;
14 import org.chromium.base.VisibleForTesting; 15 import org.chromium.base.VisibleForTesting;
15 import org.chromium.base.annotations.CalledByNative; 16 import org.chromium.base.annotations.CalledByNative;
16 import org.chromium.base.annotations.JNINamespace; 17 import org.chromium.base.annotations.JNINamespace;
17 import org.chromium.base.library_loader.LibraryLoader; 18 import org.chromium.base.library_loader.LibraryLoader;
18 import org.chromium.base.library_loader.LibraryProcessType; 19 import org.chromium.base.library_loader.LibraryProcessType;
19 import org.chromium.base.library_loader.LoaderErrors; 20 import org.chromium.base.library_loader.LoaderErrors;
20 import org.chromium.base.library_loader.ProcessInitException; 21 import org.chromium.base.library_loader.ProcessInitException;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 112
112 // This field is set after startup has been completed based on whether the s tartup was a success 113 // This field is set after startup has been completed based on whether the s tartup was a success
113 // or not. It is used when later requests to startup come in that happen aft er the initial set 114 // or not. It is used when later requests to startup come in that happen aft er the initial set
114 // of enqueued callbacks have been executed. 115 // of enqueued callbacks have been executed.
115 private boolean mStartupSuccess; 116 private boolean mStartupSuccess;
116 117
117 private int mLibraryProcessType; 118 private int mLibraryProcessType;
118 119
119 BrowserStartupController(Context context, int libraryProcessType) { 120 BrowserStartupController(Context context, int libraryProcessType) {
120 mContext = context.getApplicationContext(); 121 mContext = context.getApplicationContext();
121 mAsyncStartupCallbacks = new ArrayList<StartupCallback>(); 122 mAsyncStartupCallbacks = new ArrayList<>();
122 mLibraryProcessType = libraryProcessType; 123 mLibraryProcessType = libraryProcessType;
123 } 124 }
124 125
125 /** 126 /**
126 * Get BrowserStartupController instance, create a new one if no existing. 127 * Get BrowserStartupController instance, create a new one if no existing.
127 * 128 *
128 * @param context the application context. 129 * @param context the application context.
129 * @param libraryProcessType the type of process the shared library is loade d. it must be 130 * @param libraryProcessType the type of process the shared library is loade d. it must be
130 * LibraryProcessType.PROCESS_BROWSER or 131 * LibraryProcessType.PROCESS_BROWSER or
131 * LibraryProcessType.PROCESS_WEBVIEW. 132 * LibraryProcessType.PROCESS_WEBVIEW.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 281 }
281 }); 282 });
282 } 283 }
283 284
284 @VisibleForTesting 285 @VisibleForTesting
285 void prepareToStartBrowserProcess( 286 void prepareToStartBrowserProcess(
286 final boolean singleProcess, final Runnable completionCallback) 287 final boolean singleProcess, final Runnable completionCallback)
287 throws ProcessInitException { 288 throws ProcessInitException {
288 Log.i(TAG, "Initializing chromium process, singleProcess=%b", singleProc ess); 289 Log.i(TAG, "Initializing chromium process, singleProcess=%b", singleProc ess);
289 290
291 ContextUtils.initApplicationContext(mContext.getApplicationContext());
Ted C 2016/09/21 18:36:51 Why is this needed? With this here, isn't chrome
Torne 2016/09/26 09:21:35 We want to get rid of BaseChromiumApplication enti
Peter Wen 2016/09/28 15:55:16 Right, this should not be necessary here.
292
290 // Normally Main.java will have kicked this off asynchronously for Chrom e. But other 293 // Normally Main.java will have kicked this off asynchronously for Chrom e. But other
291 // ContentView apps like tests also need them so we make sure we've extr acted resources 294 // ContentView apps like tests also need them so we make sure we've extr acted resources
292 // here. We can still make it a little async (wait until the library is loaded). 295 // here. We can still make it a little async (wait until the library is loaded).
293 ResourceExtractor resourceExtractor = ResourceExtractor.get(mContext); 296 ResourceExtractor resourceExtractor = ResourceExtractor.get(mContext);
294 resourceExtractor.startExtractingResources(); 297 resourceExtractor.startExtractingResources();
295 298
296 // This strictmode exception is to cover the case where the browser proc ess is being started 299 // This strictmode exception is to cover the case where the browser proc ess is being started
297 // asynchronously but not in the main browser flow. The main browser fl ow will trigger 300 // asynchronously but not in the main browser flow. The main browser fl ow will trigger
298 // library loading earlier and this will be a no-op, but in the other ca ses this will need 301 // library loading earlier and this will be a no-op, but in the other ca ses this will need
299 // to block on loading libraries. 302 // to block on loading libraries.
300 // This applies to tests and ManageSpaceActivity, which can be launched from Settings. 303 // This applies to tests and ManageSpaceActivity, which can be launched from Settings.
301 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); 304 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
302 try { 305 try {
303 // Normally Main.java will have already loaded the library asynchron ously, we only need 306 // Normally Main.java will have already loaded the library asynchron ously, we only need
304 // to load it here if we arrived via another flow, e.g. bookmark acc ess & sync setup. 307 // to load it here if we arrived via another flow, e.g. bookmark acc ess & sync setup.
305 LibraryLoader.get(mLibraryProcessType).ensureInitialized(mContext); 308 LibraryLoader.get(mLibraryProcessType).ensureInitialized();
306 } finally { 309 } finally {
307 StrictMode.setThreadPolicy(oldPolicy); 310 StrictMode.setThreadPolicy(oldPolicy);
308 } 311 }
309 312
310 Runnable postResourceExtraction = new Runnable() { 313 Runnable postResourceExtraction = new Runnable() {
311 @Override 314 @Override
312 public void run() { 315 public void run() {
313 if (!mPostResourceExtractionTasksCompleted) { 316 if (!mPostResourceExtractionTasksCompleted) {
314 // TODO(yfriedman): Remove dependency on a command line flag for this. 317 // TODO(yfriedman): Remove dependency on a command line flag for this.
315 DeviceUtils.addDeviceSpecificUserAgentSwitch(mContext); 318 DeviceUtils.addDeviceSpecificUserAgentSwitch(mContext);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 351
349 private static native void nativeSetCommandLineFlags( 352 private static native void nativeSetCommandLineFlags(
350 boolean singleProcess, String pluginDescriptor); 353 boolean singleProcess, String pluginDescriptor);
351 354
352 // Is this an official build of Chrome? Only native code knows for sure. Off icial build 355 // Is this an official build of Chrome? Only native code knows for sure. Off icial build
353 // knowledge is needed very early in process startup. 356 // knowledge is needed very early in process startup.
354 private static native boolean nativeIsOfficialBuild(); 357 private static native boolean nativeIsOfficialBuild();
355 358
356 private static native boolean nativeIsPluginEnabled(); 359 private static native boolean nativeIsPluginEnabled();
357 } 360 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698