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

Unified Diff: tools/telemetry/telemetry/core/platform/tracing_category_filter.py

Issue 414253004: Introduce TracingController and TracingControllerBackend skeleton (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
Index: tools/telemetry/telemetry/core/platform/tracing_category_filter.py
diff --git a/tools/telemetry/telemetry/core/platform/tracing_category_filter.py b/tools/telemetry/telemetry/core/platform/tracing_category_filter.py
new file mode 100644
index 0000000000000000000000000000000000000000..da83643aab52cba1dbcc55f83a0509719fbfa3ec
--- /dev/null
+++ b/tools/telemetry/telemetry/core/platform/tracing_category_filter.py
@@ -0,0 +1,75 @@
+# Copyright 2014 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.
+
+class TracingCategoryFilter(object):
+ """A set of included and excluded categories that should be traced.
+
+ The TraceCategoryFilter allows fine tuning of what data is traced. Basic
+ choice of which tracers to use is done by TracingOptions.
+ """
+ def __init__(self, filter_string=None):
+ self._included_categories = []
+ self._excluded_categories = []
+ self._disabled_by_default_categories = []
+ self._delays = []
+
+ if filter_string == None:
+ return
+
+ for category in filter_string.split(','):
+ if category == '':
+ continue
+
+ if category.startswith('DELAY('):
+ self._delays.append(category)
+ continue
+
+ if category[0] == '-':
+ self._excluded_categories.append(category[1:])
+ continue
+
+ if category.startswith('disabled-by-default-'):
+ self._disabled_by_default_categories.append(category)
+ continue
+
+ self.included_categories.append(category)
+
+ @property
+ def included_categories(self):
+ return self._included_categories
+
+ @property
+ def excluded_categories(self):
+ return self._excluded_categories
+
+ @property
+ def disabled_by_default_categories(self):
+ return self._disabled_by_default_categories
+
+ @property
+ def delays(self):
+ return self._delays
+
+ @property
+ def filter_string(self):
+ # Note: This outputs fields in an order that intentionally matches
+ # trace_event_impl's CategoryFilter string order.
+ categories = []
+ categories += self._included_categories
+ categories += self._disabled_by_default_categories
+ categories += ['-%s' % x for x in self._excluded_categories]
+ categories += self._delays
+ return ','.join(categories)
+
+ def AddIncludedCategory(self, category_glob):
+ """Explicitly enables anything matching category_glob."""
+ assert not category_glob.startswith('disabled-by-default-')
+ if category_glob not in self._included_categories:
+ self._included_categories.append(category_glob)
+
+ def AddExcludedCategory(self, category_glob):
+ """Explicitly disables anything matching category_glob."""
+ assert not category_glob.startswith('disabled-by-default-')
+ if category_glob not in self._excluded_categories:
+ self._excluded_categories.append(category_glob)

Powered by Google App Engine
This is Rietveld 408576698