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 91e53678707f17b3b96a8b8bacaebe6ab07818de..fc6d46fb99771f26383d788fbe41a2254caafc76 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 |
@@ -10,7 +10,6 @@ import android.util.Log; |
import org.chromium.base.CommandLine; |
import org.chromium.base.JNINamespace; |
-import org.chromium.base.SysUtils; |
import org.chromium.base.TraceEvent; |
/** |
@@ -46,6 +45,11 @@ public class LibraryLoader { |
// library_loader_hooks.cc). |
private static boolean sInitialized = false; |
+ // One-way switches recording attempts to use Relro sharing in the browser. |
+ // The flags are used to report UMA stats later. |
+ private static boolean sIsUsingBrowserSharedRelros = false; |
+ private static boolean sLoadAtFixedAddressFailed = false; |
+ |
// 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. |
@@ -167,6 +171,7 @@ public class LibraryLoader { |
boolean isLoaded = false; |
if (Linker.isUsingBrowserSharedRelros()) { |
+ sIsUsingBrowserSharedRelros = true; |
try { |
if (zipfile != null) { |
Linker.loadLibraryInZipFile(zipfile, library); |
@@ -178,6 +183,7 @@ public class LibraryLoader { |
Log.w(TAG, "Failed to load native library with shared RELRO, " + |
"retrying without"); |
Linker.disableSharedRelros(); |
+ sLoadAtFixedAddressFailed = true; |
} |
} |
if (!isLoaded) { |
@@ -291,13 +297,29 @@ public class LibraryLoader { |
// Called after all native initializations are complete. |
public static void onNativeInitializationComplete() { |
- // Record histogram for the Chromium linker. |
+ recordBrowserProcessHistogram(); |
+ nativeRecordNativeLibraryHack(sNativeLibraryHackWasUsed); |
+ } |
+ |
+ // Record Chromium linker histogram state for the main browser process. Called from |
+ // onNativeInitializationComplete(). |
+ private static void recordBrowserProcessHistogram() { |
if (Linker.isUsed()) { |
- nativeRecordChromiumAndroidLinkerHistogram(Linker.loadAtFixedAddressFailed(), |
- SysUtils.isLowEndDevice()); |
+ nativeRecordChromiumAndroidLinkerBrowserHistogram(sIsUsingBrowserSharedRelros, |
+ sLoadAtFixedAddressFailed); |
} |
+ } |
- nativeRecordNativeLibraryHack(sNativeLibraryHackWasUsed); |
+ // Register pending Chromium linker histogram state for renderer processes. This cannot be |
+ // recorded as a histogram immediately because histograms and IPC are not ready at the |
+ // time it are captured. This function stores a pending value, so that a later call to |
+ // RecordChromiumAndroidLinkerRendererHistogram() will record it correctly. |
+ public static void registerRendererProcessHistogram(boolean requestedSharedRelro, |
+ boolean loadAtFixedAddressFailed) { |
+ if (Linker.isUsed()) { |
+ nativeRegisterChromiumAndroidLinkerRendererHistogram(requestedSharedRelro, |
+ loadAtFixedAddressFailed); |
+ } |
} |
private static native void nativeInitCommandLine(String[] initCommandLine); |
@@ -310,12 +332,19 @@ public class LibraryLoader { |
// Return true on success and false on failure. |
private static native boolean nativeLibraryLoaded(); |
- // Method called to record statistics about the Chromium linker operation, |
- // i.e. whether the library failed to be loaded at a fixed address, and |
- // whether the device is 'low-memory'. |
- private static native void nativeRecordChromiumAndroidLinkerHistogram( |
- boolean loadedAtFixedAddressFailed, |
- boolean isLowMemoryDevice); |
+ // 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. |
+ private static native void nativeRecordChromiumAndroidLinkerBrowserHistogram( |
+ boolean isUsingBrowserSharedRelros, |
+ boolean loadAtFixedAddressFailed); |
+ |
+ // Method called to register (for later recording) statistics about the Chromium linker |
+ // operation for a renderer process. Indicates whether the linker attempted relro sharing, |
+ // and if it did, whether the library failed to load at a fixed address. |
+ private static native void nativeRegisterChromiumAndroidLinkerRendererHistogram( |
+ boolean requestedSharedRelro, |
+ boolean loadAtFixedAddressFailed); |
// Get the version of the native library. This is needed so that we can check we |
// have the right version before initializing the (rest of the) JNI. |