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..174b5b9eca74a6e7fd0ea16dbc3f7c650cbda2e7 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,17 @@ 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; |
| + |
| + // Constants representing the support of the device for loading a library |
| + // directly from the APK file. |
| + // NOT_SUPPORTED -> The functionality is not supported. |
| + // SUPPORTED -> The functionality is supported. |
| + // UNKNOWN -> The loader was unable to determine whether the funcionality is supported. |
| + public static final int LIBRARY_LOAD_FROM_APK_NOT_SUPPORTED = 0; |
| + public static final int LIBRARY_LOAD_FROM_APK_SUPPORTED = 1; |
| + public static final int LIBRARY_LOAD_FROM_APK_UNKNOWN = 2; |
|
petrcermak
2014/10/16 18:48:52
I'm not completely satisfied with the way this sup
rmcilroy
2014/10/17 09:12:59
The JNI generator can help here. If you look at Me
petrcermak
2014/10/17 14:51:27
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 +168,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); |
| @@ -316,10 +321,17 @@ public class LibraryLoader { |
| // onNativeInitializationComplete(). |
| private static void recordBrowserProcessHistogram() { |
| if (Linker.isUsed()) { |
| - assert Linker.isInBrowserProcess(); |
| + final int libraryLoadFromApkSupport; |
|
rmcilroy
2014/10/17 09:12:59
Nit - we don't usually use final on locals. Person
petrcermak
2014/10/17 14:51:28
Done (although I've seen it used in Linker.java fo
|
| + if (sApkFileName != null) { |
| + libraryLoadFromApkSupport = Linker.checkLibraryLoadFromApkSupport(sApkFileName) ? |
| + LIBRARY_LOAD_FROM_APK_SUPPORTED : LIBRARY_LOAD_FROM_APK_NOT_SUPPORTED; |
| + } else { |
| + libraryLoadFromApkSupport = LIBRARY_LOAD_FROM_APK_UNKNOWN; |
| + Log.w(TAG, "Unknown APK filename due to null context"); |
| + } |
|
picksi1
2014/10/17 08:23:24
Might be more readable to swap the if/else bodies
petrcermak
2014/10/17 14:51:27
I thought about it and I would prefer to keep it t
|
| nativeRecordChromiumAndroidLinkerBrowserHistogram(sIsUsingBrowserSharedRelros, |
| sLoadAtFixedAddressFailed, |
| - sLibraryLoadFromApkSupported); |
| + libraryLoadFromApkSupport); |
|
rmcilroy
2014/10/17 09:54:45
Actually, I'm just about to turn on loading form t
petrcermak
2014/10/17 14:51:27
Done. Note that Linker.loadLibraryInZipFile doesn'
|
| } |
| } |
| @@ -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); |
|
picksi1
2014/10/17 08:23:24
Now that you've started using enums are the first
petrcermak
2014/10/17 14:51:27
ditto (as line 181).
|
| // Method called to register (for later recording) statistics about the Chromium linker |
| // operation for a renderer process. Indicates whether the linker attempted relro sharing, |