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

Unified Diff: base/metrics/field_trial_param_associator.cc

Issue 2463223002: Store field trial parameters in shared memory (Closed)
Patch Set: fix tests Created 4 years, 1 month 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/metrics/field_trial_param_associator.cc
diff --git a/base/metrics/field_trial_param_associator.cc b/base/metrics/field_trial_param_associator.cc
index b96cc396df874689af034691d9479a780ae78417..3c35c1887fabc59992a406c77820a6a2f60445e1 100644
--- a/base/metrics/field_trial_param_associator.cc
+++ b/base/metrics/field_trial_param_associator.cc
@@ -4,6 +4,7 @@
#include "base/metrics/field_trial_param_associator.h"
+#include "base/debug/stack_trace.h"
#include "base/metrics/field_trial.h"
namespace base {
@@ -37,20 +38,44 @@ bool FieldTrialParamAssociator::AssociateFieldTrialParams(
bool FieldTrialParamAssociator::GetFieldTrialParams(
const std::string& trial_name,
FieldTrialParams* params) {
+ FieldTrial* field_trial = FieldTrialList::Find(trial_name);
+ if (!field_trial)
+ return false;
+ const FieldTrialKey key(trial_name, field_trial->group_name());
+
+ // We have to scope down here, since calling group_name() might result in a
+ // call to AddToAllocatorWhileLocked(), which might call
Alexei Svitkine (slow) 2016/11/22 17:46:37 So one consequence of this set up is that all fiel
lawrencewu 2016/11/22 20:25:44 Done.
+ // GetFieldTrialParamsWithoutFallback() and cause a deadlock.
+ AutoLock scoped_lock(lock_);
+ if (!ContainsKey(field_trial_params_, key))
+ return FieldTrialList::GetParamsFromSharedMemory(field_trial, params);
Alexei Svitkine (slow) 2016/11/22 17:46:37 Please add a comment explaining the flow for futur
lawrencewu 2016/11/22 20:25:44 Done.
+
+ *params = field_trial_params_[key];
+ return true;
+}
+
+void FieldTrialParamAssociator::GetFieldTrialParamsWithoutFallback(
+ const std::string& trial_name,
+ const std::string& group_name,
+ FieldTrialParams* params) {
AutoLock scoped_lock(lock_);
- const std::string group_name = FieldTrialList::FindFullName(trial_name);
const FieldTrialKey key(trial_name, group_name);
if (!ContainsKey(field_trial_params_, key))
- return false;
+ return;
*params = field_trial_params_[key];
- return true;
}
void FieldTrialParamAssociator::ClearAllParamsForTesting() {
AutoLock scoped_lock(lock_);
field_trial_params_.clear();
+ FieldTrialList::ClearParamsFromSharedMemoryForTesting();
+}
+
+void FieldTrialParamAssociator::ClearAllCachedParamsForTesting() {
+ AutoLock scoped_lock(lock_);
+ field_trial_params_.clear();
}
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698