| Index: base/trace_event/trace_config.cc
|
| diff --git a/base/trace_event/trace_config.cc b/base/trace_event/trace_config.cc
|
| index e9e5a099893377e844be716845b0bbcfe90a2639..a8ba8496ce666765b5965c8c8a0c6d2465dc454f 100644
|
| --- a/base/trace_event/trace_config.cc
|
| +++ b/base/trace_event/trace_config.cc
|
| @@ -51,6 +51,11 @@ const char kTriggersParam[] = "triggers";
|
| const char kPeriodicIntervalParam[] = "periodic_interval_ms";
|
| const char kModeParam[] = "mode";
|
|
|
| +// String parameters used to parse category event filters.
|
| +const char kCategoryEventFilterParam[] = "category_event_filters";
|
| +const char kPredicateParam[] = "predicate";
|
| +const char kArgsParam[] = "args";
|
| +
|
| // Default configuration of memory dumps.
|
| const TraceConfig::MemoryDumpTriggerConfig kDefaultHeavyMemoryDumpTrigger = {
|
| 2000, // periodic_interval_ms
|
| @@ -75,6 +80,58 @@ class ConvertableTraceConfigToTraceFormat
|
|
|
| } // namespace
|
|
|
| +TraceConfig::CategoryEventFilterConfig::CategoryEventFilterConfig() {}
|
| +TraceConfig::CategoryEventFilterConfig::~CategoryEventFilterConfig() {}
|
| +
|
| +TraceConfig::CategoryEventFilterConfig::CategoryEventFilterConfig(
|
| + const CategoryEventFilterConfig& tc)
|
| + : predicate_name(tc.predicate_name),
|
| + included_categories(tc.included_categories),
|
| + excluded_categories(tc.excluded_categories) {
|
| + if (tc.args)
|
| + args = tc.args->CreateDeepCopy();
|
| +}
|
| +
|
| +TraceConfig::CategoryEventFilterConfig& TraceConfig::CategoryEventFilterConfig::
|
| +operator=(const TraceConfig::CategoryEventFilterConfig& rhs) {
|
| + if (this == &rhs)
|
| + return *this;
|
| +
|
| + predicate_name = rhs.predicate_name;
|
| + included_categories = rhs.included_categories;
|
| + excluded_categories = rhs.excluded_categories;
|
| + if (rhs.args)
|
| + args = rhs.args->CreateDeepCopy();
|
| +
|
| + return *this;
|
| +}
|
| +
|
| +bool TraceConfig::CategoryEventFilterConfig::IsCategoryGroupEnabled(
|
| + const char* category_group_name) const {
|
| + CStringTokenizer category_group_tokens(
|
| + category_group_name, category_group_name + strlen(category_group_name),
|
| + ",");
|
| + while (category_group_tokens.GetNext()) {
|
| + std::string category_group_token = category_group_tokens.token();
|
| +
|
| + for (const auto& excluded_category : excluded_categories) {
|
| + if (base::MatchPattern(category_group_token.c_str(),
|
| + excluded_category.c_str())) {
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + for (const auto& included_category : included_categories) {
|
| + if (base::MatchPattern(category_group_token.c_str(),
|
| + included_category.c_str())) {
|
| + return true;
|
| + }
|
| + }
|
| + }
|
| +
|
| + return false;
|
| +}
|
| +
|
| TraceConfig::TraceConfig() {
|
| InitializeDefault();
|
| }
|
| @@ -126,7 +183,8 @@ TraceConfig::TraceConfig(const TraceConfig& tc)
|
| included_categories_(tc.included_categories_),
|
| disabled_categories_(tc.disabled_categories_),
|
| excluded_categories_(tc.excluded_categories_),
|
| - synthetic_delays_(tc.synthetic_delays_) {}
|
| + synthetic_delays_(tc.synthetic_delays_),
|
| + category_event_filters_(tc.category_event_filters_) {}
|
|
|
| TraceConfig::~TraceConfig() {
|
| }
|
| @@ -144,6 +202,7 @@ TraceConfig& TraceConfig::operator=(const TraceConfig& rhs) {
|
| disabled_categories_ = rhs.disabled_categories_;
|
| excluded_categories_ = rhs.excluded_categories_;
|
| synthetic_delays_ = rhs.synthetic_delays_;
|
| + category_event_filters_ = rhs.category_event_filters_;
|
| return *this;
|
| }
|
|
|
| @@ -151,6 +210,11 @@ const TraceConfig::StringList& TraceConfig::GetSyntheticDelayValues() const {
|
| return synthetic_delays_;
|
| }
|
|
|
| +const TraceConfig::CategoryEventFilters& TraceConfig::GetCategoryEventFilters()
|
| + const {
|
| + return category_event_filters_;
|
| +}
|
| +
|
| std::string TraceConfig::ToString() const {
|
| base::DictionaryValue dict;
|
| ToDict(dict);
|
| @@ -343,6 +407,10 @@ void TraceConfig::InitializeFromConfigDict(const DictionaryValue& dict) {
|
| else
|
| SetDefaultMemoryDumpConfig();
|
| }
|
| +
|
| + const base::ListValue* category_event_filters = nullptr;
|
| + if (dict.GetList(kCategoryEventFilterParam, &category_event_filters))
|
| + SetCategoryEventFilters(*category_event_filters);
|
| }
|
|
|
| void TraceConfig::InitializeFromConfigString(const std::string& config_string) {
|
| @@ -524,6 +592,51 @@ void TraceConfig::SetDefaultMemoryDumpConfig() {
|
| memory_dump_config_.push_back(kDefaultLightMemoryDumpTrigger);
|
| }
|
|
|
| +void TraceConfig::SetCategoryEventFilters(
|
| + const base::ListValue& category_event_filters) {
|
| + category_event_filters_.clear();
|
| +
|
| + for (size_t i = 0; i < category_event_filters.GetSize(); ++i) {
|
| + const base::DictionaryValue* event_filter = nullptr;
|
| + if (!category_event_filters.GetDictionary(i, &event_filter))
|
| + continue;
|
| +
|
| + CategoryEventFilterConfig new_config;
|
| + if (!event_filter->GetString(kPredicateParam, &new_config.predicate_name)) {
|
| + LOG(ERROR) << "Invalid predicate name in category event filter.";
|
| + continue;
|
| + }
|
| +
|
| + const base::ListValue* included_list = nullptr;
|
| + if (!event_filter->GetList(kIncludedCategoriesParam, &included_list)) {
|
| + LOG(ERROR) << "Missing included_categories in category event filter.";
|
| + continue;
|
| + }
|
| +
|
| + for (size_t i = 0; i < included_list->GetSize(); ++i) {
|
| + std::string category;
|
| + if (included_list->GetString(i, &category))
|
| + new_config.included_categories.push_back(category);
|
| + }
|
| +
|
| + const base::ListValue* excluded_list = nullptr;
|
| + if (event_filter->GetList(kExcludedCategoriesParam, &excluded_list)) {
|
| + for (size_t i = 0; i < excluded_list->GetSize(); ++i) {
|
| + std::string category;
|
| + if (excluded_list->GetString(i, &category))
|
| + new_config.excluded_categories.push_back(category);
|
| + }
|
| + }
|
| +
|
| + const base::DictionaryValue* args_dict = nullptr;
|
| + if (event_filter->GetDictionary(kArgsParam, &args_dict)) {
|
| + new_config.args = args_dict->CreateDeepCopy();
|
| + }
|
| +
|
| + category_event_filters_.push_back(new_config);
|
| + }
|
| +}
|
| +
|
| void TraceConfig::ToDict(base::DictionaryValue& dict) const {
|
| switch (record_mode_) {
|
| case RECORD_UNTIL_FULL:
|
|
|