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

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

Issue 141223002: Move the android library loader from content to base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/android/library_loader/library_loader_hooks.h"
6
7 #include "base/at_exit.h"
8 #include "base/metrics/histogram.h"
9 #include "jni/LibraryLoader_jni.h"
10
11 namespace base {
12 namespace android {
13
14 namespace {
15
16 base::AtExitManager* g_at_exit_manager = NULL;
17 const char* g_library_version_number = "";
18 LibraryLoaderHook* g_jni_registration_callback = NULL;
19
20 } // namespace
21
22 void SetLibraryLoadedHook(LibraryLoaderHook* func) {
23 g_jni_registration_callback = func;
Yaron 2014/01/17 02:18:25 Don't think this needs to refer to "jni"
aberent 2014/01/30 17:46:05 Done.
24 }
25
26 static jboolean LibraryLoaded(JNIEnv* env, jclass clazz,
27 jobjectArray init_command_line) {
28 return g_jni_registration_callback(env, clazz, init_command_line);
29 }
30
31 static void RecordContentAndroidLinkerHistogram(
32 JNIEnv* env,
33 jclass clazz,
34 jboolean loaded_at_fixed_address_failed,
35 jboolean is_low_memory_device) {
36 UMA_HISTOGRAM_BOOLEAN("ContentAndroidLinker.LoadedAtFixedAddressFailed",
37 loaded_at_fixed_address_failed);
38 UMA_HISTOGRAM_BOOLEAN("ContentAndroidLinker.IsLowMemoryDevice",
39 is_low_memory_device);
40 }
41
42 void LibraryLoaderExitHook() {
43 if (g_at_exit_manager) {
44 delete g_at_exit_manager;
45 g_at_exit_manager = NULL;
46 }
47 }
48
49 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) {
50 // We need the AtExitManager to be created at the very beginning.
51 g_at_exit_manager = new base::AtExitManager();
52
53 return RegisterNativesImpl(env);
54 }
55
56 void SetVersionNumber(const char* version_number) {
57 g_library_version_number = strdup(version_number);
58 }
59
60 jstring GetVersionNumber(JNIEnv* env, jclass clazz) {
61 return env->NewStringUTF(g_library_version_number);
62 }
63
64 } // namespace android
65 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698