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

Unified Diff: base/metrics/field_trial.h

Issue 2453933004: Fix deadlock issue with AllStatesToString (Closed)
Patch Set: fix nit 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
« 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 9a7e5d26f25cf7bd3069b7fd2fe4dd65bdf65f1c..509ace4f77df5a6ec62a80d13eb18f19813a482b 100644
--- a/base/metrics/field_trial.h
+++ b/base/metrics/field_trial.h
@@ -251,6 +251,10 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
// status.
void FinalizeGroupChoice();
+ // Implements FinalizeGroupChoice() with the added flexibility of being
+ // deadlock-free if |is_locked| is true and the caller is holding a lock.
+ void FinalizeGroupChoiceImpl(bool is_locked);
+
// Returns the trial name and selected group name for this field trial via
// the output parameter |active_group|, but only if the group has already
// been chosen and has been externally observed via |group()| and the trial
@@ -266,6 +270,10 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
// untouched.
bool GetState(State* field_trial_state);
+ // Does the same thing as above, but is deadlock-free if the caller is holding
+ // a lock.
+ bool GetStateWhileLocked(State* field_trial_state);
+
// Returns the group_name. A winner need not have been chosen.
std::string group_name_internal() const { return group_name_; }
@@ -517,9 +525,9 @@ class BASE_EXPORT FieldTrialList {
// Remove an observer.
static void RemoveObserver(Observer* observer);
- // Grabs the lock and adds the field trial to the allocator. This should only
- // be called from FinalizeGroupChoice().
- static void OnGroupFinalized(FieldTrial* field_trial);
+ // Grabs the lock if necessary and adds the field trial to the allocator. This
+ // should only be called from FinalizeGroupChoice().
+ static void OnGroupFinalized(bool is_locked, FieldTrial* field_trial);
// Notify all observers that a group has been finalized for |field_trial|.
static void NotifyFieldTrialGroupSelection(FieldTrial* field_trial);
« 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