OLD | NEW |
(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/logging.h" |
| 8 #include "base/trace_event/memory_dump_manager.h" |
| 9 #include "base/trace_event/trace_log.h" |
| 10 #include "components/tracing/common/trace_config_file.h" |
| 11 #include "components/tracing/common/trace_to_console.h" |
| 12 #include "components/tracing/common/tracing_switches.h" |
| 13 |
| 14 namespace tracing { |
| 15 |
| 16 void EnableStartupTracingIfNeeded(const base::CommandLine& command_line, |
| 17 bool can_access_file_system) { |
| 18 // Enables heap profiling if "--enable-heap-profiling" flag is passed. |
| 19 base::trace_event::MemoryDumpManager::GetInstance() |
| 20 ->EnableHeapProfilingIfNeeded(); |
| 21 |
| 22 if (command_line.HasSwitch(switches::kTraceStartup)) { |
| 23 base::trace_event::TraceConfig trace_config( |
| 24 command_line.GetSwitchValueASCII(switches::kTraceStartup), |
| 25 base::trace_event::RECORD_UNTIL_FULL); |
| 26 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 27 trace_config, base::trace_event::TraceLog::RECORDING_MODE); |
| 28 } else if (command_line.HasSwitch(switches::kTraceToConsole)) { |
| 29 base::trace_event::TraceConfig trace_config = |
| 30 tracing::GetConfigForTraceToConsole(); |
| 31 LOG(ERROR) << "Start " << switches::kTraceToConsole |
| 32 << " with CategoryFilter '" |
| 33 << trace_config.ToCategoryFilterString() << "'."; |
| 34 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 35 trace_config, base::trace_event::TraceLog::RECORDING_MODE); |
| 36 } else if (can_access_file_system && |
| 37 tracing::TraceConfigFile::GetInstance()->IsEnabled()) { |
| 38 // This checks kTraceConfigFile switch. |
| 39 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 40 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), |
| 41 base::trace_event::TraceLog::RECORDING_MODE); |
| 42 } |
| 43 } |
| 44 |
| 45 } // namespace tracing |
OLD | NEW |