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

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

Issue 2050803003: Update to Chromium //base at Chromium commit e3a753f17bac62738b0dbf0b36510f767b081e4b. (Closed) Base URL: https://github.com/domokit/base.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
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"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 // The amount of time, in milliseconds, that it took to load the shared 51 // The amount of time, in milliseconds, that it took to load the shared
52 // libraries in the renderer. Set in 52 // libraries in the renderer. Set in
53 // RegisterChromiumAndroidLinkerRendererHistogram. 53 // RegisterChromiumAndroidLinkerRendererHistogram.
54 long g_renderer_library_load_time_ms = 0; 54 long g_renderer_library_load_time_ms = 0;
55 55
56 } // namespace 56 } // namespace
57 57
58 static void RegisterChromiumAndroidLinkerRendererHistogram( 58 static void RegisterChromiumAndroidLinkerRendererHistogram(
59 JNIEnv* env, 59 JNIEnv* env,
60 jobject jcaller, 60 const JavaParamRef<jobject>& jcaller,
61 jboolean requested_shared_relro, 61 jboolean requested_shared_relro,
62 jboolean load_at_fixed_address_failed, 62 jboolean load_at_fixed_address_failed,
63 jlong library_load_time_ms) { 63 jlong library_load_time_ms) {
64 // Note a pending histogram value for later recording. 64 // Note a pending histogram value for later recording.
65 if (requested_shared_relro) { 65 if (requested_shared_relro) {
66 g_renderer_histogram_code = load_at_fixed_address_failed 66 g_renderer_histogram_code = load_at_fixed_address_failed
67 ? LFA_BACKOFF_USED : LFA_SUCCESS; 67 ? LFA_BACKOFF_USED : LFA_SUCCESS;
68 } else { 68 } else {
69 g_renderer_histogram_code = LFA_NOT_ATTEMPTED; 69 g_renderer_histogram_code = LFA_NOT_ATTEMPTED;
70 } 70 }
(...skipping 11 matching lines...) Expand all
82 g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE; 82 g_renderer_histogram_code = NO_PENDING_HISTOGRAM_CODE;
83 83
84 // Record how long it took to load the shared libraries. 84 // Record how long it took to load the shared libraries.
85 UMA_HISTOGRAM_TIMES( 85 UMA_HISTOGRAM_TIMES(
86 "ChromiumAndroidLinker.RendererLoadTime", 86 "ChromiumAndroidLinker.RendererLoadTime",
87 base::TimeDelta::FromMilliseconds(g_renderer_library_load_time_ms)); 87 base::TimeDelta::FromMilliseconds(g_renderer_library_load_time_ms));
88 } 88 }
89 89
90 static void RecordChromiumAndroidLinkerBrowserHistogram( 90 static void RecordChromiumAndroidLinkerBrowserHistogram(
91 JNIEnv* env, 91 JNIEnv* env,
92 jobject jcaller, 92 const JavaParamRef<jobject>& jcaller,
93 jboolean is_using_browser_shared_relros, 93 jboolean is_using_browser_shared_relros,
94 jboolean load_at_fixed_address_failed, 94 jboolean load_at_fixed_address_failed,
95 jint library_load_from_apk_status, 95 jint library_load_from_apk_status,
96 jlong library_load_time_ms) { 96 jlong library_load_time_ms) {
97 // For low-memory devices, record whether or not we successfully loaded the 97 // For low-memory devices, record whether or not we successfully loaded the
98 // browser at a fixed address. Otherwise just record a normal invocation. 98 // browser at a fixed address. Otherwise just record a normal invocation.
99 BrowserHistogramCode histogram_code; 99 BrowserHistogramCode histogram_code;
100 if (is_using_browser_shared_relros) { 100 if (is_using_browser_shared_relros) {
101 histogram_code = load_at_fixed_address_failed 101 histogram_code = load_at_fixed_address_failed
102 ? LOW_MEMORY_LFA_BACKOFF_USED : LOW_MEMORY_LFA_SUCCESS; 102 ? LOW_MEMORY_LFA_BACKOFF_USED : LOW_MEMORY_LFA_SUCCESS;
(...skipping 11 matching lines...) Expand all
114 114
115 // Record how long it took to load the shared libraries. 115 // Record how long it took to load the shared libraries.
116 UMA_HISTOGRAM_TIMES("ChromiumAndroidLinker.BrowserLoadTime", 116 UMA_HISTOGRAM_TIMES("ChromiumAndroidLinker.BrowserLoadTime",
117 base::TimeDelta::FromMilliseconds(library_load_time_ms)); 117 base::TimeDelta::FromMilliseconds(library_load_time_ms));
118 } 118 }
119 119
120 void SetLibraryLoadedHook(LibraryLoadedHook* func) { 120 void SetLibraryLoadedHook(LibraryLoadedHook* func) {
121 g_registration_callback = func; 121 g_registration_callback = func;
122 } 122 }
123 123
124 static void InitCommandLine(JNIEnv* env, 124 static void InitCommandLine(
125 jobject jcaller, 125 JNIEnv* env,
126 jobjectArray init_command_line) { 126 const JavaParamRef<jobject>& jcaller,
127 const JavaParamRef<jobjectArray>& init_command_line) {
127 InitNativeCommandLineFromJavaArray(env, init_command_line); 128 InitNativeCommandLineFromJavaArray(env, init_command_line);
128 } 129 }
129 130
130 static jboolean LibraryLoaded(JNIEnv* env, jobject jcaller) { 131 static jboolean LibraryLoaded(JNIEnv* env,
132 const JavaParamRef<jobject>& jcaller) {
131 if (g_registration_callback == NULL) { 133 if (g_registration_callback == NULL) {
132 return true; 134 return true;
133 } 135 }
134 return g_registration_callback(env, NULL); 136 return g_registration_callback(env, NULL);
135 } 137 }
136 138
137 void LibraryLoaderExitHook() { 139 void LibraryLoaderExitHook() {
138 if (g_at_exit_manager) { 140 if (g_at_exit_manager) {
139 delete g_at_exit_manager; 141 delete g_at_exit_manager;
140 g_at_exit_manager = NULL; 142 g_at_exit_manager = NULL;
141 } 143 }
142 } 144 }
143 145
144 static jboolean ForkAndPrefetchNativeLibrary(JNIEnv* env, jclass clazz) { 146 static jboolean ForkAndPrefetchNativeLibrary(
147 JNIEnv* env,
148 const JavaParamRef<jclass>& clazz) {
145 return NativeLibraryPrefetcher::ForkAndPrefetchNativeLibrary(); 149 return NativeLibraryPrefetcher::ForkAndPrefetchNativeLibrary();
146 } 150 }
147 151
148 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { 152 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) {
149 return RegisterNativesImpl(env); 153 return RegisterNativesImpl(env);
150 } 154 }
151 155
152 void SetVersionNumber(const char* version_number) { 156 void SetVersionNumber(const char* version_number) {
153 g_library_version_number = strdup(version_number); 157 g_library_version_number = strdup(version_number);
154 } 158 }
155 159
156 ScopedJavaLocalRef<jstring> GetVersionNumber(JNIEnv* env, jobject jcaller) { 160 ScopedJavaLocalRef<jstring> GetVersionNumber(
161 JNIEnv* env,
162 const JavaParamRef<jobject>& jcaller) {
157 return ConvertUTF8ToJavaString(env, g_library_version_number); 163 return ConvertUTF8ToJavaString(env, g_library_version_number);
158 } 164 }
159 165
160 LibraryProcessType GetLibraryProcessType(JNIEnv* env) { 166 LibraryProcessType GetLibraryProcessType(JNIEnv* env) {
161 return static_cast<LibraryProcessType>( 167 return static_cast<LibraryProcessType>(
162 Java_LibraryLoader_getLibraryProcessType(env)); 168 Java_LibraryLoader_getLibraryProcessType(env));
163 } 169 }
164 170
165 void InitAtExitManager() { 171 void InitAtExitManager() {
166 g_at_exit_manager = new base::AtExitManager(); 172 g_at_exit_manager = new base::AtExitManager();
167 } 173 }
168 174
169 } // namespace android 175 } // namespace android
170 } // namespace base 176 } // namespace base
OLDNEW
« no previous file with comments | « android/junit/src/org/chromium/base/LogTest.java ('k') | android/library_loader/library_prefetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698