| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/android/library_loader/library_loader_hooks.h" | 5 #include "base/android/library_loader/library_loader_hooks.h" |
| 6 | 6 |
| 7 #include "base/android/command_line_android.h" | 7 #include "base/android/command_line_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/android/library_loader/library_load_from_apk_status_codes.h" |
| 9 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| 10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 11 #include "jni/LibraryLoader_jni.h" | 12 #include "jni/LibraryLoader_jni.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 namespace android { | 15 namespace android { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 base::AtExitManager* g_at_exit_manager = NULL; | 19 base::AtExitManager* g_at_exit_manager = NULL; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 39 | 40 |
| 40 // Low-memory browser loads at fixed address, success or fail. | 41 // Low-memory browser loads at fixed address, success or fail. |
| 41 LOW_MEMORY_LFA_SUCCESS = 1, | 42 LOW_MEMORY_LFA_SUCCESS = 1, |
| 42 LOW_MEMORY_LFA_BACKOFF_USED = 2, | 43 LOW_MEMORY_LFA_BACKOFF_USED = 2, |
| 43 | 44 |
| 44 MAX_BROWSER_HISTOGRAM_CODE = 3, | 45 MAX_BROWSER_HISTOGRAM_CODE = 3, |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 RendererHistogramCode g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE; | 48 RendererHistogramCode g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE; |
| 48 | 49 |
| 49 enum LibraryLoadFromApkSupportCode { | |
| 50 // The device's support for loading a library directly from the APK file. | |
| 51 NOT_SUPPORTED = 0, | |
| 52 SUPPORTED = 1, | |
| 53 | |
| 54 MAX_LIBRARY_LOAD_FROM_APK_SUPPORT_CODE = 2, | |
| 55 }; | |
| 56 | |
| 57 } // namespace | 50 } // namespace |
| 58 | 51 |
| 59 static void RegisterChromiumAndroidLinkerRendererHistogram( | 52 static void RegisterChromiumAndroidLinkerRendererHistogram( |
| 60 JNIEnv* env, | 53 JNIEnv* env, |
| 61 jclass clazz, | 54 jclass clazz, |
| 62 jboolean requested_shared_relro, | 55 jboolean requested_shared_relro, |
| 63 jboolean load_at_fixed_address_failed) { | 56 jboolean load_at_fixed_address_failed) { |
| 64 // Note a pending histogram value for later recording. | 57 // Note a pending histogram value for later recording. |
| 65 if (requested_shared_relro) { | 58 if (requested_shared_relro) { |
| 66 g_renderer_histogram_code = load_at_fixed_address_failed | 59 g_renderer_histogram_code = load_at_fixed_address_failed |
| (...skipping 11 matching lines...) Expand all Loading... |
| 78 g_renderer_histogram_code, | 71 g_renderer_histogram_code, |
| 79 MAX_RENDERER_HISTOGRAM_CODE); | 72 MAX_RENDERER_HISTOGRAM_CODE); |
| 80 g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE; | 73 g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE; |
| 81 } | 74 } |
| 82 | 75 |
| 83 static void RecordChromiumAndroidLinkerBrowserHistogram( | 76 static void RecordChromiumAndroidLinkerBrowserHistogram( |
| 84 JNIEnv* env, | 77 JNIEnv* env, |
| 85 jclass clazz, | 78 jclass clazz, |
| 86 jboolean is_using_browser_shared_relros, | 79 jboolean is_using_browser_shared_relros, |
| 87 jboolean load_at_fixed_address_failed, | 80 jboolean load_at_fixed_address_failed, |
| 88 jboolean library_load_from_apk_supported) { | 81 jint library_load_from_apk_status) { |
| 89 // For low-memory devices, record whether or not we successfully loaded the | 82 // For low-memory devices, record whether or not we successfully loaded the |
| 90 // browser at a fixed address. Otherwise just record a normal invocation. | 83 // browser at a fixed address. Otherwise just record a normal invocation. |
| 91 BrowserHistogramCode histogram_code; | 84 BrowserHistogramCode histogram_code; |
| 92 if (is_using_browser_shared_relros) { | 85 if (is_using_browser_shared_relros) { |
| 93 histogram_code = load_at_fixed_address_failed | 86 histogram_code = load_at_fixed_address_failed |
| 94 ? LOW_MEMORY_LFA_BACKOFF_USED : LOW_MEMORY_LFA_SUCCESS; | 87 ? LOW_MEMORY_LFA_BACKOFF_USED : LOW_MEMORY_LFA_SUCCESS; |
| 95 } else { | 88 } else { |
| 96 histogram_code = NORMAL_LRA_SUCCESS; | 89 histogram_code = NORMAL_LRA_SUCCESS; |
| 97 } | 90 } |
| 98 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.BrowserStates", | 91 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.BrowserStates", |
| 99 histogram_code, | 92 histogram_code, |
| 100 MAX_BROWSER_HISTOGRAM_CODE); | 93 MAX_BROWSER_HISTOGRAM_CODE); |
| 101 | 94 |
| 102 // Record whether the device supports loading a library directly from the APK | 95 // Record the device support for loading a library directly from the APK file. |
| 103 // file. | 96 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.LibraryLoadFromApkStatus", |
| 104 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.LibraryLoadFromApkSupported", | 97 library_load_from_apk_status, |
| 105 library_load_from_apk_supported ? | 98 LIBRARY_LOAD_FROM_APK_STATUS_CODES_MAX); |
| 106 SUPPORTED : NOT_SUPPORTED, | |
| 107 MAX_LIBRARY_LOAD_FROM_APK_SUPPORT_CODE); | |
| 108 } | 99 } |
| 109 | 100 |
| 110 void SetLibraryLoadedHook(LibraryLoadedHook* func) { | 101 void SetLibraryLoadedHook(LibraryLoadedHook* func) { |
| 111 g_registration_callback = func; | 102 g_registration_callback = func; |
| 112 } | 103 } |
| 113 | 104 |
| 114 static void InitCommandLine(JNIEnv* env, jclass clazz, | 105 static void InitCommandLine(JNIEnv* env, jclass clazz, |
| 115 jobjectArray init_command_line) { | 106 jobjectArray init_command_line) { |
| 116 InitNativeCommandLineFromJavaArray(env, init_command_line); | 107 InitNativeCommandLineFromJavaArray(env, init_command_line); |
| 117 } | 108 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 144 jstring GetVersionNumber(JNIEnv* env, jclass clazz) { | 135 jstring GetVersionNumber(JNIEnv* env, jclass clazz) { |
| 145 return ConvertUTF8ToJavaString(env, g_library_version_number).Release(); | 136 return ConvertUTF8ToJavaString(env, g_library_version_number).Release(); |
| 146 } | 137 } |
| 147 | 138 |
| 148 static void RecordNativeLibraryHack(JNIEnv*, jclass, jboolean usedHack) { | 139 static void RecordNativeLibraryHack(JNIEnv*, jclass, jboolean usedHack) { |
| 149 UMA_HISTOGRAM_BOOLEAN("LibraryLoader.NativeLibraryHack", usedHack); | 140 UMA_HISTOGRAM_BOOLEAN("LibraryLoader.NativeLibraryHack", usedHack); |
| 150 } | 141 } |
| 151 | 142 |
| 152 } // namespace android | 143 } // namespace android |
| 153 } // namespace base | 144 } // namespace base |
| OLD | NEW |