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

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

Issue 684453003: Add UMA for testing whether the Chromium library was page aligned in the APK file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added asserts to crazy linker Created 6 years, 2 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
Index: base/android/java/src/org/chromium/base/library_loader/Linker.java
diff --git a/base/android/java/src/org/chromium/base/library_loader/Linker.java b/base/android/java/src/org/chromium/base/library_loader/Linker.java
index 8ad26d8a8391237e3dd60511487f10842deee12b..b6466a2cdb3fee7a07a2c1636ecc48749eaef0fc 100644
--- a/base/android/java/src/org/chromium/base/library_loader/Linker.java
+++ b/base/android/java/src/org/chromium/base/library_loader/Linker.java
@@ -158,7 +158,7 @@ public class Linker {
private static final String TAG = "chromium_android_linker";
// Set to true to enable debug logs.
- private static final boolean DEBUG = false;
+ public static final boolean DEBUG = false;
// Constants used to control the behaviour of the browser process with
// regards to the shared RELRO section.
@@ -702,7 +702,8 @@ public class Linker {
* Load a native shared library with the Chromium linker.
* The shared library is uncompressed and page aligned inside the zipfile.
* Note the crazy linker treats libraries and files as equivalent,
- * so you can only open one library in a given zip file.
+ * so you can only open one library in a given zip file. The library must
+ * not be the Chromium linker library.
*
* @param zipfile The filename of the zipfile contain the library.
* @param library The library's base name.
@@ -712,7 +713,8 @@ public class Linker {
}
/**
- * Load a native shared library with the Chromium linker.
+ * Load a native shared library with the Chromium linker. The library must
+ * not be the Chromium linker library.
*
* @param library The library's base name.
*/
@@ -723,15 +725,7 @@ public class Linker {
private static void loadLibraryMaybeInZipFile(
@Nullable String zipFile, String library) {
if (DEBUG) Log.i(TAG, "loadLibrary: " + library);
-
- // Don't self-load the linker. This is because the build system is
- // not clever enough to understand that all the libraries packaged
- // in the final .apk don't need to be explicitly loaded.
- // Also deal with the component build that adds a .cr suffix to the name.
- if (library.equals(TAG) || library.equals(TAG + ".cr")) {
- if (DEBUG) Log.i(TAG, "ignoring self-linker load");
- return;
- }
+ assert !isLinkerLibrary(library);
synchronized (Linker.class) {
ensureInitializedLocked();
@@ -821,6 +815,14 @@ public class Linker {
}
/**
+ * Determine whether a library is the linker library. Also deal with the
+ * component build that adds a .cr suffix to the name.
+ */
+ public static boolean isLinkerLibrary(String library) {
rmcilroy 2014/10/28 13:07:15 nit - isChromiumLinkerLibrary
petrcermak 2014/10/28 13:48:15 Done.
+ return library.equals(TAG) || library.equals(TAG + ".cr");
+ }
+
+ /**
* Check whether the device supports loading a library directly from the APK file.
*
* @param apkFile Filename of the APK.
@@ -840,6 +842,25 @@ public class Linker {
}
/**
+ * Check whether a library is page aligned in the APK file.
+ *
+ * @param apkFile Filename of the APK.
+ * @param library The library's base name.
+ * @return true if page aligned.
+ */
+ public static boolean checkLibraryAlignedInApk(String apkFile, String library) {
+ synchronized (Linker.class) {
+ ensureInitializedLocked();
+
+ if (DEBUG) Log.i(TAG, "checkLibraryAlignedInApk: " + apkFile + ", " + library);
+ boolean aligned = nativeCheckLibraryAlignedInApk(apkFile, library);
+ if (DEBUG) Log.i(TAG, library + " is " + (aligned ? "" : "NOT ") +
+ "page aligned in " + apkFile);
+ return aligned;
+ }
+ }
+
+ /**
* Move activity from the native thread to the main UI thread.
* Called from native code on its own thread. Posts a callback from
* the UI thread back to native code.
@@ -942,11 +963,19 @@ public class Linker {
*
* @param apkFile Filename of the APK.
* @return true if supported.
- *
*/
private static native boolean nativeCheckLibraryLoadFromApkSupport(String apkFile);
/**
+ * Native method which checks whether a library is page aligned in the APK file.
+ *
+ * @param apkFile Filename of the APK.
+ * @param library The library's base name.
+ * @return true if page aligned.
+ */
+ private static native boolean nativeCheckLibraryAlignedInApk(String apkFile, String library);
+
+ /**
* Record information for a given library.
* IMPORTANT: Native code knows about this class's fields, so
* don't change them without modifying the corresponding C++ sources.

Powered by Google App Engine
This is Rietveld 408576698