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

Unified Diff: base/metrics/field_trial.cc

Issue 2570473003: NoBarrier_Load()/NoBarrier_Store() for manipulating activated field. (Closed)
Patch Set: 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 | « base/metrics/field_trial.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/field_trial.cc
diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc
index aed51bf839c41dacfca96c85bd0785c26fa73e6d..0fc8cc66b2d8a9a13713332a51e1e5db831520ec 100644
--- a/base/metrics/field_trial.cc
+++ b/base/metrics/field_trial.cc
@@ -726,7 +726,7 @@ void FieldTrialList::GetInitiallyActiveFieldTrials(
StringPiece trial_name;
StringPiece group_name;
- if (entry->activated &&
+ if (subtle::NoBarrier_Load(&entry->activated) &&
entry->GetTrialAndGroupName(&trial_name, &group_name)) {
FieldTrial::ActiveGroup group;
group.trial_name = trial_name.as_string();
@@ -1083,6 +1083,9 @@ void FieldTrialList::ClearParamsFromSharedMemoryForTesting() {
FieldTrial::FieldTrialEntry* new_entry =
allocator->GetAsObject<FieldTrial::FieldTrialEntry>(new_ref,
kFieldTrialType);
+ // Note: No need to use NoBarrier ops below because this is the browser
+ // process so the value we're reading won't change underneath us and the new
+ // entry we're assigning to is not iterable yet.
new_entry->activated = prev_entry->activated;
bcwhite 2016/12/13 13:38:50 These need to be accessed using atomic ops or you'
Alexei Svitkine (slow) 2016/12/13 15:26:04 Done.
new_entry->pickle_size = pickle.size();
@@ -1186,7 +1189,7 @@ bool FieldTrialList::CreateTrialsFromSharedMemory(
CreateFieldTrial(trial_name.as_string(), group_name.as_string());
trial->ref_ = ref;
- if (entry->activated) {
+ if (subtle::NoBarrier_Load(&entry->activated)) {
// Call |group()| to mark the trial as "used" and notify observers, if
// any. This is useful to ensure that field trials created in child
// processes are properly reported in crash reports.
@@ -1278,6 +1281,7 @@ void FieldTrialList::AddToAllocatorWhileLocked(
FieldTrial::FieldTrialEntry* entry =
allocator->GetAsObject<FieldTrial::FieldTrialEntry>(ref, kFieldTrialType);
+ // Note: The entry isn't iterable yet, so no need to use NoBarrier_Store().
entry->activated = trial_state.activated;
bcwhite 2016/12/13 13:38:50 Still need to so "linters" and "sanitizers" won't
Alexei Svitkine (slow) 2016/12/13 15:26:04 Done.
entry->pickle_size = pickle.size();
@@ -1313,7 +1317,7 @@ void FieldTrialList::ActivateFieldTrialEntryWhileLocked(
FieldTrial::FieldTrialEntry* entry =
allocator->GetAsObject<FieldTrial::FieldTrialEntry>(ref,
kFieldTrialType);
- entry->activated = true;
+ subtle::NoBarrier_Store(&entry->activated, 1);
}
}
« no previous file with comments | « base/metrics/field_trial.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698