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/base_switches.h" | 12 #include "base/base_switches.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/string_tokenizer.h" | 18 #include "base/string_tokenizer.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/tracked_objects.h" | 20 #include "base/tracked_objects.h" |
21 #include "content/app/android/app_jni_registrar.h" | 21 #include "content/app/android/app_jni_registrar.h" |
22 #include "content/browser/android/browser_jni_registrar.h" | 22 #include "content/browser/android/browser_jni_registrar.h" |
23 #include "content/common/android/common_jni_registrar.h" | 23 #include "content/common/android/common_jni_registrar.h" |
24 #include "content/common/android/command_line.h" | 24 #include "content/common/android/command_line.h" |
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 "media/base/android/media_jni_registrar.h" | 27 #include "media/base/android/media_jni_registrar.h" |
27 #include "net/android/net_jni_registrar.h" | 28 #include "net/android/net_jni_registrar.h" |
28 #include "ui/android/ui_jni_registrar.h" | 29 #include "ui/android/ui_jni_registrar.h" |
29 #include "jni/LibraryLoader_jni.h" | 30 #include "jni/LibraryLoader_jni.h" |
30 #include "ui/gfx/android/gfx_jni_registrar.h" | 31 #include "ui/gfx/android/gfx_jni_registrar.h" |
31 | 32 |
32 namespace { | 33 namespace { |
33 base::AtExitManager* g_at_exit_manager = NULL; | 34 base::AtExitManager* g_at_exit_manager = NULL; |
34 } | 35 } |
35 | 36 |
36 namespace content { | 37 namespace content { |
37 | 38 |
38 static jboolean LibraryLoadedOnMainThread(JNIEnv* env, jclass clazz, | 39 static jint LibraryLoadedOnMainThread(JNIEnv* env, jclass clazz, |
39 jobjectArray init_command_line) { | 40 jobjectArray init_command_line) { |
40 InitNativeCommandLineFromJavaArray(env, init_command_line); | 41 InitNativeCommandLineFromJavaArray(env, init_command_line); |
41 | 42 |
42 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 43 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
43 | 44 |
44 if (command_line->HasSwitch(switches::kTraceStartup)) { | 45 if (command_line->HasSwitch(switches::kTraceStartup)) { |
45 base::debug::TraceLog::GetInstance()->SetEnabled( | 46 base::debug::TraceLog::GetInstance()->SetEnabled( |
46 command_line->GetSwitchValueASCII(switches::kTraceStartup)); | 47 command_line->GetSwitchValueASCII(switches::kTraceStartup)); |
47 } | 48 } |
48 | 49 |
(...skipping 14 matching lines...) Expand all Loading... |
63 dcheck_state); | 64 dcheck_state); |
64 // To view log output with IDs and timestamps use "adb logcat -v threadtime". | 65 // To view log output with IDs and timestamps use "adb logcat -v threadtime". |
65 logging::SetLogItems(false, // Process ID | 66 logging::SetLogItems(false, // Process ID |
66 false, // Thread ID | 67 false, // Thread ID |
67 false, // Timestamp | 68 false, // Timestamp |
68 false); // Tick count | 69 false); // Tick count |
69 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() | 70 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() |
70 << ", default verbosity = " << logging::GetVlogVerbosity(); | 71 << ", default verbosity = " << logging::GetVlogVerbosity(); |
71 | 72 |
72 if (!base::android::RegisterJni(env)) | 73 if (!base::android::RegisterJni(env)) |
73 return JNI_FALSE; | 74 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
74 | 75 |
75 if (!net::android::RegisterJni(env)) | 76 if (!net::android::RegisterJni(env)) |
76 return JNI_FALSE; | 77 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
77 | 78 |
78 if (!ui::RegisterJni(env)) | 79 if (!ui::RegisterJni(env)) |
79 return JNI_FALSE; | 80 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
80 | 81 |
81 if (!content::android::RegisterCommonJni(env)) | 82 if (!content::android::RegisterCommonJni(env)) |
82 return JNI_FALSE; | 83 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
83 | 84 |
84 if (!content::android::RegisterBrowserJni(env)) | 85 if (!content::android::RegisterBrowserJni(env)) |
85 return JNI_FALSE; | 86 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
86 | 87 |
87 if (!content::android::RegisterAppJni(env)) | 88 if (!content::android::RegisterAppJni(env)) |
88 return JNI_FALSE; | 89 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
89 | 90 |
90 if (!media::RegisterJni(env)) | 91 if (!media::RegisterJni(env)) |
91 return JNI_FALSE; | 92 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
92 | 93 |
93 if (!gfx::RegisterJni(env)) | 94 if (!gfx::RegisterJni(env)) |
94 return JNI_FALSE; | 95 return RESULT_CODE_FAILED_TO_REGISTER_JNI; |
95 | 96 |
96 return JNI_TRUE; | 97 return 0; |
97 } | 98 } |
98 | 99 |
99 void LibraryLoaderExitHook() { | 100 void LibraryLoaderExitHook() { |
100 if (g_at_exit_manager) { | 101 if (g_at_exit_manager) { |
101 delete g_at_exit_manager; | 102 delete g_at_exit_manager; |
102 g_at_exit_manager = NULL; | 103 g_at_exit_manager = NULL; |
103 } | 104 } |
104 } | 105 } |
105 | 106 |
106 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { | 107 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { |
107 // We need the AtExitManager to be created at the very beginning. | 108 // We need the AtExitManager to be created at the very beginning. |
108 g_at_exit_manager = new base::AtExitManager(); | 109 g_at_exit_manager = new base::AtExitManager(); |
109 | 110 |
110 return RegisterNativesImpl(env); | 111 return RegisterNativesImpl(env); |
111 } | 112 } |
112 | 113 |
113 } // namespace content | 114 } // namespace content |
OLD | NEW |