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

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

Issue 2015533005: Record the return value of NativeLibraryPreloader.loadLibrary in UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « base/android/library_loader/library_loader_hooks.h ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/android/library_loader/library_load_from_apk_status_codes.h" 9 #include "base/android/library_loader/library_load_from_apk_status_codes.h"
10 #include "base/android/library_loader/library_prefetcher.h" 10 #include "base/android/library_loader/library_prefetcher.h"
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/metrics/sparse_histogram.h"
13 #include "jni/LibraryLoader_jni.h" 14 #include "jni/LibraryLoader_jni.h"
14 15
15 namespace base { 16 namespace base {
16 namespace android { 17 namespace android {
17 18
18 namespace { 19 namespace {
19 20
20 base::AtExitManager* g_at_exit_manager = NULL; 21 base::AtExitManager* g_at_exit_manager = NULL;
21 const char* g_library_version_number = ""; 22 const char* g_library_version_number = "";
22 LibraryLoadedHook* g_registration_callback = NULL; 23 LibraryLoadedHook* g_registration_callback = NULL;
(...skipping 18 matching lines...) Expand all
41 42
42 // Low-memory browser loads at fixed address, success or fail. 43 // Low-memory browser loads at fixed address, success or fail.
43 LOW_MEMORY_LFA_SUCCESS = 1, 44 LOW_MEMORY_LFA_SUCCESS = 1,
44 LOW_MEMORY_LFA_BACKOFF_USED = 2, 45 LOW_MEMORY_LFA_BACKOFF_USED = 2,
45 46
46 MAX_BROWSER_HISTOGRAM_CODE = 3, 47 MAX_BROWSER_HISTOGRAM_CODE = 3,
47 }; 48 };
48 49
49 RendererHistogramCode g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE; 50 RendererHistogramCode g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE;
50 51
52 // Indicate whether g_library_preloader_renderer_histogram_code is valid
53 bool g_library_preloader_renderer_histogram_code_registered = false;
54
55 // The return value of NativeLibraryPreloader.loadLibrary() in child processes,
56 // it is initialized to the invalid value which shouldn't showup in UMA report.
57 int g_library_preloader_renderer_histogram_code = -1;
58
51 // The amount of time, in milliseconds, that it took to load the shared 59 // The amount of time, in milliseconds, that it took to load the shared
52 // libraries in the renderer. Set in 60 // libraries in the renderer. Set in
53 // RegisterChromiumAndroidLinkerRendererHistogram. 61 // RegisterChromiumAndroidLinkerRendererHistogram.
54 long g_renderer_library_load_time_ms = 0; 62 long g_renderer_library_load_time_ms = 0;
55 63
64 void RecordChromiumAndroidLinkerRendererHistogram() {
65 if (g_renderer_histogram_code == NO_PENDING_HISTOGRAM_CODE)
66 return;
67 // Record and release the pending histogram value.
68 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.RendererStates",
69 g_renderer_histogram_code,
70 MAX_RENDERER_HISTOGRAM_CODE);
71 g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE;
72
73 // Record how long it took to load the shared libraries.
74 UMA_HISTOGRAM_TIMES("ChromiumAndroidLinker.RendererLoadTime",
75 base::TimeDelta::FromMilliseconds(g_renderer_library_load_time_ms));
76 }
77
78 void RecordLibraryPreloaderRendereHistogram() {
79 if (g_library_preloader_renderer_histogram_code_registered) {
80 UMA_HISTOGRAM_SPARSE_SLOWLY(
81 "Android.NativeLibraryPreloader.Result.Renderer",
82 g_library_preloader_renderer_histogram_code);
83 }
84 }
85
56 } // namespace 86 } // namespace
57 87
58 static void RegisterChromiumAndroidLinkerRendererHistogram( 88 static void RegisterChromiumAndroidLinkerRendererHistogram(
59 JNIEnv* env, 89 JNIEnv* env,
60 const JavaParamRef<jobject>& jcaller, 90 const JavaParamRef<jobject>& jcaller,
61 jboolean requested_shared_relro, 91 jboolean requested_shared_relro,
62 jboolean load_at_fixed_address_failed, 92 jboolean load_at_fixed_address_failed,
63 jlong library_load_time_ms) { 93 jlong library_load_time_ms) {
64 // Note a pending histogram value for later recording. 94 // Note a pending histogram value for later recording.
65 if (requested_shared_relro) { 95 if (requested_shared_relro) {
66 g_renderer_histogram_code = load_at_fixed_address_failed 96 g_renderer_histogram_code = load_at_fixed_address_failed
67 ? LFA_BACKOFF_USED : LFA_SUCCESS; 97 ? LFA_BACKOFF_USED : LFA_SUCCESS;
68 } else { 98 } else {
69 g_renderer_histogram_code = LFA_NOT_ATTEMPTED; 99 g_renderer_histogram_code = LFA_NOT_ATTEMPTED;
70 } 100 }
71 101
72 g_renderer_library_load_time_ms = library_load_time_ms; 102 g_renderer_library_load_time_ms = library_load_time_ms;
73 } 103 }
74 104
75 void RecordChromiumAndroidLinkerRendererHistogram() {
76 if (g_renderer_histogram_code == NO_PENDING_HISTOGRAM_CODE)
77 return;
78 // Record and release the pending histogram value.
79 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.RendererStates",
80 g_renderer_histogram_code,
81 MAX_RENDERER_HISTOGRAM_CODE);
82 g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE;
83
84 // Record how long it took to load the shared libraries.
85 UMA_HISTOGRAM_TIMES("ChromiumAndroidLinker.RendererLoadTime",
86 base::TimeDelta::FromMilliseconds(g_renderer_library_load_time_ms));
87 }
88
89 static void RecordChromiumAndroidLinkerBrowserHistogram( 105 static void RecordChromiumAndroidLinkerBrowserHistogram(
90 JNIEnv* env, 106 JNIEnv* env,
91 const JavaParamRef<jobject>& jcaller, 107 const JavaParamRef<jobject>& jcaller,
92 jboolean is_using_browser_shared_relros, 108 jboolean is_using_browser_shared_relros,
93 jboolean load_at_fixed_address_failed, 109 jboolean load_at_fixed_address_failed,
94 jint library_load_from_apk_status, 110 jint library_load_from_apk_status,
95 jlong library_load_time_ms) { 111 jlong library_load_time_ms) {
96 // For low-memory devices, record whether or not we successfully loaded the 112 // For low-memory devices, record whether or not we successfully loaded the
97 // browser at a fixed address. Otherwise just record a normal invocation. 113 // browser at a fixed address. Otherwise just record a normal invocation.
98 BrowserHistogramCode histogram_code; 114 BrowserHistogramCode histogram_code;
(...skipping 10 matching lines...) Expand all
109 // Record the device support for loading a library directly from the APK file. 125 // Record the device support for loading a library directly from the APK file.
110 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.LibraryLoadFromApkStatus", 126 UMA_HISTOGRAM_ENUMERATION("ChromiumAndroidLinker.LibraryLoadFromApkStatus",
111 library_load_from_apk_status, 127 library_load_from_apk_status,
112 LIBRARY_LOAD_FROM_APK_STATUS_CODES_MAX); 128 LIBRARY_LOAD_FROM_APK_STATUS_CODES_MAX);
113 129
114 // Record how long it took to load the shared libraries. 130 // Record how long it took to load the shared libraries.
115 UMA_HISTOGRAM_TIMES("ChromiumAndroidLinker.BrowserLoadTime", 131 UMA_HISTOGRAM_TIMES("ChromiumAndroidLinker.BrowserLoadTime",
116 base::TimeDelta::FromMilliseconds(library_load_time_ms)); 132 base::TimeDelta::FromMilliseconds(library_load_time_ms));
117 } 133 }
118 134
135 static void RecordLibraryPreloaderBrowserHistogram(
136 JNIEnv* env,
137 const JavaParamRef<jobject>& jcaller,
138 jint status) {
139 UMA_HISTOGRAM_SPARSE_SLOWLY(
140 "Android.NativeLibraryPreloader.Result.Browser",
141 status);
142 }
143
144 static void RegisterLibraryPreloaderRendererHistogram(
145 JNIEnv* env,
146 const JavaParamRef<jobject>& jcaller,
147 jint status) {
148 g_library_preloader_renderer_histogram_code = status;
149 g_library_preloader_renderer_histogram_code_registered = true;
150 }
151
152 void RecordLibraryLoaderRendererHistograms() {
153 RecordChromiumAndroidLinkerRendererHistogram();
154 RecordLibraryPreloaderRendereHistogram();
155 }
156
119 void SetLibraryLoadedHook(LibraryLoadedHook* func) { 157 void SetLibraryLoadedHook(LibraryLoadedHook* func) {
120 g_registration_callback = func; 158 g_registration_callback = func;
121 } 159 }
122 160
123 static void InitCommandLine( 161 static void InitCommandLine(
124 JNIEnv* env, 162 JNIEnv* env,
125 const JavaParamRef<jobject>& jcaller, 163 const JavaParamRef<jobject>& jcaller,
126 const JavaParamRef<jobjectArray>& init_command_line) { 164 const JavaParamRef<jobjectArray>& init_command_line) {
127 InitNativeCommandLineFromJavaArray(env, init_command_line); 165 InitNativeCommandLineFromJavaArray(env, init_command_line);
128 } 166 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return static_cast<LibraryProcessType>( 210 return static_cast<LibraryProcessType>(
173 Java_LibraryLoader_getLibraryProcessType(env)); 211 Java_LibraryLoader_getLibraryProcessType(env));
174 } 212 }
175 213
176 void InitAtExitManager() { 214 void InitAtExitManager() {
177 g_at_exit_manager = new base::AtExitManager(); 215 g_at_exit_manager = new base::AtExitManager();
178 } 216 }
179 217
180 } // namespace android 218 } // namespace android
181 } // namespace base 219 } // namespace base
OLDNEW
« no previous file with comments | « base/android/library_loader/library_loader_hooks.h ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698