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

Unified Diff: base/trace_event/trace_options.cc

Issue 1154133003: [Startup Tracing] Separate TraceOptions and CategoryFilter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add gn build support Created 5 years, 7 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 | « base/trace_event/trace_options.h ('k') | base/trace_event/trace_options_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/trace_options.cc
diff --git a/base/trace_event/trace_options.cc b/base/trace_event/trace_options.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7cab61dbbd0726f8a4fb85f69c60917fe8e7a88d
--- /dev/null
+++ b/base/trace_event/trace_options.cc
@@ -0,0 +1,84 @@
+// Copyright (c) 2015 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 "base/trace_event/trace_options.h"
+
+#include "base/logging.h"
+#include "base/strings/string_split.h"
+
+namespace base {
+namespace trace_event {
+
+namespace {
+
+// String options that can be used to initialize TraceOptions.
+const char kRecordUntilFull[] = "record-until-full";
+const char kRecordContinuously[] = "record-continuously";
+const char kRecordAsMuchAsPossible[] = "record-as-much-as-possible";
+const char kTraceToConsole[] = "trace-to-console";
+const char kEnableSampling[] = "enable-sampling";
+const char kEnableSystrace[] = "enable-systrace";
+const char kEnableArgumentFilter[] = "enable-argument-filter";
+
+} // namespace
+
+bool TraceOptions::SetFromString(const std::string& options_string) {
+ record_mode = RECORD_UNTIL_FULL;
+ enable_sampling = false;
+ enable_systrace = false;
+
+ std::vector<std::string> split;
+ std::vector<std::string>::iterator iter;
+ base::SplitString(options_string, ',', &split);
+ for (iter = split.begin(); iter != split.end(); ++iter) {
+ if (*iter == kRecordUntilFull) {
+ record_mode = RECORD_UNTIL_FULL;
+ } else if (*iter == kRecordContinuously) {
+ record_mode = RECORD_CONTINUOUSLY;
+ } else if (*iter == kTraceToConsole) {
+ record_mode = ECHO_TO_CONSOLE;
+ } else if (*iter == kRecordAsMuchAsPossible) {
+ record_mode = RECORD_AS_MUCH_AS_POSSIBLE;
+ } else if (*iter == kEnableSampling) {
+ enable_sampling = true;
+ } else if (*iter == kEnableSystrace) {
+ enable_systrace = true;
+ } else if (*iter == kEnableArgumentFilter) {
+ enable_argument_filter = true;
+ } else {
+ return false;
+ }
+ }
+ return true;
+}
+
+std::string TraceOptions::ToString() const {
+ std::string ret;
+ switch (record_mode) {
+ case RECORD_UNTIL_FULL:
+ ret = kRecordUntilFull;
+ break;
+ case RECORD_CONTINUOUSLY:
+ ret = kRecordContinuously;
+ break;
+ case ECHO_TO_CONSOLE:
+ ret = kTraceToConsole;
+ break;
+ case RECORD_AS_MUCH_AS_POSSIBLE:
+ ret = kRecordAsMuchAsPossible;
+ break;
+ default:
+ NOTREACHED();
+ }
+ if (enable_sampling)
+ ret = ret + "," + kEnableSampling;
+ if (enable_systrace)
+ ret = ret + "," + kEnableSystrace;
+ if (enable_argument_filter)
+ ret = ret + "," + kEnableArgumentFilter;
+ return ret;
+}
+
+} // namespace trace_event
+} // namespace base
« no previous file with comments | « base/trace_event/trace_options.h ('k') | base/trace_event/trace_options_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698