Chromium Code Reviews| Index: base/debug/trace_event_impl.cc |
| diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc |
| index cbcf54b81c6aac08b08d5f71fb6796f6869b84de..28dbb8e358b0be8c1494af827d69e8381ee73935 100644 |
| --- a/base/debug/trace_event_impl.cc |
| +++ b/base/debug/trace_event_impl.cc |
| @@ -49,18 +49,19 @@ const size_t kTraceEventBatchSize = 1000; |
| namespace { |
| -// Parallel arrays g_categories and g_category_enabled are separate so that |
| -// a pointer to a member of g_category_enabled can be easily converted to an |
| -// index into g_categories. This allows macros to deal only with char enabled |
| -// pointers from g_category_enabled, and we can convert internally to determine |
| -// the category name from the char enabled pointer. |
| -const char* g_categories[TRACE_EVENT_MAX_CATEGORIES] = { |
| +// Parallel arrays g_category_groups and g_category_group_enabled are separate |
| +// so that a pointer to a member of g_category_group_enabled can be easily |
| +// converted to an index into g_category_groups. This allows macros to deal |
| +// only with char enabled pointers from g_category_group_enabled, and we can |
| +// convert internally to determine the category name from the char enabled |
| +// pointer. |
| +const char* g_category_groups[TRACE_EVENT_MAX_CATEGORIES] = { |
|
nduca
2013/02/21 06:02:36
MAX_CATEGORY_GROUPS
rterrazas
2013/02/25 05:55:02
Done.
|
| "tracing already shutdown", |
| "tracing categories exhausted; must increase TRACE_EVENT_MAX_CATEGORIES", |
| "__metadata", |
| }; |
| // The enabled flag is char instead of bool so that the API can be used from C. |
| -unsigned char g_category_enabled[TRACE_EVENT_MAX_CATEGORIES] = { 0 }; |
| +unsigned char g_category_group_enabled[TRACE_EVENT_MAX_CATEGORIES] = { 0 }; |
| const int g_category_already_shutdown = 0; |
| const int g_category_categories_exhausted = 1; |
| const int g_category_metadata = 2; |
| @@ -101,7 +102,7 @@ void CopyTraceEventParameter(char** buffer, |
| TraceEvent::TraceEvent() |
| : id_(0u), |
| - category_enabled_(NULL), |
| + category_group_enabled_(NULL), |
| name_(NULL), |
| thread_id_(0), |
| phase_(TRACE_EVENT_PHASE_BEGIN), |
| @@ -114,7 +115,7 @@ TraceEvent::TraceEvent() |
| TraceEvent::TraceEvent(int thread_id, |
| TimeTicks timestamp, |
| char phase, |
| - const unsigned char* category_enabled, |
| + const unsigned char* category_group_enabled, |
| const char* name, |
| unsigned long long id, |
| int num_args, |
| @@ -124,7 +125,7 @@ TraceEvent::TraceEvent(int thread_id, |
| unsigned char flags) |
| : timestamp_(timestamp), |
| id_(id), |
| - category_enabled_(category_enabled), |
| + category_group_enabled_(category_group_enabled), |
| name_(name), |
| thread_id_(thread_id), |
| phase_(phase), |
| @@ -242,12 +243,12 @@ void TraceEvent::AppendEventsAsJSON(const std::vector<TraceEvent>& events, |
| void TraceEvent::AppendAsJSON(std::string* out) const { |
| int64 time_int64 = timestamp_.ToInternalValue(); |
| int process_id = TraceLog::GetInstance()->process_id(); |
| - // Category name checked at category creation time. |
| + // Category group checked at category creation time. |
| DCHECK(!strchr(name_, '"')); |
| StringAppendF(out, |
| "{\"cat\":\"%s\",\"pid\":%i,\"tid\":%i,\"ts\":%" PRId64 "," |
| "\"ph\":\"%c\",\"name\":\"%s\",\"args\":{", |
| - TraceLog::GetCategoryName(category_enabled_), |
| + TraceLog::GetCategoryGroupName(category_group_enabled_), |
| process_id, |
| thread_id_, |
| time_int64, |
| @@ -357,10 +358,11 @@ TraceLog::TraceLog() |
| // traced or not, so we allow races on the enabled flag to keep the trace |
| // macros fast. |
| // TODO(jbates): ANNOTATE_BENIGN_RACE_SIZED crashes windows TSAN bots: |
| - // ANNOTATE_BENIGN_RACE_SIZED(g_category_enabled, sizeof(g_category_enabled), |
| - // "trace_event category enabled"); |
| + // ANNOTATE_BENIGN_RACE_SIZED(g_category_group_enabled, |
| + // sizeof(g_category_group_enabled), |
| + // "trace_event category enabled"); |
| for (int i = 0; i < TRACE_EVENT_MAX_CATEGORIES; ++i) { |
| - ANNOTATE_BENIGN_RACE(&g_category_enabled[i], |
| + ANNOTATE_BENIGN_RACE(&g_category_group_enabled[i], |
| "trace_event category enabled"); |
| } |
| #if defined(OS_NACL) // NaCl shouldn't expose the process id. |
| @@ -373,128 +375,230 @@ TraceLog::TraceLog() |
| TraceLog::~TraceLog() { |
| } |
| -const unsigned char* TraceLog::GetCategoryEnabled(const char* name) { |
| +const unsigned char* TraceLog::GetCategoryGroupEnabled( |
| + const char* category_group) { |
| TraceLog* tracelog = GetInstance(); |
| if (!tracelog) { |
| - DCHECK(!g_category_enabled[g_category_already_shutdown]); |
| - return &g_category_enabled[g_category_already_shutdown]; |
| + DCHECK(!g_category_group_enabled[g_category_already_shutdown]); |
| + return &g_category_group_enabled[g_category_already_shutdown]; |
| } |
| - return tracelog->GetCategoryEnabledInternal(name); |
| + return tracelog->GetCategoryGroupEnabledInternal(category_group); |
| } |
| -const char* TraceLog::GetCategoryName(const unsigned char* category_enabled) { |
| - // Calculate the index of the category by finding category_enabled in |
| - // g_category_enabled array. |
| - uintptr_t category_begin = reinterpret_cast<uintptr_t>(g_category_enabled); |
| - uintptr_t category_ptr = reinterpret_cast<uintptr_t>(category_enabled); |
| +const char* TraceLog::GetCategoryGroupName( |
| + const unsigned char* category_group_enabled) { |
| + // Calculate the index of the category group by finding |
| + // category_group_enabled in g_category_group_enabled array. |
| + uintptr_t category_begin = reinterpret_cast<uintptr_t>( |
| + g_category_group_enabled); |
|
nduca
2013/02/21 06:02:36
check your indentation throughout, as noted before
rterrazas
2013/02/25 05:55:02
Done.
rterrazas
2013/02/25 05:55:02
Done.
|
| + uintptr_t category_ptr = reinterpret_cast<uintptr_t>(category_group_enabled); |
| DCHECK(category_ptr >= category_begin && |
| - category_ptr < reinterpret_cast<uintptr_t>(g_category_enabled + |
| + category_ptr < reinterpret_cast<uintptr_t>(g_category_group_enabled + |
| TRACE_EVENT_MAX_CATEGORIES)) << |
| "out of bounds category pointer"; |
| uintptr_t category_index = |
| - (category_ptr - category_begin) / sizeof(g_category_enabled[0]); |
| - return g_categories[category_index]; |
| -} |
| - |
| -static void EnableMatchingCategory(int category_index, |
| - const std::vector<std::string>& patterns, |
| - unsigned char matched_value, |
| - unsigned char unmatched_value) { |
| - std::vector<std::string>::const_iterator ci = patterns.begin(); |
| - bool is_match = false; |
| - for (; ci != patterns.end(); ++ci) { |
| - is_match = MatchPattern(g_categories[category_index], ci->c_str()); |
| - if (is_match) |
| - break; |
| - } |
| - g_category_enabled[category_index] = is_match ? |
| - matched_value : unmatched_value; |
| + (category_ptr - category_begin) / sizeof(g_category_group_enabled[0]); |
| + return g_category_groups[category_index]; |
| +} |
| + |
| +void TraceLog::EnableIncludedCategoryGroup(int category_index, |
|
nduca
2013/02/21 06:02:36
any reason we're passing the filter when this is a
rterrazas
2013/02/25 05:55:02
It's static function, at the time I liked it bette
|
| + const CategoryFilter& category_filter) { |
| + bool is_enabled = |
| + category_filter.IsCategoryGroupEnabled(g_category_groups[category_index]); |
| + g_category_group_enabled[category_index] = is_enabled ? |
| + TraceLog::CATEGORY_ENABLED : 0; |
| } |
| -// 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) { |
| +void TraceLog::EnableIncludedCategoryGroups( |
| + const CategoryFilter& category_filter) { |
| for (int i = 0; i < g_category_index; i++) |
| - EnableMatchingCategory(i, patterns, matched_value, unmatched_value); |
| + EnableIncludedCategoryGroup(i, category_filter); |
| } |
| -const unsigned char* TraceLog::GetCategoryEnabledInternal(const char* name) { |
| +const unsigned char* TraceLog::GetCategoryGroupEnabledInternal( |
| + const char* category_group) { |
| AutoLock lock(lock_); |
| - DCHECK(!strchr(name, '"')) << "Category names may not contain double quote"; |
| + DCHECK(!strchr(category_group, '"')) << |
|
dsinclair
2013/02/22 21:13:44
Can we do this before we lock?
rterrazas
2013/02/25 05:55:02
Done.
|
| + "Category group names may not contain double quote"; |
|
dsinclair
2013/02/22 21:13:44
contain a double
dsinclair
2013/02/22 21:13:44
Why can't it contain a quote? Can it contain a , o
rterrazas
2013/02/25 05:55:02
The double quote restriction must be related to th
|
| - unsigned char* category_enabled = NULL; |
| - // Search for pre-existing category matching this name |
| + unsigned char* category_group_enabled = NULL; |
| + // Search for pre-existing category matching this category_group |
| for (int i = 0; i < g_category_index; i++) { |
| - if (strcmp(g_categories[i], name) == 0) { |
| - category_enabled = &g_category_enabled[i]; |
| + if (strcmp(g_category_groups[i], category_group) == 0) { |
| + category_group_enabled = &g_category_group_enabled[i]; |
| break; |
| } |
| } |
| - if (!category_enabled) { |
| + if (!category_group_enabled) { |
| // Create a new category |
| DCHECK(g_category_index < TRACE_EVENT_MAX_CATEGORIES) << |
| "must increase TRACE_EVENT_MAX_CATEGORIES"; |
| if (g_category_index < TRACE_EVENT_MAX_CATEGORIES) { |
| int new_index = g_category_index++; |
| - // Don't hold on to the name pointer, so that we can create categories |
| - // with strings not known at compile time (this is required by |
| - // SetWatchEvent). |
| - const char* new_name = strdup(name); |
| - ANNOTATE_LEAKING_OBJECT_PTR(new_name); |
| - g_categories[new_index] = new_name; |
| - DCHECK(!g_category_enabled[new_index]); |
| + // Don't hold on to the category_group pointer, so that we can create |
| + // category groups with strings not known at compile time (this is |
| + // required by SetWatchEvent). |
| + const char* new_group = strdup(category_group); |
| + ANNOTATE_LEAKING_OBJECT_PTR(new_group); |
| + g_category_groups[new_index] = new_group; |
| + DCHECK(!g_category_group_enabled[new_index]); |
| if (enable_count_) { |
| - // Note that if both included and excluded_categories are empty, the |
| - // else clause below excludes nothing, thereby enabling this category. |
| - if (!included_categories_.empty()) { |
| - EnableMatchingCategory(new_index, included_categories_, |
| - CATEGORY_ENABLED, 0); |
| - } else { |
| - EnableMatchingCategory(new_index, excluded_categories_, |
| - 0, CATEGORY_ENABLED); |
| - } |
| + // Note that if both included and excluded patterns in the |
| + // CategoryFilter are empty, we exclude nothing, |
| + // thereby enabling this category group. |
| + EnableIncludedCategoryGroup(new_index, category_filter_); |
| } else { |
| - g_category_enabled[new_index] = 0; |
| + g_category_group_enabled[new_index] = 0; |
| } |
| - category_enabled = &g_category_enabled[new_index]; |
| + category_group_enabled = &g_category_group_enabled[new_index]; |
| } else { |
| - category_enabled = &g_category_enabled[g_category_categories_exhausted]; |
| + category_group_enabled = |
| + &g_category_group_enabled[g_category_categories_exhausted]; |
| } |
| } |
| #if defined(OS_ANDROID) |
| - ApplyATraceEnabledFlag(category_enabled); |
| + ApplyATraceEnabledFlag(category_group_enabled); |
| #endif |
| - return category_enabled; |
| + return category_group_enabled; |
| } |
| -void TraceLog::GetKnownCategories(std::vector<std::string>* categories) { |
| +void TraceLog::GetKnownCategoryGroups( |
| + std::vector<std::string>* category_groups) { |
| AutoLock lock(lock_); |
| for (int i = 0; i < g_category_index; i++) |
| - categories->push_back(g_categories[i]); |
| + category_groups->push_back(g_category_groups[i]); |
| +} |
| + |
| +static bool DoesCategoryGroupContainCategory(const char* category_group, |
| + const char* category) { |
| + DCHECK(category); |
| + CStringTokenizer category_group_tokens(category_group, |
| + category_group + strlen(category_group), ","); |
| + while (category_group_tokens.GetNext()) { |
| + std::string category_group_token = category_group_tokens.token(); |
| + // Don't allow empty tokens, nor tokens with leading or trailing space. |
| + DCHECK(!category_group_token.empty() && |
| + category_group_token.at(0) != ' '&& |
| + category_group_token.at(category_group_token.length() - 1) != ' ') |
| + << "Disallowed category string"; |
| + if (MatchPattern(category_group_token.c_str(), category)) |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +const char* CategoryFilter::kDefaultCategoryFilterString = "-*Debug,-*Test"; |
| + |
| +CategoryFilter::CategoryFilter() { |
| + Initialize(CategoryFilter::kDefaultCategoryFilterString); |
| +} |
| + |
| +CategoryFilter::CategoryFilter(const std::string& filter_string) { |
| + Initialize(filter_string); |
| } |
| -void TraceLog::SetEnabled(const std::vector<std::string>& included_categories, |
| - const std::vector<std::string>& excluded_categories) { |
| +void CategoryFilter::Initialize(const std::string& filter_string) { |
| + // Pass 1: Tokenize list of categories, delimited by ','. |
|
nduca
2013/02/21 06:02:36
There's only one pass....?
rterrazas
2013/02/25 05:55:02
Done.
|
| + StringTokenizer tokens(filter_string, ","); |
| + while (tokens.GetNext()) { |
| + bool is_included = true; |
| + std::string category = tokens.token(); |
| + // Ignore empty categories. |
| + if(category.empty()) |
| + continue; |
| + // Excluded categories start with '-'. |
| + if (category.at(0) == '-') { |
| + // Remove '-' from category string. |
| + category = category.substr(1); |
| + is_included = false; |
| + } |
| + if (is_included) |
|
dsinclair
2013/02/22 21:13:44
Instead of storing is_included, why not just do th
rterrazas
2013/02/25 05:55:02
Like.
Done.
|
| + included_.push_back(category); |
| + else |
| + excluded_.push_back(category); |
| + } |
| +} |
| + |
| +void CategoryFilter::WriteString(std::string* out, |
| + bool included) const { |
| + std::vector<std::string>::const_iterator ci; |
| + std::vector<std::string>::const_iterator end; |
| + if (included) { |
| + ci = included_.begin(); |
| + end = included_.end(); |
| + } else { |
| + ci = excluded_.begin(); |
| + end = excluded_.end(); |
| + } |
| + |
| + for (; ci != end; ++ci) { |
| + if (included) |
| + StringAppendF(out, "%s,", ci->c_str()); |
| + else |
| + StringAppendF(out, "-%s,", ci->c_str()); |
|
dsinclair
2013/02/22 21:13:44
StringAppendF(out, "%s%s,", (included ? "" : "-"),
rterrazas
2013/02/25 05:55:02
Done.
|
| + } |
| +} |
| + |
| +void CategoryFilter::ToString(std::string* filter_string) const { |
|
nduca
2013/02/21 06:02:36
not sure that this makes sense... or works in all
rterrazas
2013/02/25 05:55:02
In Initialize, I ignored empty category patterns (
|
| + WriteString(filter_string, true); |
| + WriteString(filter_string, false); |
| +} |
| + |
| +bool CategoryFilter::IsCategoryGroupEnabled(const char* category_group_name) |
| + const { |
|
nduca
2013/02/21 06:02:36
indentation
rterrazas
2013/02/25 05:55:02
Done.
|
| + // TraceLog should call this method only as part of enabling/disabling |
| + // categories. |
| + std::vector<std::string>::const_iterator ci = included_.begin(); |
| + for (; ci != included_.end(); ++ci) { |
| + if (DoesCategoryGroupContainCategory(category_group_name, ci->c_str())) |
| + return true; |
| + } |
| + ci = excluded_.begin(); |
| + for (; ci != excluded_.end(); ++ci) { |
| + if (DoesCategoryGroupContainCategory(category_group_name, ci->c_str())) |
| + return false; |
| + } |
| + // If the category group is not excluded, and there are no included patterns |
| + // we consider this pattern enabled. |
| + return included_.empty(); |
| +} |
| + |
| +void CategoryFilter::Merge(const CategoryFilter& nested_filter) { |
| + included_.insert(included_.end(), |
| + nested_filter.included_.begin(), |
| + nested_filter.included_.end()); |
| + excluded_.insert(excluded_.end(), |
|
nduca
2013/02/21 06:02:36
indentation is funky
rterrazas
2013/02/25 05:55:02
Done.
|
| + nested_filter.excluded_.begin(), |
| + nested_filter.excluded_.end()); |
| +} |
| + |
| +bool CategoryFilter::HasIncludedCategories() const { |
| + return !included_.empty(); |
| +} |
| + |
| +void CategoryFilter::Clear() { |
|
nduca
2013/02/21 06:02:36
what use case necessitated this?
rterrazas
2013/02/25 05:55:02
SetEnabled() // If either old or new included cate
|
| + included_.clear(); |
| + excluded_.clear(); |
| +} |
| + |
| +void TraceLog::SetEnabled(const CategoryFilter& category_filter) { |
| + |
| + // Actually enable/disable the categories. |
|
nduca
2013/02/21 06:02:36
categyr groups
|
| AutoLock lock(lock_); |
| if (enable_count_++ > 0) { |
| // Tracing is already enabled, so just merge in enabled categories. |
| // We only expand the set of enabled categories upon nested SetEnable(). |
| - if (!included_categories_.empty() && !included_categories.empty()) { |
| - included_categories_.insert(included_categories_.end(), |
| - included_categories.begin(), |
| - included_categories.end()); |
| - EnableMatchingCategories(included_categories_, CATEGORY_ENABLED, 0); |
| + if (category_filter_.HasIncludedCategories() && |
|
nduca
2013/02/21 06:02:36
Can this just be part of merge? E.g. make merge do
rterrazas
2013/02/25 05:55:02
We could do something like MergeIfNeeded and Clear
|
| + category_filter.HasIncludedCategories()) { |
| + category_filter_.Merge(category_filter); |
| } else { |
| - // If either old or new included categories are empty, allow all events. |
| - included_categories_.clear(); |
| - excluded_categories_.clear(); |
| - EnableMatchingCategories(excluded_categories_, 0, CATEGORY_ENABLED); |
| + // If either old or new included categories are empty, allow all not |
| + // excluded events. |
| + category_filter_.Clear(); |
| } |
| + EnableIncludedCategoryGroups(category_filter_); |
| return; |
| } |
| @@ -510,45 +614,14 @@ void TraceLog::SetEnabled(const std::vector<std::string>& included_categories, |
| dispatching_to_observer_list_ = false; |
| logged_events_.reserve(1024); |
| - 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); |
| - else |
| - EnableMatchingCategories(excluded_categories_, 0, CATEGORY_ENABLED); |
| -} |
| - |
| -void TraceLog::SetEnabled(const std::string& categories) { |
| - std::vector<std::string> included, excluded; |
| - // Tokenize list of categories, delimited by ','. |
| - StringTokenizer tokens(categories, ","); |
| - 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); |
| - is_included = false; |
| - } |
| - if (is_included) |
| - included.push_back(category); |
| - else |
| - excluded.push_back(category); |
| - } |
| - SetEnabled(included, excluded); |
| + category_filter_ = CategoryFilter(category_filter); |
| + EnableIncludedCategoryGroups(category_filter_); |
| } |
| -void TraceLog::GetEnabledTraceCategories( |
| - std::vector<std::string>* included_out, |
| - std::vector<std::string>* excluded_out) { |
| +CategoryFilter& TraceLog::GetCurrentCategoryFilter() { |
| AutoLock lock(lock_); |
| - if (enable_count_) { |
| - *included_out = included_categories_; |
| - *excluded_out = excluded_categories_; |
| - } |
| + DCHECK(enable_count_ > 0); |
| + return category_filter_; |
| } |
| void TraceLog::SetDisabled() { |
| @@ -568,22 +641,14 @@ void TraceLog::SetDisabled() { |
| OnTraceLogWillDisable()); |
| dispatching_to_observer_list_ = false; |
| - included_categories_.clear(); |
| - excluded_categories_.clear(); |
| + category_filter_.Clear(); |
| watch_category_ = NULL; |
| watch_event_name_ = ""; |
| for (int i = 0; i < g_category_index; i++) |
| - g_category_enabled[i] = 0; |
| + g_category_group_enabled[i] = 0; |
| AddThreadNameMetadataEvents(); |
| } |
| -void TraceLog::SetEnabled(bool enabled) { |
| - if (enabled) |
| - SetEnabled(std::vector<std::string>(), std::vector<std::string>()); |
| - else |
| - SetDisabled(); |
| -} |
| - |
| void TraceLog::AddEnabledStateObserver(EnabledStateChangedObserver* listener) { |
| enabled_state_observer_list_.AddObserver(listener); |
| } |
| @@ -624,7 +689,7 @@ void TraceLog::Flush(const TraceLog::OutputCallback& cb) { |
| } |
| void TraceLog::AddTraceEvent(char phase, |
| - const unsigned char* category_enabled, |
| + const unsigned char* category_group_enabled, |
| const char* name, |
| unsigned long long id, |
| int num_args, |
| @@ -634,14 +699,14 @@ void TraceLog::AddTraceEvent(char phase, |
| unsigned char flags) { |
| int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); |
| - AddTraceEventWithThreadIdAndTimestamp(phase, category_enabled, name, id, |
| + AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, name, id, |
| thread_id, now, num_args, arg_names, |
| arg_types, arg_values, flags); |
| } |
| void TraceLog::AddTraceEventWithThreadIdAndTimestamp( |
| char phase, |
| - const unsigned char* category_enabled, |
| + const unsigned char* category_group_enabled, |
| const char* name, |
| unsigned long long id, |
| int thread_id, |
| @@ -654,7 +719,7 @@ void TraceLog::AddTraceEventWithThreadIdAndTimestamp( |
| DCHECK(name); |
| #if defined(OS_ANDROID) |
| - SendToATrace(phase, GetCategoryName(category_enabled), name, |
| + SendToATrace(phase, GetCategoryGroupName(category_group_enabled), name, |
| num_args, arg_names, arg_types, arg_values); |
| #endif |
| @@ -663,7 +728,7 @@ void TraceLog::AddTraceEventWithThreadIdAndTimestamp( |
| { |
| AutoLock lock(lock_); |
| - if (*category_enabled != CATEGORY_ENABLED) |
| + if (*category_group_enabled != CATEGORY_ENABLED) |
| return; |
| if (logged_events_.size() >= kTraceEventBufferSize) |
| return; |
| @@ -703,14 +768,14 @@ void TraceLog::AddTraceEventWithThreadIdAndTimestamp( |
| logged_events_.push_back( |
| TraceEvent(thread_id, |
| - now, phase, category_enabled, name, id, |
| + now, phase, category_group_enabled, name, id, |
| num_args, arg_names, arg_types, arg_values, |
| flags)); |
| if (logged_events_.size() == kTraceEventBufferSize) |
| notifier.AddNotificationWhileLocked(TRACE_BUFFER_FULL); |
| - if (watch_category_ == category_enabled && watch_event_name_ == name) |
| + if (watch_category_ == category_group_enabled && watch_event_name_ == name) |
| notifier.AddNotificationWhileLocked(EVENT_WATCH_NOTIFICATION); |
| } // release lock |
| @@ -742,7 +807,8 @@ void TraceLog::AddTraceEventEtw(char phase, |
| void TraceLog::SetWatchEvent(const std::string& category_name, |
| const std::string& event_name) { |
| - const unsigned char* category = GetCategoryEnabled(category_name.c_str()); |
| + const unsigned char* category = GetCategoryGroupEnabled( |
| + category_name.c_str()); |
| int notify_count = 0; |
| { |
| AutoLock lock(lock_); |
| @@ -752,7 +818,7 @@ void TraceLog::SetWatchEvent(const std::string& category_name, |
| // First, search existing events for watch event because we want to catch it |
| // even if it has already occurred. |
| for (size_t i = 0u; i < logged_events_.size(); ++i) { |
| - if (category == logged_events_[i].category_enabled() && |
| + if (category == logged_events_[i].category_group_enabled() && |
| strcmp(event_name.c_str(), logged_events_[i].name()) == 0) { |
| ++notify_count; |
| } |
| @@ -789,7 +855,7 @@ void TraceLog::AddThreadNameMetadataEvents() { |
| logged_events_.push_back( |
| TraceEvent(it->first, |
| TimeTicks(), TRACE_EVENT_PHASE_METADATA, |
| - &g_category_enabled[g_category_metadata], |
| + &g_category_group_enabled[g_category_metadata], |
| "thread_name", trace_event_internal::kNoEventId, |
| num_args, &arg_name, &arg_type, &arg_value, |
| TRACE_EVENT_FLAG_NONE)); |
| @@ -830,7 +896,7 @@ ScopedTrace::ScopedTrace( |
| reinterpret_cast<const unsigned char*>(TRACE_EVENT_API_ATOMIC_LOAD( |
| *event_uid)); |
| if (!category_enabled_) { |
| - category_enabled_ = TRACE_EVENT_API_GET_CATEGORY_ENABLED("gpu"); |
| + category_enabled_ = TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED("gpu"); |
| TRACE_EVENT_API_ATOMIC_STORE( |
| *event_uid, |
| reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(category_enabled_)); |