Index: base/trace_event/trace_event_etw_export_win.cc |
diff --git a/base/trace_event/trace_event_etw_export_win.cc b/base/trace_event/trace_event_etw_export_win.cc |
index 47e6353704764112b98cef7d794b08f9726758bb..01529875035b337f6aafb9fe8c7d2a46619ddfdb 100644 |
--- a/base/trace_event/trace_event_etw_export_win.cc |
+++ b/base/trace_event/trace_event_etw_export_win.cc |
@@ -90,6 +90,9 @@ const char* disabled_other_events_group_name = |
"__DISABLED_OTHER_EVENTS"; // 0x4000000000000000 |
uint64 other_events_keyword_bit = 1ULL << 61; |
uint64 disabled_other_events_keyword_bit = 1ULL << 62; |
+ |
+// Time between checks for ETW keyword changes (in milliseconds). |
+unsigned int kUpdateTimerDelayMs = 1000; |
} // namespace |
// Redirector function for EventRegister. Called by macros in |
@@ -171,6 +174,11 @@ void TraceEventETWExport::DisableETWExport() { |
} |
// static |
+bool TraceEventETWExport::IsETWExportEnabled() { |
+ return (GetInstance() && GetInstance()->etw_export_enabled_); |
brucedawson
2015/06/26 22:24:24
If you move this and change it in the same CL then
|
+} |
+ |
+// static |
void TraceEventETWExport::AddEvent( |
char phase, |
const unsigned char* category_group_enabled, |
@@ -297,10 +305,6 @@ void TraceEventETWExport::AddCustomEvent(const char* name, |
arg_value_2, arg_name_3, arg_value_3); |
} |
-void TraceEventETWExport::Resurrect() { |
- StaticMemorySingletonTraits<TraceEventETWExport>::Resurrect(); |
-} |
- |
// static |
bool TraceEventETWExport::IsCategoryGroupEnabled( |
const char* category_group_name) { |
@@ -324,21 +328,36 @@ bool TraceEventETWExport::IsCategoryGroupEnabled( |
return false; |
} |
-void TraceEventETWExport::UpdateEnabledCategories() { |
+// static |
+void TraceEventETWExport::StartKeywordUpdateTimer() { |
+ if (IsETWExportEnabled()) { |
+ GetInstance()->keyword_update_timer_.Start( |
+ FROM_HERE, base::TimeDelta::FromMilliseconds(kUpdateTimerDelayMs), |
+ base::Bind(&TraceEventETWExport::KeywordUpdateTimerCallback)); |
+ } |
+} |
+ |
+void TraceEventETWExport::Resurrect() { |
+ StaticMemorySingletonTraits<TraceEventETWExport>::Resurrect(); |
+} |
+ |
+bool TraceEventETWExport::UpdateEnabledCategories() { |
+ if (etw_match_any_keyword_ == CHROME_Context.MatchAnyKeyword) |
+ return false; |
+ |
// If the keyword has changed, update each category. |
// Chrome_Context.MatchAnyKeyword is set by UIforETW (or other ETW trace |
// recording tools) using the ETW infrastructure. This value will be set in |
// all Chrome processes that have registered their ETW provider. |
- if (etw_match_any_keyword_ != CHROME_Context.MatchAnyKeyword) { |
- etw_match_any_keyword_ = CHROME_Context.MatchAnyKeyword; |
- for (int i = 0; i < ARRAYSIZE(filtered_event_group_names); i++) { |
- if (etw_match_any_keyword_ & (1ULL << i)) { |
- categories_status_[filtered_event_group_names[i]] = true; |
- } else { |
- categories_status_[filtered_event_group_names[i]] = false; |
- } |
+ etw_match_any_keyword_ = CHROME_Context.MatchAnyKeyword; |
+ for (int i = 0; i < ARRAYSIZE(filtered_event_group_names); i++) { |
+ if (etw_match_any_keyword_ & (1ULL << i)) { |
+ categories_status_[filtered_event_group_names[i]] = true; |
+ } else { |
+ categories_status_[filtered_event_group_names[i]] = false; |
} |
} |
+ |
// Also update the two default categories. |
if (etw_match_any_keyword_ & other_events_keyword_bit) { |
categories_status_[other_events_group_name] = true; |
@@ -350,6 +369,8 @@ void TraceEventETWExport::UpdateEnabledCategories() { |
} else { |
categories_status_[disabled_other_events_group_name] = false; |
} |
+ |
+ return true; |
} |
bool TraceEventETWExport::IsCategoryEnabled(const char* category_name) const { |
@@ -371,5 +392,13 @@ bool TraceEventETWExport::IsCategoryEnabled(const char* category_name) const { |
} |
} |
+// static |
+void TraceEventETWExport::KeywordUpdateTimerCallback() { |
+ DCHECK(GetInstance()); |
+ if (IsETWExportEnabled()) { |
+ if (GetInstance()->UpdateEnabledCategories()) |
+ TraceLog::GetInstance()->UpdateCategoryGroupEnabledFlags(); |
+ } |
+} |
} // namespace trace_event |
} // namespace base |