Chromium Code Reviews| 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 86bca4399d2abf908ebb34f501de147a7e2484b0..6eee0349b9a07d92a1e613c8bc79c4c1bbf958af 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 |
| @@ -50,9 +50,12 @@ public class LibraryLoader { |
| private static boolean sIsUsingBrowserSharedRelros = false; |
| private static boolean sLoadAtFixedAddressFailed = false; |
| - // One-way switch recording whether the device supports memory mapping |
| - // APK files with executable permissions. Only used in the browser. |
| - private static boolean sLibraryLoadFromApkSupported = false; |
| + // The name of the APK file. |
| + private static String sApkFileName = null; |
| + |
| + // One-way switch becomes true when the library is successfully loaded from |
|
rmcilroy
2014/10/20 10:42:39
nit - One-way switch becomes true if the library w
petrcermak
2014/10/20 15:33:22
Done.
|
| + // the APK file. |
| + private static boolean sLibraryLoadedFromApk = false; |
|
rmcilroy
2014/10/20 10:42:39
nit - sLibraryWasLoadedFromApk
petrcermak
2014/10/20 15:33:22
Done.
|
| // One-way switch becomes true if the system library loading failed, |
| // and the right native library was found and loaded by the hack. |
| @@ -160,21 +163,18 @@ public class LibraryLoader { |
| long startTime = SystemClock.uptimeMillis(); |
| boolean useChromiumLinker = Linker.isUsed(); |
| + if (context != null) { |
| + sApkFileName = context.getApplicationInfo().sourceDir; |
| + } |
| + |
| if (useChromiumLinker) { |
| // Load libraries using the Chromium linker. |
| Linker.prepareLibraryLoad(); |
| - // Check if the device supports loading a library directly from the APK file. |
| - String apkfile = context.getApplicationInfo().sourceDir; |
| - if (Linker.isInBrowserProcess()) { |
| - sLibraryLoadFromApkSupported = Linker.checkLibraryLoadFromApkSupport( |
| - apkfile); |
| - } |
| - |
| for (String library : NativeLibraries.LIBRARIES) { |
| String zipfile = null; |
| if (Linker.isInZipFile()) { |
| - zipfile = apkfile; |
| + zipfile = sApkFileName; |
| Log.i(TAG, "Loading " + library + " from within " + zipfile); |
| } else { |
| Log.i(TAG, "Loading: " + library); |
| @@ -186,6 +186,7 @@ public class LibraryLoader { |
| try { |
| if (zipfile != null) { |
| Linker.loadLibraryInZipFile(zipfile, library); |
| + sLibraryLoadedFromApk = true; |
| } else { |
| Linker.loadLibrary(library); |
| } |
| @@ -200,6 +201,7 @@ public class LibraryLoader { |
| if (!isLoaded) { |
| if (zipfile != null) { |
| Linker.loadLibraryInZipFile(zipfile, library); |
| + sLibraryLoadedFromApk = true; |
| } else { |
| Linker.loadLibrary(library); |
| } |
| @@ -316,10 +318,20 @@ public class LibraryLoader { |
| // onNativeInitializationComplete(). |
| private static void recordBrowserProcessHistogram() { |
|
rmcilroy
2014/10/20 10:42:39
It looks like this is only called from onNativeIni
petrcermak
2014/10/20 15:33:22
Done.
|
| if (Linker.isUsed()) { |
| - assert Linker.isInBrowserProcess(); |
| + int libraryLoadFromApkSupport; |
|
rmcilroy
2014/10/20 10:42:39
nit - libraryLoadFromApkStatus
petrcermak
2014/10/20 15:33:22
The variable is not needed now that the code is in
|
| + if (sLibraryLoadedFromApk) { |
| + libraryLoadFromApkSupport = LibraryLoadFromApkSupportCode.SUCCESSFUL; |
| + } else if (sApkFileName != null) { |
| + libraryLoadFromApkSupport = Linker.checkLibraryLoadFromApkSupport(sApkFileName) ? |
| + LibraryLoadFromApkSupportCode.SUPPORTED : |
| + LibraryLoadFromApkSupportCode.NOT_SUPPORTED; |
| + } else { |
| + libraryLoadFromApkSupport = LibraryLoadFromApkSupportCode.UNKNOWN; |
| + Log.w(TAG, "Unknown APK filename due to null context"); |
| + } |
|
rmcilroy
2014/10/20 10:42:39
Please pull this out into a separate function whic
petrcermak
2014/10/20 15:33:22
Done.
|
| nativeRecordChromiumAndroidLinkerBrowserHistogram(sIsUsingBrowserSharedRelros, |
| sLoadAtFixedAddressFailed, |
| - sLibraryLoadFromApkSupported); |
| + libraryLoadFromApkSupport); |
| } |
| } |
| @@ -348,11 +360,11 @@ public class LibraryLoader { |
| // Method called to record statistics about the Chromium linker operation for the main |
| // browser process. Indicates whether the linker attempted relro sharing for the browser, |
| // and if it did, whether the library failed to load at a fixed address. Also records |
| - // support for memory mapping APK files with executable permissions. |
| + // support for loading a library directly from the APK file. |
| private static native void nativeRecordChromiumAndroidLinkerBrowserHistogram( |
| boolean isUsingBrowserSharedRelros, |
| boolean loadAtFixedAddressFailed, |
| - boolean apkMemoryMappingSupported); |
| + int libraryLoadFromApkSupport); |
| // Method called to register (for later recording) statistics about the Chromium linker |
| // operation for a renderer process. Indicates whether the linker attempted relro sharing, |