Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Side by Side Diff: content/app/android/library_loader_hooks.cc

Issue 2683913002: Enable startup tracing from command line flags in components/tracing (Closed)
Patch Set: Rebase. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/tracing/common/trace_startup.cc ('k') | content/app/content_main_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (!ui::RegisterUIAndroidJni(env)) 110 if (!ui::RegisterUIAndroidJni(env))
113 return false; 111 return false;
114 112
115 g_jni_init_done = true; 113 g_jni_init_done = true;
116 } 114 }
117 115
118 return true; 116 return true;
119 } 117 }
120 118
121 bool LibraryLoaded(JNIEnv* env, jclass clazz) { 119 bool LibraryLoaded(JNIEnv* env, jclass clazz) {
122 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
123
124 // Enable startup tracing asap to avoid early TRACE_EVENT calls being ignored. 120 // Enable startup tracing asap to avoid early TRACE_EVENT calls being ignored.
125 if (command_line->HasSwitch(switches::kTraceStartup)) { 121 tracing::EnableStartupTracingIfNeeded(true /* can_access_file_system */);
126 base::trace_event::TraceConfig trace_config(
127 command_line->GetSwitchValueASCII(switches::kTraceStartup), "");
128 base::trace_event::TraceLog::GetInstance()->SetEnabled(
129 trace_config, base::trace_event::TraceLog::RECORDING_MODE);
130 } else if (command_line->HasSwitch(switches::kTraceToConsole)) {
131 base::trace_event::TraceConfig trace_config =
132 tracing::GetConfigForTraceToConsole();
133 LOG(ERROR) << "Start " << switches::kTraceToConsole
134 << " with CategoryFilter '"
135 << trace_config.ToCategoryFilterString() << "'.";
136 base::trace_event::TraceLog::GetInstance()->SetEnabled(
137 trace_config,
138 base::trace_event::TraceLog::RECORDING_MODE);
139 } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) {
140 // This checks kTraceConfigFile switch.
141 base::trace_event::TraceLog::GetInstance()->SetEnabled(
142 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(),
143 base::trace_event::TraceLog::RECORDING_MODE);
144 }
145 122
146 // Android's main browser loop is custom so we set the browser 123 // Android's main browser loop is custom so we set the browser
147 // name here as early as possible. 124 // name here as early as possible.
148 base::trace_event::TraceLog::GetInstance()->SetProcessName("Browser"); 125 base::trace_event::TraceLog::GetInstance()->SetProcessName("Browser");
149 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( 126 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
150 kTraceEventBrowserProcessSortIndex); 127 kTraceEventBrowserProcessSortIndex);
151 128
152 // Can only use event tracing after setting up the command line. 129 // Can only use event tracing after setting up the command line.
153 TRACE_EVENT0("jni", "JNI_OnLoad continuation"); 130 TRACE_EVENT0("jni", "JNI_OnLoad continuation");
154 131
155 logging::LoggingSettings settings; 132 logging::LoggingSettings settings;
156 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 133 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
157 logging::InitLogging(settings); 134 logging::InitLogging(settings);
158 // To view log output with IDs and timestamps use "adb logcat -v threadtime". 135 // To view log output with IDs and timestamps use "adb logcat -v threadtime".
159 logging::SetLogItems(false, // Process ID 136 logging::SetLogItems(false, // Process ID
160 false, // Thread ID 137 false, // Thread ID
161 false, // Timestamp 138 false, // Timestamp
162 false); // Tick count 139 false); // Tick count
163 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() 140 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel()
164 << ", default verbosity = " << logging::GetVlogVerbosity(); 141 << ", default verbosity = " << logging::GetVlogVerbosity();
165 142
166 return true; 143 return true;
167 } 144 }
168 145
169 } // namespace content 146 } // namespace content
OLDNEW
« no previous file with comments | « components/tracing/common/trace_startup.cc ('k') | content/app/content_main_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698