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

Unified Diff: base/android/java/src/org/chromium/base/library_loader/LibraryLoader.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 side-by-side diff with in-line comments
Download patch
Index: base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
diff --git a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
index 454b167c9e20559b6fbefbec71f96945a7945c90..3909ef82974755a4d9ead8100104cee174f8f30a 100644
--- a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
+++ b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
@@ -4,7 +4,6 @@
package org.chromium.base.library_loader;
-import android.content.Context;
import android.os.AsyncTask;
import android.os.SystemClock;
@@ -129,18 +128,14 @@ public class LibraryLoader {
/**
* This method blocks until the library is fully loaded and initialized.
- *
- * @param context The context in which the method is called.
*/
- public void ensureInitialized(Context context) throws ProcessInitException {
- // TODO(wnwen): Move this call appropriately down to the tests that need it.
- ContextUtils.initApplicationContext(context.getApplicationContext());
+ public void ensureInitialized() throws ProcessInitException {
synchronized (sLock) {
if (mInitialized) {
// Already initialized, nothing to do.
return;
}
- loadAlreadyLocked(context);
+ loadAlreadyLocked();
initializeAlreadyLocked();
}
}
@@ -159,13 +154,11 @@ public class LibraryLoader {
* this is called on will be the thread that runs the native code's static initializers.
* See the comment in doInBackground() for more considerations on this.
*
- * @param context The context the code is running.
- *
* @throws ProcessInitException if the native library failed to load.
*/
- public void loadNow(Context context) throws ProcessInitException {
+ public void loadNow() throws ProcessInitException {
synchronized (sLock) {
- loadAlreadyLocked(context);
+ loadAlreadyLocked();
}
}
@@ -250,7 +243,7 @@ public class LibraryLoader {
// Invoke either Linker.loadLibrary(...) or System.loadLibrary(...), triggering
// JNI_OnLoad in native code
- private void loadAlreadyLocked(Context context) throws ProcessInitException {
+ private void loadAlreadyLocked() throws ProcessInitException {
try {
if (!mLoaded) {
assert !mInitialized;
@@ -276,7 +269,8 @@ public class LibraryLoader {
String libFilePath = System.mapLibraryName(library);
if (Linker.isInZipFile()) {
// Load directly from the APK.
- zipFilePath = context.getApplicationInfo().sourceDir;
+ zipFilePath = ContextUtils.getApplicationContext()
+ .getApplicationInfo().sourceDir;
Log.i(TAG, "Loading " + library + " from within " + zipFilePath);
} else {
// The library is in its own file.
@@ -290,7 +284,8 @@ public class LibraryLoader {
linker.finishLibraryLoad();
} else {
if (sLibraryPreloader != null) {
- mLibraryPreloaderStatus = sLibraryPreloader.loadLibrary(context);
+ mLibraryPreloaderStatus = sLibraryPreloader.loadLibrary(
+ ContextUtils.getApplicationContext());
}
// Load libraries using the system linker.
for (String library : NativeLibraries.LIBRARIES) {
@@ -378,18 +373,19 @@ public class LibraryLoader {
}
// Called after all native initializations are complete.
- public void onNativeInitializationComplete(Context context) {
- recordBrowserProcessHistogram(context);
+ public void onNativeInitializationComplete() {
+ recordBrowserProcessHistogram();
}
// Record Chromium linker histogram state for the main browser process. Called from
// onNativeInitializationComplete().
- private void recordBrowserProcessHistogram(Context context) {
+ private void recordBrowserProcessHistogram() {
if (Linker.getInstance().isUsed()) {
- nativeRecordChromiumAndroidLinkerBrowserHistogram(mIsUsingBrowserSharedRelros,
- mLoadAtFixedAddressFailed,
- getLibraryLoadFromApkStatus(context),
- mLibraryLoadTimeMs);
+ nativeRecordChromiumAndroidLinkerBrowserHistogram(
+ mIsUsingBrowserSharedRelros,
+ mLoadAtFixedAddressFailed,
+ getLibraryLoadFromApkStatus(),
+ mLibraryLoadTimeMs);
}
if (sLibraryPreloader != null) {
nativeRecordLibraryPreloaderBrowserHistogram(mLibraryPreloaderStatus);
@@ -398,7 +394,7 @@ public class LibraryLoader {
// Returns the device's status for loading a library directly from the APK file.
// This method can only be called when the Chromium linker is used.
- private int getLibraryLoadFromApkStatus(Context context) {
+ private int getLibraryLoadFromApkStatus() {
assert Linker.getInstance().isUsed();
if (mLibraryWasLoadedFromApk) {

Powered by Google App Engine
This is Rietveld 408576698