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/app/android/library_loader_hooks.h" | 5 #include "content/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/command_line_android.h" | 8 #include "base/android/command_line_android.h" |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_registrar.h" | 10 #include "base/android/jni_registrar.h" |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/android/library_loader/library_loader_hooks.h" | 12 #include "base/android/library_loader/library_loader_hooks.h" |
13 #include "base/base_switches.h" | 13 #include "base/base_switches.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
19 #include "base/tracked_objects.h" | 19 #include "base/tracked_objects.h" |
20 #include "components/tracing/browser/trace_config_file.h" | 20 #include "components/tracing/common/trace_startup.h" |
21 #include "components/tracing/common/trace_to_console.h" | |
22 #include "components/tracing/common/tracing_switches.h" | |
23 #include "content/app/android/app_jni_registrar.h" | 21 #include "content/app/android/app_jni_registrar.h" |
24 #include "content/browser/android/browser_jni_registrar.h" | 22 #include "content/browser/android/browser_jni_registrar.h" |
25 #include "content/common/android/common_jni_registrar.h" | 23 #include "content/common/android/common_jni_registrar.h" |
26 #include "content/common/content_constants_internal.h" | 24 #include "content/common/content_constants_internal.h" |
27 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
28 #include "content/public/common/result_codes.h" | 26 #include "content/public/common/result_codes.h" |
29 #include "device/bluetooth/android/bluetooth_jni_registrar.h" | 27 #include "device/bluetooth/android/bluetooth_jni_registrar.h" |
30 #include "device/gamepad/android/gamepad_jni_registrar.h" | 28 #include "device/gamepad/android/gamepad_jni_registrar.h" |
31 #include "device/generic_sensor/android/sensors_jni_registrar.h" | 29 #include "device/generic_sensor/android/sensors_jni_registrar.h" |
32 #include "device/geolocation/android/geolocation_jni_registrar.h" | 30 #include "device/geolocation/android/geolocation_jni_registrar.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 if (!ui::RegisterUIAndroidJni(env)) | 114 if (!ui::RegisterUIAndroidJni(env)) |
117 return false; | 115 return false; |
118 | 116 |
119 g_jni_init_done = true; | 117 g_jni_init_done = true; |
120 } | 118 } |
121 | 119 |
122 return true; | 120 return true; |
123 } | 121 } |
124 | 122 |
125 bool LibraryLoaded(JNIEnv* env, jclass clazz) { | 123 bool LibraryLoaded(JNIEnv* env, jclass clazz) { |
126 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
127 | |
128 // Enable startup tracing asap to avoid early TRACE_EVENT calls being ignored. | 124 // Enable startup tracing asap to avoid early TRACE_EVENT calls being ignored. |
129 if (command_line->HasSwitch(switches::kTraceStartup)) { | 125 tracing::EnableStartupTracingIfNeeded(true /* can_access_file_system */); |
130 base::trace_event::TraceConfig trace_config( | |
131 command_line->GetSwitchValueASCII(switches::kTraceStartup), ""); | |
132 base::trace_event::TraceLog::GetInstance()->SetEnabled( | |
133 trace_config, base::trace_event::TraceLog::RECORDING_MODE); | |
134 } else if (command_line->HasSwitch(switches::kTraceToConsole)) { | |
135 base::trace_event::TraceConfig trace_config = | |
136 tracing::GetConfigForTraceToConsole(); | |
137 LOG(ERROR) << "Start " << switches::kTraceToConsole | |
138 << " with CategoryFilter '" | |
139 << trace_config.ToCategoryFilterString() << "'."; | |
140 base::trace_event::TraceLog::GetInstance()->SetEnabled( | |
141 trace_config, | |
142 base::trace_event::TraceLog::RECORDING_MODE); | |
143 } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) { | |
144 // This checks kTraceConfigFile switch. | |
145 base::trace_event::TraceLog::GetInstance()->SetEnabled( | |
146 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), | |
147 base::trace_event::TraceLog::RECORDING_MODE); | |
148 } | |
149 | 126 |
150 // Android's main browser loop is custom so we set the browser | 127 // Android's main browser loop is custom so we set the browser |
151 // name here as early as possible. | 128 // name here as early as possible. |
152 base::trace_event::TraceLog::GetInstance()->SetProcessName("Browser"); | 129 base::trace_event::TraceLog::GetInstance()->SetProcessName("Browser"); |
153 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( | 130 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( |
154 kTraceEventBrowserProcessSortIndex); | 131 kTraceEventBrowserProcessSortIndex); |
155 | 132 |
156 // Can only use event tracing after setting up the command line. | 133 // Can only use event tracing after setting up the command line. |
157 TRACE_EVENT0("jni", "JNI_OnLoad continuation"); | 134 TRACE_EVENT0("jni", "JNI_OnLoad continuation"); |
158 | 135 |
159 logging::LoggingSettings settings; | 136 logging::LoggingSettings settings; |
160 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 137 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
161 logging::InitLogging(settings); | 138 logging::InitLogging(settings); |
162 // To view log output with IDs and timestamps use "adb logcat -v threadtime". | 139 // To view log output with IDs and timestamps use "adb logcat -v threadtime". |
163 logging::SetLogItems(false, // Process ID | 140 logging::SetLogItems(false, // Process ID |
164 false, // Thread ID | 141 false, // Thread ID |
165 false, // Timestamp | 142 false, // Timestamp |
166 false); // Tick count | 143 false); // Tick count |
167 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() | 144 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() |
168 << ", default verbosity = " << logging::GetVlogVerbosity(); | 145 << ", default verbosity = " << logging::GetVlogVerbosity(); |
169 | 146 |
170 return true; | 147 return true; |
171 } | 148 } |
172 | 149 |
173 } // namespace content | 150 } // namespace content |
OLD | NEW |