Chromium Code Reviews| 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/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 } | 116 } |
| 117 | 117 |
| 118 void LibraryLoaderExitHook() { | 118 void LibraryLoaderExitHook() { |
| 119 if (g_at_exit_manager) { | 119 if (g_at_exit_manager) { |
| 120 delete g_at_exit_manager; | 120 delete g_at_exit_manager; |
| 121 g_at_exit_manager = NULL; | 121 g_at_exit_manager = NULL; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { | 125 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { |
| 126 // TODO(michaelbai): Remove this after refactoring all dependents. | |
| 127 InitAtExitManager(); | |
| 126 // We need the AtExitManager to be created at the very beginning. | 128 // We need the AtExitManager to be created at the very beginning. |
| 127 g_at_exit_manager = new base::AtExitManager(); | 129 DCHECK(g_at_exit_manager); |
| 128 | |
| 129 return RegisterNativesImpl(env); | 130 return RegisterNativesImpl(env); |
| 130 } | 131 } |
| 131 | 132 |
| 132 void SetVersionNumber(const char* version_number) { | 133 void SetVersionNumber(const char* version_number) { |
| 133 g_library_version_number = strdup(version_number); | 134 g_library_version_number = strdup(version_number); |
| 134 } | 135 } |
| 135 | 136 |
| 136 jstring GetVersionNumber(JNIEnv* env, jobject jcaller) { | 137 jstring GetVersionNumber(JNIEnv* env, jobject jcaller) { |
| 137 return ConvertUTF8ToJavaString(env, g_library_version_number).Release(); | 138 return ConvertUTF8ToJavaString(env, g_library_version_number).Release(); |
| 138 } | 139 } |
| 139 | 140 |
| 140 LibraryProcessType GetLibraryProcessType(JNIEnv* env) { | 141 LibraryProcessType GetLibraryProcessType(JNIEnv* env) { |
| 141 return static_cast<LibraryProcessType>( | 142 return static_cast<LibraryProcessType>( |
| 142 Java_LibraryLoader_getLibraryProcessType(env)); | 143 Java_LibraryLoader_getLibraryProcessType(env)); |
| 143 } | 144 } |
| 144 | 145 |
| 146 void InitAtExitManager() { | |
|
Torne
2015/03/11 18:08:29
Why do we need to InitAtExitManager in this way at
michaelbai
2015/03/11 18:29:10
As I said in my previous comment, I am refactoring
| |
| 147 g_at_exit_manager = new base::AtExitManager(); | |
| 148 } | |
| 149 | |
| 145 } // namespace android | 150 } // namespace android |
| 146 } // namespace base | 151 } // namespace base |
| OLD | NEW |