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 a0897c066a3e79673ef7368b094ee4c9c2440bd8..6665ddfde738544d38fa382a7d0a9da91ede98d0 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 |
@@ -48,6 +48,9 @@ public class LibraryLoader { |
// Guards all access to the libraries |
private static final Object sLock = new Object(); |
+ // The singleton instance of NativeLibraryPreloader. |
+ private static NativeLibraryPreloader sLibraryPreloader; |
+ |
// The singleton instance of LibraryLoader. |
private static volatile LibraryLoader sInstance; |
@@ -88,6 +91,20 @@ public class LibraryLoader { |
private long mLibraryLoadTimeMs; |
/** |
+ * Set native library preloader, if set, the NativeLibraryPreloader.loadLibrary will be invoked |
+ * before calling System.loadLibrary, this only applies when not using the chromium linker. |
+ * |
+ * @param loader the NativeLibraryPreloader, it shall only be set once and before the |
+ * native library loaded. |
+ */ |
+ public static void setNativeLibraryPreloader(NativeLibraryPreloader loader) { |
+ synchronized (sLock) { |
+ assert sLibraryPreloader == null && (sInstance == null || !sInstance.mLoaded); |
+ sLibraryPreloader = loader; |
+ } |
+ } |
+ |
+ /** |
* @param libraryProcessType the process the shared library is loaded in. refer to |
* LibraryProcessType for possible values. |
* @return LibraryLoader if existing, otherwise create a new one. |
@@ -266,6 +283,9 @@ public class LibraryLoader { |
linker.finishLibraryLoad(); |
} else { |
+ if (sLibraryPreloader != null) { |
+ sLibraryPreloader.loadLibrary(context); |
+ } |
// Load libraries using the system linker. |
for (String library : NativeLibraries.LIBRARIES) { |
System.loadLibrary(library); |