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

Side by Side Diff: components/tracing/common/trace_startup.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.h ('k') | content/app/android/library_loader_hooks.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/tracing/common/trace_startup.h"
6
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/trace_event/memory_dump_manager.h"
10 #include "base/trace_event/trace_log.h"
11 #include "components/tracing/common/trace_config_file.h"
12 #include "components/tracing/common/trace_to_console.h"
13 #include "components/tracing/common/tracing_switches.h"
14
15 namespace tracing {
16
17 void EnableStartupTracingIfNeeded(bool can_access_file_system) {
18 const base::CommandLine& command_line =
19 *base::CommandLine::ForCurrentProcess();
20
21 // Enables heap profiling if "--enable-heap-profiling" flag is passed.
22 base::trace_event::MemoryDumpManager::GetInstance()
23 ->EnableHeapProfilingIfNeeded();
24
25 if (command_line.HasSwitch(switches::kTraceStartup)) {
26 base::trace_event::TraceConfig trace_config(
27 command_line.GetSwitchValueASCII(switches::kTraceStartup),
28 base::trace_event::RECORD_UNTIL_FULL);
29 base::trace_event::TraceLog::GetInstance()->SetEnabled(
30 trace_config, base::trace_event::TraceLog::RECORDING_MODE);
31 } else if (command_line.HasSwitch(switches::kTraceToConsole)) {
32 base::trace_event::TraceConfig trace_config =
33 tracing::GetConfigForTraceToConsole();
34 LOG(ERROR) << "Start " << switches::kTraceToConsole
35 << " with CategoryFilter '"
36 << trace_config.ToCategoryFilterString() << "'.";
37 base::trace_event::TraceLog::GetInstance()->SetEnabled(
38 trace_config, base::trace_event::TraceLog::RECORDING_MODE);
39 } else if (can_access_file_system &&
40 tracing::TraceConfigFile::GetInstance()->IsEnabled()) {
41 // This checks kTraceConfigFile switch.
42 base::trace_event::TraceLog::GetInstance()->SetEnabled(
43 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(),
44 base::trace_event::TraceLog::RECORDING_MODE);
45 }
46 }
47
48 } // namespace tracing
OLDNEW
« no previous file with comments | « components/tracing/common/trace_startup.h ('k') | content/app/android/library_loader_hooks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698