zhenw | c5db2a0 | 2015-12-11 23:31:43 | [diff] [blame] | 1 | // Copyright (c) 2015 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/trace_to_console.h" |
| 6 | |
| 7 | #include <string> |
| 8 | |
| 9 | #include "base/command_line.h" |
| 10 | #include "components/tracing/tracing_switches.h" |
| 11 | |
| 12 | namespace tracing { |
| 13 | |
| 14 | namespace { |
| 15 | // These categories will cause deadlock when ECHO_TO_CONSOLE. crbug.com/325575. |
wangxianzhu | f4fb3804 | 2015-12-21 16:08:12 | [diff] [blame] | 16 | const char kEchoToConsoleCategoryFilter[] = "-ipc,-toplevel"; |
zhenw | c5db2a0 | 2015-12-11 23:31:43 | [diff] [blame] | 17 | } // namespace |
| 18 | |
| 19 | base::trace_event::TraceConfig GetConfigForTraceToConsole() { |
| 20 | const base::CommandLine& command_line = |
| 21 | *base::CommandLine::ForCurrentProcess(); |
| 22 | DCHECK(command_line.HasSwitch(switches::kTraceToConsole)); |
| 23 | std::string filter = command_line.GetSwitchValueASCII( |
| 24 | switches::kTraceToConsole); |
| 25 | if (filter.empty()) { |
| 26 | filter = kEchoToConsoleCategoryFilter; |
| 27 | } else { |
| 28 | filter.append(","); |
| 29 | filter.append(kEchoToConsoleCategoryFilter); |
| 30 | } |
| 31 | return base::trace_event::TraceConfig( |
| 32 | filter, base::trace_event::ECHO_TO_CONSOLE); |
| 33 | } |
| 34 | |
| 35 | } // namespace tracing |