Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2046)

Unified Diff: base/trace_event/trace_log.cc

Issue 1348613006: [tracing] Fix races in TraceLog's EnabledStateObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/trace_event/trace_log.cc
diff --git a/base/trace_event/trace_log.cc b/base/trace_event/trace_log.cc
index e3331559d7e849c9768af57ed14577ac255cca50..eed24118a48ff9be7cc79901d5545d7568aa1d33 100644
--- a/base/trace_event/trace_log.cc
+++ b/base/trace_event/trace_log.cc
@@ -808,10 +808,12 @@ int TraceLog::GetNumTracesRecorded() {
}
void TraceLog::AddEnabledStateObserver(EnabledStateObserver* listener) {
+ AutoLock lock(lock_);
enabled_state_observer_list_.push_back(listener);
}
void TraceLog::RemoveEnabledStateObserver(EnabledStateObserver* listener) {
+ AutoLock lock(lock_);
std::vector<EnabledStateObserver*>::iterator it =
std::find(enabled_state_observer_list_.begin(),
enabled_state_observer_list_.end(), listener);
@@ -820,6 +822,7 @@ void TraceLog::RemoveEnabledStateObserver(EnabledStateObserver* listener) {
}
bool TraceLog::HasEnabledStateObserver(EnabledStateObserver* listener) const {
+ AutoLock lock(lock_);
std::vector<EnabledStateObserver*>::const_iterator it =
std::find(enabled_state_observer_list_.begin(),
enabled_state_observer_list_.end(), listener);

Powered by Google App Engine
This is Rietveld 408576698