[Tracing] Support multi-categories group list.

jasongin@ created this patch.
dcc50445a3
This patch adds the support to emit a trace event by using a comma-separated
list of categories, so that the trace event will be emitted if there is at least
one category is enabled in the categories list.

TBR=jochen@chromium.org

Review-Url: https://codereview.chromium.org/2558193002
Cr-Commit-Position: refs/heads/master@{#41567}
This commit is contained in:
lpy 2016-12-07 16:27:43 -08:00 committed by Commit bot
parent c7c19c86a7
commit ecdff43b99
2 changed files with 15 additions and 2 deletions

View File

@ -21,8 +21,13 @@ TraceConfig* TraceConfig::CreateDefaultTraceConfig() {
}
bool TraceConfig::IsCategoryGroupEnabled(const char* category_group) const {
for (auto included_category : included_categories_) {
if (strcmp(included_category.data(), category_group) == 0) return true;
std::stringstream category_stream(category_group);
while (category_stream.good()) {
std::string category;
getline(category_stream, category, ',');
for (auto included_category : included_categories_) {
if (category == included_category) return true;
}
}
return false;
}

View File

@ -25,6 +25,14 @@ TEST(TestTraceConfig) {
CHECK_EQ(trace_config->IsCategoryGroupEnabled(
TRACE_DISABLED_BY_DEFAULT("v8.runtime")),
true);
CHECK_EQ(trace_config->IsCategoryGroupEnabled("v8,v8.cpu_profile"), true);
CHECK_EQ(
trace_config->IsCategoryGroupEnabled("v8,disabled-by-default-v8.runtime"),
true);
CHECK_EQ(trace_config->IsCategoryGroupEnabled(
"v8_cpu_profile,v8.cpu_profile.hires"),
false);
delete trace_config;
}