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..ec5f450a33cda46b7ca88bf3ed7221b412625ae1 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 |
@@ -129,18 +129,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(ContextUtils.getApplicationContext()); |
initializeAlreadyLocked(); |
} |
} |
@@ -159,10 +155,18 @@ 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() throws ProcessInitException { |
+ loadNow(ContextUtils.getApplicationContext()); |
+ } |
+ |
+ /** |
+ * Override kept for callers that need to load from a different app context. |
+ * |
+ * @param context The overriding context to be used to load libraries. |
+ * @throws ProcessInitException if the native library failed to load with this context. |
+ */ |
public void loadNow(Context context) throws ProcessInitException { |
Ted C
2016/09/26 20:49:15
We should probably name this more explicit as well
Peter Wen
2016/09/28 15:55:17
Done.
|
synchronized (sLock) { |
Ted C
2016/09/26 20:49:15
If we call this with something other than the appl
Peter Wen
2016/09/28 15:55:17
Agreed, done.
|
loadAlreadyLocked(context); |
@@ -378,18 +382,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 +403,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) { |