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/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 |
OLD | NEW |