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

Unified Diff: base/android/java/src/org/chromium/base/library_loader/LibraryLoader.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: Update for review feedback 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
« no previous file with comments | « no previous file | base/android/java/src/org/chromium/base/library_loader/Linker.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 c56d76c97d354f0886ad106f0ebdeb5b0d7b0544..2f922e045b49a910bd1dcbe62b15d7633b66c567 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
@@ -30,6 +30,9 @@ import org.chromium.base.TraceEvent;
public class LibraryLoader {
private static final String TAG = "LibraryLoader";
+ // Set to true to enable debug logs.
+ private static final boolean DEBUG = false;
+
// Guards all access to the libraries
private static final Object sLock = new Object();
@@ -54,6 +57,10 @@ public class LibraryLoader {
// directly.
private static boolean sLibraryWasLoadedFromApk = false;
+ // One-way switch becomes false if the Chromium library should be loaded
+ // directly from the APK file but it was not aligned.
+ private static boolean sLibraryWasAlignedInApk = true;
+
// One-way switch becomes true if the system library loading failed,
// and the right native library was found and loaded by the hack.
// The flag is used to report UMA stats later.
@@ -165,9 +172,19 @@ public class LibraryLoader {
Linker.prepareLibraryLoad();
for (String library : NativeLibraries.LIBRARIES) {
+ // 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.
+ if (Linker.isChromiumLinkerLibrary(library)) {
+ if (DEBUG) Log.i(TAG, "ignoring self-linker load");
+ continue;
+ }
+
String zipfile = null;
if (Linker.isInZipFile()) {
zipfile = context.getApplicationInfo().sourceDir;
+ sLibraryWasAlignedInApk = Linker.checkLibraryAlignedInApk(
+ zipfile, System.mapLibraryName(library));
Log.i(TAG, "Loading " + library + " from within " + zipfile);
} else {
Log.i(TAG, "Loading: " + library);
@@ -326,6 +343,10 @@ public class LibraryLoader {
return LibraryLoadFromApkStatusCodes.SUCCESSFUL;
}
+ if (!sLibraryWasAlignedInApk) {
+ return LibraryLoadFromApkStatusCodes.NOT_ALIGNED;
+ }
+
if (context == null) {
Log.w(TAG, "Unknown APK filename due to null context");
return LibraryLoadFromApkStatusCodes.UNKNOWN;
« no previous file with comments | « no previous file | base/android/java/src/org/chromium/base/library_loader/Linker.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698