| 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/startup_command_parser.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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(); | 124 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 127 | 125 |
| 128 // Enable startup tracing asap to avoid early TRACE_EVENT calls being ignored. | 126 // Enable startup tracing asap to avoid early TRACE_EVENT calls being ignored. |
| 129 if (command_line->HasSwitch(switches::kTraceStartup)) { | 127 tracing::ParseStartupTraceCommands(*command_line, |
| 130 base::trace_event::TraceConfig trace_config( | 128 true /* can_access_file_system */); |
| 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 | 129 |
| 150 // Android's main browser loop is custom so we set the browser | 130 // Android's main browser loop is custom so we set the browser |
| 151 // name here as early as possible. | 131 // name here as early as possible. |
| 152 base::trace_event::TraceLog::GetInstance()->SetProcessName("Browser"); | 132 base::trace_event::TraceLog::GetInstance()->SetProcessName("Browser"); |
| 153 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( | 133 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( |
| 154 kTraceEventBrowserProcessSortIndex); | 134 kTraceEventBrowserProcessSortIndex); |
| 155 | 135 |
| 156 // Can only use event tracing after setting up the command line. | 136 // Can only use event tracing after setting up the command line. |
| 157 TRACE_EVENT0("jni", "JNI_OnLoad continuation"); | 137 TRACE_EVENT0("jni", "JNI_OnLoad continuation"); |
| 158 | 138 |
| 159 logging::LoggingSettings settings; | 139 logging::LoggingSettings settings; |
| 160 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 140 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 161 logging::InitLogging(settings); | 141 logging::InitLogging(settings); |
| 162 // To view log output with IDs and timestamps use "adb logcat -v threadtime". | 142 // To view log output with IDs and timestamps use "adb logcat -v threadtime". |
| 163 logging::SetLogItems(false, // Process ID | 143 logging::SetLogItems(false, // Process ID |
| 164 false, // Thread ID | 144 false, // Thread ID |
| 165 false, // Timestamp | 145 false, // Timestamp |
| 166 false); // Tick count | 146 false); // Tick count |
| 167 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() | 147 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() |
| 168 << ", default verbosity = " << logging::GetVlogVerbosity(); | 148 << ", default verbosity = " << logging::GetVlogVerbosity(); |
| 169 | 149 |
| 170 return true; | 150 return true; |
| 171 } | 151 } |
| 172 | 152 |
| 173 } // namespace content | 153 } // namespace content |
| OLD | NEW |