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

Unified Diff: base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java

Issue 1607993003: Add NativeLibraryPreloader interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync and add Java in BUILD.gn Created 4 years, 9 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
« no previous file with comments | « base/BUILD.gn ('k') | base/android/java/src/org/chromium/base/library_loader/NativeLibraryPreloader.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « base/BUILD.gn ('k') | base/android/java/src/org/chromium/base/library_loader/NativeLibraryPreloader.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698