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

Unified Diff: base/metrics/field_trial.h

Issue 2570473003: NoBarrier_Load()/NoBarrier_Store() for manipulating activated field. (Closed)
Patch Set: Address comments. Created 4 years 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 | base/metrics/field_trial.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/field_trial.h
diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h
index 8a84baea34e338ec3d449cda5c4010f11595ea01..866d9f70f32fd4c7c0b40c7b0f85b69d80efed8e 100644
--- a/base/metrics/field_trial.h
+++ b/base/metrics/field_trial.h
@@ -63,6 +63,7 @@
#include <string>
#include <vector>
+#include "base/atomicops.h"
#include "base/base_export.h"
#include "base/command_line.h"
#include "base/feature_list.h"
@@ -143,8 +144,11 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
static constexpr size_t kExpectedInstanceSize = 8;
// Whether or not this field trial is activated. This is really just a
- // boolean but marked as a uint32_t for portability reasons.
- uint32_t activated;
+ // boolean but using a 32 bit value for portability reasons. It should be
+ // accessed via NoBarrier_Load()/NoBarrier_Store() to prevent the compiler
+ // from doing unexpected optimizations because it thinks that only one
+ // thread is accessing the memory location.
+ subtle::Atomic32 activated;
// Size of the pickled structure, NOT the total size of this entry.
uint32_t pickle_size;
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698