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

Unified Diff: src/profiler/profiler-listener.cc

Issue 2321073004: [profiler] Allow thread-safe access to add/remove code event observers. (Closed)
Patch Set: addressing the comment. Created 4 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
« no previous file with comments | « src/profiler/profiler-listener.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/profiler/profiler-listener.cc
diff --git a/src/profiler/profiler-listener.cc b/src/profiler/profiler-listener.cc
index 7ce874e6c1ef82dcdd927252095ba9856ba3f561..4bceac2e89530e4182a866168728bf7e813ca011 100644
--- a/src/profiler/profiler-listener.cc
+++ b/src/profiler/profiler-listener.cc
@@ -319,6 +319,7 @@ CodeEntry* ProfilerListener::NewCodeEntry(
}
void ProfilerListener::AddObserver(CodeEventObserver* observer) {
+ base::LockGuard<base::Mutex> guard(&mutex_);
if (std::find(observers_.begin(), observers_.end(), observer) !=
observers_.end())
return;
@@ -326,6 +327,7 @@ void ProfilerListener::AddObserver(CodeEventObserver* observer) {
}
void ProfilerListener::RemoveObserver(CodeEventObserver* observer) {
+ base::LockGuard<base::Mutex> guard(&mutex_);
auto it = std::find(observers_.begin(), observers_.end(), observer);
if (it == observers_.end()) return;
observers_.erase(it);
« no previous file with comments | « src/profiler/profiler-listener.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698