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

Unified Diff: components/tracing/common/startup_command_parser.cc

Issue 2683913002: Enable startup tracing from command line flags in components/tracing (Closed)
Patch Set: . 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/tracing/common/startup_command_parser.h ('k') | components/tracing/common/trace_config_file.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/tracing/common/startup_command_parser.cc
diff --git a/components/tracing/common/startup_command_parser.cc b/components/tracing/common/startup_command_parser.cc
new file mode 100644
index 0000000000000000000000000000000000000000..17c5892586dbc274381ac219782775089c8d2100
--- /dev/null
+++ b/components/tracing/common/startup_command_parser.cc
@@ -0,0 +1,44 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/tracing/common/startup_command_parser.h"
+
+#include "base/logging.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/trace_log.h"
+#include "components/tracing/common/trace_config_file.h"
+#include "components/tracing/common/trace_to_console.h"
+#include "components/tracing/common/tracing_switches.h"
+
+namespace tracing {
+
+void ParseStartupTraceCommands(const base::CommandLine& command_line,
Zhen Wang 2017/02/10 19:56:01 This function name does not capture what it actual
ssid 2017/02/11 01:14:17 Renamed as suggested. I'd be happy to rename the f
+ bool can_access_file_system) {
+ base::trace_event::MemoryDumpManager::GetInstance()
+ ->EnableHeapProfilingIfNeeded();
+
+ if (command_line.HasSwitch(switches::kTraceStartup)) {
+ base::trace_event::TraceConfig trace_config(
+ command_line.GetSwitchValueASCII(switches::kTraceStartup),
+ base::trace_event::RECORD_UNTIL_FULL);
+ base::trace_event::TraceLog::GetInstance()->SetEnabled(
+ trace_config, base::trace_event::TraceLog::RECORDING_MODE);
+ } else if (command_line.HasSwitch(switches::kTraceToConsole)) {
+ base::trace_event::TraceConfig trace_config =
+ tracing::GetConfigForTraceToConsole();
+ LOG(ERROR) << "Start " << switches::kTraceToConsole
+ << " with CategoryFilter '"
+ << trace_config.ToCategoryFilterString() << "'.";
+ base::trace_event::TraceLog::GetInstance()->SetEnabled(
+ trace_config, base::trace_event::TraceLog::RECORDING_MODE);
+ } else if (can_access_file_system &&
+ tracing::TraceConfigFile::GetInstance()->IsEnabled()) {
+ // This checks kTraceConfigFile switch.
+ base::trace_event::TraceLog::GetInstance()->SetEnabled(
+ tracing::TraceConfigFile::GetInstance()->GetTraceConfig(),
+ base::trace_event::TraceLog::RECORDING_MODE);
+ }
+}
+
+} // namespace tracing
« no previous file with comments | « components/tracing/common/startup_command_parser.h ('k') | components/tracing/common/trace_config_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698