Index: base/debug/trace_event_impl.cc |
diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc |
index 07679d1131250fb101401191d02434dc6e59e8b8..0cea5f7747795568bc834961ede794d6c1093a0c 100644 |
--- a/base/debug/trace_event_impl.cc |
+++ b/base/debug/trace_event_impl.cc |
@@ -393,14 +393,33 @@ const char* TraceLog::GetCategoryName(const unsigned char* category_enabled) { |
return g_categories[category_index]; |
} |
+static bool DoesCategoryContainMatchingTag(const char* tagged_category, |
rterrazas
2013/01/15 08:08:31
Implemented the support for multi tag and single t
|
+ const char* tag_pattern) { |
+ CStringTokenizer tag_tokens(tagged_category, |
+ tagged_category + strlen(tagged_category), ","); |
+ while (tag_tokens.GetNext()) { |
+ std::string trimmed_tag; |
+ //Trimming tokens to allow categories with arbitrary spaces: |
+ // i.e: "webkit, input" or "webkit , input". |
+ TrimWhitespaceASCII(tag_tokens.token(), TRIM_ALL, &trimmed_tag); |
+ if(trimmed_tag.length() == 0) |
+ continue; |
+ if (MatchPattern(trimmed_tag.c_str(), tag_pattern)) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
static void EnableMatchingCategory(int category_index, |
- const std::vector<std::string>& patterns, |
+ const std::vector<std::string>& tag_patterns, |
unsigned char matched_value, |
unsigned char unmatched_value) { |
- std::vector<std::string>::const_iterator ci = patterns.begin(); |
+ std::vector<std::string>::const_iterator ci = tag_patterns.begin(); |
bool is_match = false; |
- for (; ci != patterns.end(); ++ci) { |
- is_match = MatchPattern(g_categories[category_index], ci->c_str()); |
+ for (; ci != tag_patterns.end(); ++ci) { |
+ is_match = DoesCategoryContainMatchingTag(g_categories[category_index], |
+ ci->c_str()); |
+ |
if (is_match) |
break; |
} |
@@ -408,14 +427,16 @@ static void EnableMatchingCategory(int category_index, |
matched_value : unmatched_value; |
} |
-// Enable/disable each category based on the category filters in |patterns|. |
-// If the category name matches one of the patterns, its enabled status is set |
-// to |matched_value|. Otherwise its enabled status is set to |unmatched_value|. |
-static void EnableMatchingCategories(const std::vector<std::string>& patterns, |
- unsigned char matched_value, |
- unsigned char unmatched_value) { |
+// Enable/disable each category based on the category filters in |tag_patterns|. |
+// If the category name contains a tag that matches one of the tag_patterns, |
+// its enabled status is set to |matched_value|. |
+// Otherwise its enabled status is set to |unmatched_value|. |
+static void EnableMatchingCategories( |
+ const std::vector<std::string>& tag_patterns, |
+ unsigned char matched_value, |
+ unsigned char unmatched_value) { |
for (int i = 0; i < g_category_index; i++) |
- EnableMatchingCategory(i, patterns, matched_value, unmatched_value); |
+ EnableMatchingCategory(i, tag_patterns, matched_value, unmatched_value); |
} |
const unsigned char* TraceLog::GetCategoryEnabledInternal(const char* name) { |
@@ -445,13 +466,13 @@ const unsigned char* TraceLog::GetCategoryEnabledInternal(const char* name) { |
g_categories[new_index] = new_name; |
DCHECK(!g_category_enabled[new_index]); |
if (enabled_) { |
- // Note that if both included and excluded_categories are empty, the |
+ // Note that if both included and excluded_tag_patterns are empty, the |
// else clause below excludes nothing, thereby enabling this category. |
- if (!included_categories_.empty()) { |
- EnableMatchingCategory(new_index, included_categories_, |
+ if (!included_tag_patterns_.empty()) { |
+ EnableMatchingCategory(new_index, included_tag_patterns_, |
CATEGORY_ENABLED, 0); |
} else { |
- EnableMatchingCategory(new_index, excluded_categories_, |
+ EnableMatchingCategory(new_index, excluded_tag_patterns_, |
0, CATEGORY_ENABLED); |
} |
} else { |
@@ -474,8 +495,8 @@ void TraceLog::GetKnownCategories(std::vector<std::string>* categories) { |
categories->push_back(g_categories[i]); |
} |
-void TraceLog::SetEnabled(const std::vector<std::string>& included_categories, |
- const std::vector<std::string>& excluded_categories) { |
+void TraceLog::SetEnabled(const std::vector<std::string>& included_tag_patterns, |
+ const std::vector<std::string>& excluded_tag_patterns) { |
rterrazas
2013/01/15 08:08:31
Crossed the 80 char barrier, seemed moving the par
rterrazas
2013/01/18 01:25:35
Done.
|
AutoLock lock(lock_); |
if (enabled_) |
return; |
@@ -493,33 +514,33 @@ void TraceLog::SetEnabled(const std::vector<std::string>& included_categories, |
logged_events_.reserve(1024); |
enabled_ = true; |
- included_categories_ = included_categories; |
- excluded_categories_ = excluded_categories; |
- // Note that if both included and excluded_categories are empty, the else |
- // clause below excludes nothing, thereby enabling all categories. |
- if (!included_categories_.empty()) |
- EnableMatchingCategories(included_categories_, CATEGORY_ENABLED, 0); |
+ included_tag_patterns_ = included_tag_patterns; |
+ excluded_tag_patterns_ = excluded_tag_patterns; |
+ // Note that if both included and excluded_tag_patterns are empty, the |
+ // else clause below excludes nothing, thereby enabling all categories. |
+ if (!included_tag_patterns_.empty()) |
+ EnableMatchingCategories(included_tag_patterns_, CATEGORY_ENABLED, 0); |
else |
- EnableMatchingCategories(excluded_categories_, 0, CATEGORY_ENABLED); |
+ EnableMatchingCategories(excluded_tag_patterns_, 0, CATEGORY_ENABLED); |
} |
-void TraceLog::SetEnabled(const std::string& categories) { |
+void TraceLog::SetEnabled(const std::string& tag_patterns) { |
std::vector<std::string> included, excluded; |
- // Tokenize list of categories, delimited by ','. |
- StringTokenizer tokens(categories, ","); |
+ // Tokenize list of tag patterns, delimited by ','. |
+ StringTokenizer tokens(tag_patterns, ","); |
while (tokens.GetNext()) { |
bool is_included = true; |
- std::string category = tokens.token(); |
- // Excluded categories start with '-'. |
- if (category.at(0) == '-') { |
- // Remove '-' from category string. |
- category = category.substr(1); |
+ std::string tag_pattern = tokens.token(); |
+ // Excluded tags start with '-'. |
+ if (tag_pattern.at(0) == '-') { |
+ // Remove '-' from tag pattern string. |
+ tag_pattern = tag_pattern.substr(1); |
is_included = false; |
} |
if (is_included) |
- included.push_back(category); |
+ included.push_back(tag_pattern); |
else |
- excluded.push_back(category); |
+ excluded.push_back(tag_pattern); |
} |
SetEnabled(included, excluded); |
} |
@@ -529,8 +550,8 @@ void TraceLog::GetEnabledTraceCategories( |
std::vector<std::string>* excluded_out) { |
AutoLock lock(lock_); |
if (enabled_) { |
- *included_out = included_categories_; |
- *excluded_out = excluded_categories_; |
+ *included_out = included_tag_patterns_; |
+ *excluded_out = excluded_tag_patterns_; |
} |
} |
@@ -551,8 +572,8 @@ void TraceLog::SetDisabled() { |
dispatching_to_observer_list_ = false; |
enabled_ = false; |
- included_categories_.clear(); |
- excluded_categories_.clear(); |
+ included_tag_patterns_.clear(); |
+ excluded_tag_patterns_.clear(); |
watch_category_ = NULL; |
watch_event_name_ = ""; |
for (int i = 0; i < g_category_index; i++) |