| 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/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // Low-memory browser loads at fixed address, success or fail. | 40 // Low-memory browser loads at fixed address, success or fail. |
| 41 LOW_MEMORY_LFA_SUCCESS = 1, | 41 LOW_MEMORY_LFA_SUCCESS = 1, |
| 42 LOW_MEMORY_LFA_BACKOFF_USED = 2, | 42 LOW_MEMORY_LFA_BACKOFF_USED = 2, |
| 43 | 43 |
| 44 MAX_BROWSER_HISTOGRAM_CODE = 3, | 44 MAX_BROWSER_HISTOGRAM_CODE = 3, |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 RendererHistogramCode g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE; | 47 RendererHistogramCode g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE; |
| 48 | 48 |
| 49 enum LibraryLoadFromApkSupportCode { | 49 enum LibraryLoadFromApkSupportCode { |
| 50 // The device's support for loading a library directly from the APK file. | 50 #define DEFINE_LIBRARY_LOAD_FROM_APK_SUPPORT_CODE(name, value) \ |
| 51 NOT_SUPPORTED = 0, | 51 LIBRARY_LOAD_FROM_APK_SUPPORT_CODE_##name = value, |
| 52 SUPPORTED = 1, | 52 #include "library_load_from_apk_support_code.h" |
| 53 | 53 #undef DEFINE_LIBRARY_LOAD_FROM_APK_SUPPORT_CODE |
| 54 MAX_LIBRARY_LOAD_FROM_APK_SUPPORT_CODE = 2, | |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 } // namespace | 56 } // namespace |
| 58 | 57 |
| 59 static void RegisterChromiumAndroidLinkerRendererHistogram( | 58 static void RegisterChromiumAndroidLinkerRendererHistogram( |
| 60 JNIEnv* env, | 59 JNIEnv* env, |
| 61 jclass clazz, | 60 jclass clazz, |
| 62 jboolean requested_shared_relro, | 61 jboolean requested_shared_relro, |
| 63 jboolean load_at_fixed_address_failed) { | 62 jboolean load_at_fixed_address_failed) { |
| 64 // Note a pending histogram value for later recording. | 63 // Note a pending histogram value for later recording. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 78 g_renderer_histogram_code, | 77 g_renderer_histogram_code, |
| 79 MAX_RENDERER_HISTOGRAM_CODE); | 78 MAX_RENDERER_HISTOGRAM_CODE); |
| 80 g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE; | 79 g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE; |
| 81 } | 80 } |
| 82 | 81 |
| 83 static void RecordChromiumAndroidLinkerBrowserHistogram( | 82 static void RecordChromiumAndroidLinkerBrowserHistogram( |
| 84 JNIEnv* env, | 83 JNIEnv* env, |
| 85 jclass clazz, | 84 jclass clazz, |
| 86 jboolean is_using_browser_shared_relros, | 85 jboolean is_using_browser_shared_relros, |
| 87 jboolean load_at_fixed_address_failed, | 86 jboolean load_at_fixed_address_failed, |
| 88 jboolean library_load_from_apk_supported) { | 87 jint library_load_from_apk_support) { |
| 89 // For low-memory devices, record whether or not we successfully loaded the | 88 // For low-memory devices, record whether or not we successfully loaded the |
| 90 // browser at a fixed address. Otherwise just record a normal invocation. | 89 // browser at a fixed address. Otherwise just record a normal invocation. |
| 91 BrowserHistogramCode histogram_code; | 90 BrowserHistogramCode histogram_code; |
| 92 if (is_using_browser_shared_relros) { | 91 if (is_using_browser_shared_relros) { |
| 93 histogram_code = load_at_fixed_address_failed | 92 histogram_code = load_at_fixed_address_failed |
| 94 ? LOW_MEMORY_LFA_BACKOFF_USED : LOW_MEMORY_LFA_SUCCESS; | 93 ? LOW_MEMORY_LFA_BACKOFF_USED : LOW_MEMORY_LFA_SUCCESS; |
| 95 } else { | 94 } else { |
| 96 histogram_code = NORMAL_LRA_SUCCESS; | 95 histogram_code = NORMAL_LRA_SUCCESS; |
| 97 } | 96 } |
| 98 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.BrowserStates", | 97 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.BrowserStates", |
| 99 histogram_code, | 98 histogram_code, |
| 100 MAX_BROWSER_HISTOGRAM_CODE); | 99 MAX_BROWSER_HISTOGRAM_CODE); |
| 101 | 100 |
| 102 // Record whether the device supports loading a library directly from the APK | 101 // Record the device support for loading a library directly from the APK file. |
| 103 // file. | 102 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.LibraryLoadFromApkSupport", |
| 104 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.LibraryLoadFromApkSupported", | 103 library_load_from_apk_support, |
| 105 library_load_from_apk_supported ? | 104 LIBRARY_LOAD_FROM_APK_SUPPORT_CODE_MAX); |
| 106 SUPPORTED : NOT_SUPPORTED, | |
| 107 MAX_LIBRARY_LOAD_FROM_APK_SUPPORT_CODE); | |
| 108 } | 105 } |
| 109 | 106 |
| 110 void SetLibraryLoadedHook(LibraryLoadedHook* func) { | 107 void SetLibraryLoadedHook(LibraryLoadedHook* func) { |
| 111 g_registration_callback = func; | 108 g_registration_callback = func; |
| 112 } | 109 } |
| 113 | 110 |
| 114 static void InitCommandLine(JNIEnv* env, jclass clazz, | 111 static void InitCommandLine(JNIEnv* env, jclass clazz, |
| 115 jobjectArray init_command_line) { | 112 jobjectArray init_command_line) { |
| 116 InitNativeCommandLineFromJavaArray(env, init_command_line); | 113 InitNativeCommandLineFromJavaArray(env, init_command_line); |
| 117 } | 114 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 144 jstring GetVersionNumber(JNIEnv* env, jclass clazz) { | 141 jstring GetVersionNumber(JNIEnv* env, jclass clazz) { |
| 145 return ConvertUTF8ToJavaString(env, g_library_version_number).Release(); | 142 return ConvertUTF8ToJavaString(env, g_library_version_number).Release(); |
| 146 } | 143 } |
| 147 | 144 |
| 148 static void RecordNativeLibraryHack(JNIEnv*, jclass, jboolean usedHack) { | 145 static void RecordNativeLibraryHack(JNIEnv*, jclass, jboolean usedHack) { |
| 149 UMA_HISTOGRAM_BOOLEAN("LibraryLoader.NativeLibraryHack", usedHack); | 146 UMA_HISTOGRAM_BOOLEAN("LibraryLoader.NativeLibraryHack", usedHack); |
| 150 } | 147 } |
| 151 | 148 |
| 152 } // namespace android | 149 } // namespace android |
| 153 } // namespace base | 150 } // namespace base |
| OLD | NEW |