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_registrar.h" | 8 #include "base/android/jni_registrar.h" |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/string_tokenizer.h" | 17 #include "base/string_tokenizer.h" |
18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
19 #include "base/tracked_objects.h" | 19 #include "base/tracked_objects.h" |
20 #include "content/app/android/app_jni_registrar.h" | 20 #include "content/app/android/app_jni_registrar.h" |
21 #include "content/browser/android/browser_jni_registrar.h" | 21 #include "content/browser/android/browser_jni_registrar.h" |
22 #include "content/common/android/common_jni_registrar.h" | 22 #include "content/common/android/common_jni_registrar.h" |
23 #include "content/common/android/command_line.h" | 23 #include "content/common/android/command_line.h" |
24 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
25 #include "content/public/common/result_codes.h" | |
25 #include "media/base/android/media_jni_registrar.h" | 26 #include "media/base/android/media_jni_registrar.h" |
26 #include "net/android/net_jni_registrar.h" | 27 #include "net/android/net_jni_registrar.h" |
27 #include "ui/android/ui_jni_registrar.h" | 28 #include "ui/android/ui_jni_registrar.h" |
28 #include "jni/LibraryLoader_jni.h" | 29 #include "jni/LibraryLoader_jni.h" |
29 #include "ui/gfx/android/gfx_jni_registrar.h" | 30 #include "ui/gfx/android/gfx_jni_registrar.h" |
30 | 31 |
31 namespace { | 32 namespace { |
32 base::AtExitManager* g_at_exit_manager = NULL; | 33 base::AtExitManager* g_at_exit_manager = NULL; |
33 } | 34 } |
34 | 35 |
35 namespace content { | 36 namespace content { |
36 | 37 |
37 static jboolean LibraryLoadedOnMainThread(JNIEnv* env, jclass clazz, | 38 static jint LibraryLoadedOnMainThread(JNIEnv* env, jclass clazz, |
38 jobjectArray init_command_line) { | 39 jobjectArray init_command_line) { |
joth
2013/01/08 21:20:45
indent wrong.
| |
39 InitNativeCommandLineFromJavaArray(env, init_command_line); | 40 InitNativeCommandLineFromJavaArray(env, init_command_line); |
40 | 41 |
41 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 42 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
42 | 43 |
43 if (command_line->HasSwitch(switches::kTraceStartup)) { | 44 if (command_line->HasSwitch(switches::kTraceStartup)) { |
44 base::debug::TraceLog::GetInstance()->SetEnabled( | 45 base::debug::TraceLog::GetInstance()->SetEnabled( |
45 command_line->GetSwitchValueASCII(switches::kTraceStartup)); | 46 command_line->GetSwitchValueASCII(switches::kTraceStartup)); |
46 } | 47 } |
47 | 48 |
48 // Can only use event tracing after setting up the command line. | 49 // Can only use event tracing after setting up the command line. |
49 TRACE_EVENT0("jni", "JNI_OnLoad continuation"); | 50 TRACE_EVENT0("jni", "JNI_OnLoad continuation"); |
50 | 51 |
51 logging::InitLogging(NULL, | 52 logging::InitLogging(NULL, |
52 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, | 53 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, |
53 logging::DONT_LOCK_LOG_FILE, | 54 logging::DONT_LOCK_LOG_FILE, |
54 logging::DELETE_OLD_LOG_FILE, | 55 logging::DELETE_OLD_LOG_FILE, |
55 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); | 56 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); |
56 // To view log output with IDs and timestamps use "adb logcat -v threadtime". | 57 // To view log output with IDs and timestamps use "adb logcat -v threadtime". |
57 logging::SetLogItems(false, // Process ID | 58 logging::SetLogItems(false, // Process ID |
58 false, // Thread ID | 59 false, // Thread ID |
59 false, // Timestamp | 60 false, // Timestamp |
60 false); // Tick count | 61 false); // Tick count |
61 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() | 62 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() |
62 << ", default verbosity = " << logging::GetVlogVerbosity(); | 63 << ", default verbosity = " << logging::GetVlogVerbosity(); |
63 | 64 |
64 if (!base::android::RegisterJni(env)) | 65 if (!base::android::RegisterJni(env)) |
65 return JNI_FALSE; | 66 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
66 | 67 |
67 if (!net::android::RegisterJni(env)) | 68 if (!net::android::RegisterJni(env)) |
68 return JNI_FALSE; | 69 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
69 | 70 |
70 if (!ui::RegisterJni(env)) | 71 if (!ui::RegisterJni(env)) |
71 return JNI_FALSE; | 72 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
72 | 73 |
73 if (!content::android::RegisterCommonJni(env)) | 74 if (!content::android::RegisterCommonJni(env)) |
74 return JNI_FALSE; | 75 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
75 | 76 |
76 if (!content::android::RegisterBrowserJni(env)) | 77 if (!content::android::RegisterBrowserJni(env)) |
77 return JNI_FALSE; | 78 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
78 | 79 |
79 if (!content::android::RegisterAppJni(env)) | 80 if (!content::android::RegisterAppJni(env)) |
80 return JNI_FALSE; | 81 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
81 | 82 |
82 if (!media::RegisterJni(env)) | 83 if (!media::RegisterJni(env)) |
83 return JNI_FALSE; | 84 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
84 | 85 |
85 if (!gfx::RegisterJni(env)) | 86 if (!gfx::RegisterJni(env)) |
86 return JNI_FALSE; | 87 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
joth
2013/01/08 21:20:45
I don't think it's adding much to reuse result_cod
michaelbai
2013/01/09 00:14:00
I think it is better for user to find the error in
| |
87 | 88 |
88 return JNI_TRUE; | 89 return 0; |
89 } | 90 } |
90 | 91 |
91 void LibraryLoaderExitHook() { | 92 void LibraryLoaderExitHook() { |
92 if (g_at_exit_manager) { | 93 if (g_at_exit_manager) { |
93 delete g_at_exit_manager; | 94 delete g_at_exit_manager; |
94 g_at_exit_manager = NULL; | 95 g_at_exit_manager = NULL; |
95 } | 96 } |
96 } | 97 } |
97 | 98 |
98 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { | 99 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { |
99 // We need the AtExitManager to be created at the very beginning. | 100 // We need the AtExitManager to be created at the very beginning. |
100 g_at_exit_manager = new base::AtExitManager(); | 101 g_at_exit_manager = new base::AtExitManager(); |
101 | 102 |
102 return RegisterNativesImpl(env); | 103 return RegisterNativesImpl(env); |
103 } | 104 } |
104 | 105 |
105 } // namespace content | 106 } // namespace content |
OLD | NEW |