| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/public/app/android_library_loader_hooks.h" | 5 #include "content/public/app/android_library_loader_hooks.h" |
| 6 | 6 |
| 7 #include "base/android/base_jni_registrar.h" | 7 #include "base/android/base_jni_registrar.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_registrar.h" | 9 #include "base/android/jni_registrar.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
| 26 #include "content/public/common/result_codes.h" | 26 #include "content/public/common/result_codes.h" |
| 27 #include "jni/LibraryLoader_jni.h" | 27 #include "jni/LibraryLoader_jni.h" |
| 28 #include "media/base/android/media_jni_registrar.h" | 28 #include "media/base/android/media_jni_registrar.h" |
| 29 #include "net/android/net_jni_registrar.h" | 29 #include "net/android/net_jni_registrar.h" |
| 30 #include "ui/base/android/ui_jni_registrar.h" | 30 #include "ui/base/android/ui_jni_registrar.h" |
| 31 #include "ui/gfx/android/gfx_jni_registrar.h" | 31 #include "ui/gfx/android/gfx_jni_registrar.h" |
| 32 #include "ui/gl/android/gl_jni_registrar.h" | 32 #include "ui/gl/android/gl_jni_registrar.h" |
| 33 #include "ui/shell_dialogs/android/shell_dialogs_jni_registrar.h" | 33 #include "ui/shell_dialogs/android/shell_dialogs_jni_registrar.h" |
| 34 | 34 |
| 35 namespace content { |
| 36 |
| 35 namespace { | 37 namespace { |
| 36 base::AtExitManager* g_at_exit_manager = NULL; | 38 base::AtExitManager* g_at_exit_manager = NULL; |
| 37 } | 39 } |
| 38 | 40 |
| 39 namespace content { | 41 bool EnsureJniRegistered(JNIEnv* env) { |
| 42 static bool g_jni_init_done = false; |
| 43 |
| 44 if (!g_jni_init_done) { |
| 45 if (!base::android::RegisterJni(env)) |
| 46 return false; |
| 47 |
| 48 if (!gfx::android::RegisterJni(env)) |
| 49 return false; |
| 50 |
| 51 if (!net::android::RegisterJni(env)) |
| 52 return false; |
| 53 |
| 54 if (!ui::android::RegisterJni(env)) |
| 55 return false; |
| 56 |
| 57 if (!ui::gl::android::RegisterJni(env)) |
| 58 return false; |
| 59 |
| 60 if (!ui::shell_dialogs::RegisterJni(env)) |
| 61 return false; |
| 62 |
| 63 if (!content::android::RegisterChildJni(env)) |
| 64 return false; |
| 65 |
| 66 if (!content::android::RegisterCommonJni(env)) |
| 67 return false; |
| 68 |
| 69 if (!content::android::RegisterBrowserJni(env)) |
| 70 return false; |
| 71 |
| 72 if (!content::android::RegisterAppJni(env)) |
| 73 return false; |
| 74 |
| 75 if (!media::RegisterJni(env)) |
| 76 return false; |
| 77 |
| 78 g_jni_init_done = true; |
| 79 } |
| 80 |
| 81 return true; |
| 82 } |
| 40 | 83 |
| 41 static jint LibraryLoaded(JNIEnv* env, jclass clazz, | 84 static jint LibraryLoaded(JNIEnv* env, jclass clazz, |
| 42 jobjectArray init_command_line) { | 85 jobjectArray init_command_line) { |
| 43 InitNativeCommandLineFromJavaArray(env, init_command_line); | 86 InitNativeCommandLineFromJavaArray(env, init_command_line); |
| 44 | 87 |
| 45 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 88 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 46 | 89 |
| 47 if (command_line->HasSwitch(switches::kTraceStartup)) { | 90 if (command_line->HasSwitch(switches::kTraceStartup)) { |
| 48 base::debug::CategoryFilter category_filter( | 91 base::debug::CategoryFilter category_filter( |
| 49 command_line->GetSwitchValueASCII(switches::kTraceStartup)); | 92 command_line->GetSwitchValueASCII(switches::kTraceStartup)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 65 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; | 108 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; |
| 66 logging::InitLogging(settings); | 109 logging::InitLogging(settings); |
| 67 // To view log output with IDs and timestamps use "adb logcat -v threadtime". | 110 // To view log output with IDs and timestamps use "adb logcat -v threadtime". |
| 68 logging::SetLogItems(false, // Process ID | 111 logging::SetLogItems(false, // Process ID |
| 69 false, // Thread ID | 112 false, // Thread ID |
| 70 false, // Timestamp | 113 false, // Timestamp |
| 71 false); // Tick count | 114 false); // Tick count |
| 72 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() | 115 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() |
| 73 << ", default verbosity = " << logging::GetVlogVerbosity(); | 116 << ", default verbosity = " << logging::GetVlogVerbosity(); |
| 74 | 117 |
| 75 if (!base::android::RegisterJni(env)) | 118 if (!EnsureJniRegistered(env)) |
| 76 return RESULT_CODE_FAILED_TO_REGISTER_JNI; | |
| 77 | |
| 78 if (!gfx::android::RegisterJni(env)) | |
| 79 return RESULT_CODE_FAILED_TO_REGISTER_JNI; | |
| 80 | |
| 81 if (!net::android::RegisterJni(env)) | |
| 82 return RESULT_CODE_FAILED_TO_REGISTER_JNI; | |
| 83 | |
| 84 if (!ui::android::RegisterJni(env)) | |
| 85 return RESULT_CODE_FAILED_TO_REGISTER_JNI; | |
| 86 | |
| 87 if (!ui::gl::android::RegisterJni(env)) | |
| 88 return RESULT_CODE_FAILED_TO_REGISTER_JNI; | |
| 89 | |
| 90 if (!ui::shell_dialogs::RegisterJni(env)) | |
| 91 return RESULT_CODE_FAILED_TO_REGISTER_JNI; | |
| 92 | |
| 93 if (!content::android::RegisterChildJni(env)) | |
| 94 return RESULT_CODE_FAILED_TO_REGISTER_JNI; | |
| 95 | |
| 96 if (!content::android::RegisterCommonJni(env)) | |
| 97 return RESULT_CODE_FAILED_TO_REGISTER_JNI; | |
| 98 | |
| 99 if (!content::android::RegisterBrowserJni(env)) | |
| 100 return RESULT_CODE_FAILED_TO_REGISTER_JNI; | |
| 101 | |
| 102 if (!content::android::RegisterAppJni(env)) | |
| 103 return RESULT_CODE_FAILED_TO_REGISTER_JNI; | |
| 104 | |
| 105 if (!media::RegisterJni(env)) | |
| 106 return RESULT_CODE_FAILED_TO_REGISTER_JNI; | 119 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
| 107 | 120 |
| 108 return 0; | 121 return 0; |
| 109 } | 122 } |
| 110 | 123 |
| 111 static void RecordContentAndroidLinkerHistogram( | 124 static void RecordContentAndroidLinkerHistogram( |
| 112 JNIEnv* env, | 125 JNIEnv* env, |
| 113 jclass clazz, | 126 jclass clazz, |
| 114 jboolean loaded_at_fixed_address_failed, | 127 jboolean loaded_at_fixed_address_failed, |
| 115 jboolean is_low_memory_device) { | 128 jboolean is_low_memory_device) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 127 } | 140 } |
| 128 | 141 |
| 129 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { | 142 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { |
| 130 // We need the AtExitManager to be created at the very beginning. | 143 // We need the AtExitManager to be created at the very beginning. |
| 131 g_at_exit_manager = new base::AtExitManager(); | 144 g_at_exit_manager = new base::AtExitManager(); |
| 132 | 145 |
| 133 return RegisterNativesImpl(env); | 146 return RegisterNativesImpl(env); |
| 134 } | 147 } |
| 135 | 148 |
| 136 } // namespace content | 149 } // namespace content |
| OLD | NEW |