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

Unified Diff: base/files/file_tracing.cc

Issue 2114993003: Access FileTracing::g_provider atomically to prevent data races (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_tracing.cc
diff --git a/base/files/file_tracing.cc b/base/files/file_tracing.cc
index 6d11cbc746ed268a357e0d2ba08d463c501e5d96..c909569e692e8bf5c2567b515e321740c38547f1 100644
--- a/base/files/file_tracing.cc
+++ b/base/files/file_tracing.cc
@@ -4,8 +4,11 @@
#include "base/files/file_tracing.h"
+#include "base/atomicops.h"
#include "base/files/file.h"
+using base::subtle::AtomicWord;
danakj 2016/07/07 22:40:36 nit: you could put this in the method that uses it
Dan Beam 2016/07/07 23:13:48 Done.
+
namespace base {
namespace {
@@ -19,7 +22,8 @@ bool FileTracing::IsCategoryEnabled() {
// static
void FileTracing::SetProvider(FileTracing::Provider* provider) {
- g_provider = provider;
+ base::subtle::NoBarrier_Store(reinterpret_cast<AtomicWord*>(&g_provider),
danakj 2016/07/07 22:40:36 I think the way most people do this would be with
Dan Beam 2016/07/07 23:13:48 g_provider should only be set once. ever. i can ve
danakj 2016/07/07 23:21:04 Ah, so it's just threads are reading null.. readin
+ reinterpret_cast<AtomicWord>(provider));
}
FileTracing::ScopedEnabler::ScopedEnabler() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698