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

Side by Side Diff: base/android/library_loader/library_loader_hooks.cc

Issue 663543003: Fix low-memory devices crashing on Chrome start up during UMA recodring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // The device's support for loading a library directly from the APK file.
51 NOT_SUPPORTED = 0, 51 NOT_SUPPORTED = 0,
52 SUPPORTED = 1, 52 SUPPORTED = 1,
53 53
54 MAX_LIBRARY_LOAD_FROM_APK_SUPPORT_CODE = 2, 54 // The loader was unable to determine whether the funcionality is supported.
Ilya Sherman 2014/10/16 19:00:30 nit: "funcionality" -> "functionality"
petrcermak 2014/10/17 14:51:28 Done.
55 UNKNOWN = 2,
Ilya Sherman 2014/10/16 19:00:30 nit: I'd recommend moving this to be the first ite
petrcermak 2014/10/17 14:51:28 Done. It is very likely that more values will inde
56
57 MAX_LIBRARY_LOAD_FROM_APK_SUPPORT_CODE = 3,
55 }; 58 };
picksi1 2014/10/17 08:23:24 You should probably have the enums named the same
petrcermak 2014/10/17 14:51:28 Done.
56 59
57 } // namespace 60 } // namespace
58 61
59 static void RegisterChromiumAndroidLinkerRendererHistogram( 62 static void RegisterChromiumAndroidLinkerRendererHistogram(
60 JNIEnv* env, 63 JNIEnv* env,
61 jclass clazz, 64 jclass clazz,
62 jboolean requested_shared_relro, 65 jboolean requested_shared_relro,
63 jboolean load_at_fixed_address_failed) { 66 jboolean load_at_fixed_address_failed) {
64 // Note a pending histogram value for later recording. 67 // Note a pending histogram value for later recording.
65 if (requested_shared_relro) { 68 if (requested_shared_relro) {
(...skipping 12 matching lines...) Expand all
78 g_renderer_histogram_code, 81 g_renderer_histogram_code,
79 MAX_RENDERER_HISTOGRAM_CODE); 82 MAX_RENDERER_HISTOGRAM_CODE);
80 g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE; 83 g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE;
81 } 84 }
82 85
83 static void RecordChromiumAndroidLinkerBrowserHistogram( 86 static void RecordChromiumAndroidLinkerBrowserHistogram(
84 JNIEnv* env, 87 JNIEnv* env,
85 jclass clazz, 88 jclass clazz,
86 jboolean is_using_browser_shared_relros, 89 jboolean is_using_browser_shared_relros,
87 jboolean load_at_fixed_address_failed, 90 jboolean load_at_fixed_address_failed,
88 jboolean library_load_from_apk_supported) { 91 jint library_load_from_apk_support) {
89 // For low-memory devices, record whether or not we successfully loaded the 92 // For low-memory devices, record whether or not we successfully loaded the
90 // browser at a fixed address. Otherwise just record a normal invocation. 93 // browser at a fixed address. Otherwise just record a normal invocation.
91 BrowserHistogramCode histogram_code; 94 BrowserHistogramCode histogram_code;
92 if (is_using_browser_shared_relros) { 95 if (is_using_browser_shared_relros) {
93 histogram_code = load_at_fixed_address_failed 96 histogram_code = load_at_fixed_address_failed
94 ? LOW_MEMORY_LFA_BACKOFF_USED : LOW_MEMORY_LFA_SUCCESS; 97 ? LOW_MEMORY_LFA_BACKOFF_USED : LOW_MEMORY_LFA_SUCCESS;
95 } else { 98 } else {
96 histogram_code = NORMAL_LRA_SUCCESS; 99 histogram_code = NORMAL_LRA_SUCCESS;
97 } 100 }
98 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.BrowserStates", 101 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.BrowserStates",
99 histogram_code, 102 histogram_code,
100 MAX_BROWSER_HISTOGRAM_CODE); 103 MAX_BROWSER_HISTOGRAM_CODE);
101 104
102 // Record whether the device supports loading a library directly from the APK 105 // Record the device support for loading a library directly from the APK file.
103 // file. 106 if (library_load_from_apk_support < 0 ||
104 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.LibraryLoadFromApkSupported", 107 library_load_from_apk_support >= MAX_LIBRARY_LOAD_FROM_APK_SUPPORT_CODE) {
105 library_load_from_apk_supported ? 108 library_load_from_apk_support = UNKNOWN;
picksi1 2014/10/17 08:23:24 Definitely replace the '0' with NOT_SUPPORTED enum
rmcilroy 2014/10/17 09:12:59 I actually think that might be more error prone si
picksi1 2014/10/17 09:23:51 If we ditched the default entry in the case statem
rmcilroy 2014/10/17 09:54:45 +1 this sounds good.
petrcermak 2014/10/17 14:51:28 Done.
petrcermak 2014/10/17 14:51:28 After a discussion with simonb, we concluded that
106 SUPPORTED : NOT_SUPPORTED, 109 }
110 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.LibraryLoadFromApkSupport",
111 library_load_from_apk_support,
107 MAX_LIBRARY_LOAD_FROM_APK_SUPPORT_CODE); 112 MAX_LIBRARY_LOAD_FROM_APK_SUPPORT_CODE);
108 } 113 }
109 114
110 void SetLibraryLoadedHook(LibraryLoadedHook* func) { 115 void SetLibraryLoadedHook(LibraryLoadedHook* func) {
111 g_registration_callback = func; 116 g_registration_callback = func;
112 } 117 }
113 118
114 static void InitCommandLine(JNIEnv* env, jclass clazz, 119 static void InitCommandLine(JNIEnv* env, jclass clazz,
115 jobjectArray init_command_line) { 120 jobjectArray init_command_line) {
116 InitNativeCommandLineFromJavaArray(env, init_command_line); 121 InitNativeCommandLineFromJavaArray(env, init_command_line);
(...skipping 27 matching lines...) Expand all
144 jstring GetVersionNumber(JNIEnv* env, jclass clazz) { 149 jstring GetVersionNumber(JNIEnv* env, jclass clazz) {
145 return ConvertUTF8ToJavaString(env, g_library_version_number).Release(); 150 return ConvertUTF8ToJavaString(env, g_library_version_number).Release();
146 } 151 }
147 152
148 static void RecordNativeLibraryHack(JNIEnv*, jclass, jboolean usedHack) { 153 static void RecordNativeLibraryHack(JNIEnv*, jclass, jboolean usedHack) {
149 UMA_HISTOGRAM_BOOLEAN("LibraryLoader.NativeLibraryHack", usedHack); 154 UMA_HISTOGRAM_BOOLEAN("LibraryLoader.NativeLibraryHack", usedHack);
150 } 155 }
151 156
152 } // namespace android 157 } // namespace android
153 } // namespace base 158 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698