| 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/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/at_exit.h" | 11 #include "base/at_exit.h" |
| 11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 12 #include "jni/LibraryLoader_jni.h" | 13 #include "jni/LibraryLoader_jni.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 namespace android { | 16 namespace android { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 base::AtExitManager* g_at_exit_manager = NULL; | 20 base::AtExitManager* g_at_exit_manager = NULL; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 return g_registration_callback(env, NULL); | 116 return g_registration_callback(env, NULL); |
| 116 } | 117 } |
| 117 | 118 |
| 118 void LibraryLoaderExitHook() { | 119 void LibraryLoaderExitHook() { |
| 119 if (g_at_exit_manager) { | 120 if (g_at_exit_manager) { |
| 120 delete g_at_exit_manager; | 121 delete g_at_exit_manager; |
| 121 g_at_exit_manager = NULL; | 122 g_at_exit_manager = NULL; |
| 122 } | 123 } |
| 123 } | 124 } |
| 124 | 125 |
| 126 static jboolean ForkAndPrefetchNativeLibrary(JNIEnv* env, jclass clazz) { |
| 127 return NativeLibraryPrefetcher::ForkAndPrefetchNativeLibrary(); |
| 128 } |
| 129 |
| 125 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { | 130 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { |
| 126 return RegisterNativesImpl(env); | 131 return RegisterNativesImpl(env); |
| 127 } | 132 } |
| 128 | 133 |
| 129 void SetVersionNumber(const char* version_number) { | 134 void SetVersionNumber(const char* version_number) { |
| 130 g_library_version_number = strdup(version_number); | 135 g_library_version_number = strdup(version_number); |
| 131 } | 136 } |
| 132 | 137 |
| 133 jstring GetVersionNumber(JNIEnv* env, jobject jcaller) { | 138 jstring GetVersionNumber(JNIEnv* env, jobject jcaller) { |
| 134 return ConvertUTF8ToJavaString(env, g_library_version_number).Release(); | 139 return ConvertUTF8ToJavaString(env, g_library_version_number).Release(); |
| 135 } | 140 } |
| 136 | 141 |
| 137 LibraryProcessType GetLibraryProcessType(JNIEnv* env) { | 142 LibraryProcessType GetLibraryProcessType(JNIEnv* env) { |
| 138 return static_cast<LibraryProcessType>( | 143 return static_cast<LibraryProcessType>( |
| 139 Java_LibraryLoader_getLibraryProcessType(env)); | 144 Java_LibraryLoader_getLibraryProcessType(env)); |
| 140 } | 145 } |
| 141 | 146 |
| 142 void InitAtExitManager() { | 147 void InitAtExitManager() { |
| 143 g_at_exit_manager = new base::AtExitManager(); | 148 g_at_exit_manager = new base::AtExitManager(); |
| 144 } | 149 } |
| 145 | 150 |
| 146 } // namespace android | 151 } // namespace android |
| 147 } // namespace base | 152 } // namespace base |
| OLD | NEW |