Index: base/metrics/field_trial.h |
diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h |
index e2e543947a10a97595b828c63a432c7710aaab79..26257ab4a890b70c257a23e5dfb854c0bf2c78d7 100644 |
--- a/base/metrics/field_trial.h |
+++ b/base/metrics/field_trial.h |
@@ -106,6 +106,14 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> { |
std::string group_name; |
}; |
+ // A triplet representing a FieldTrial, its selected group and whether it's |
+ // active. |
+ struct FieldTrialState { |
+ std::string trial_name; |
+ std::string group_name; |
+ bool activated; |
+ }; |
+ |
typedef std::vector<ActiveGroup> ActiveGroups; |
// A return value to indicate that a given instance has not yet had a group |
@@ -180,8 +188,10 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> { |
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, OneWinner); |
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, DisableProbability); |
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, ActiveGroups); |
+ FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, AllGroups); |
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, ActiveGroupsNotFinalized); |
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, Save); |
+ FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, SaveAll); |
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, DuplicateRestore); |
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, SetForcedTurnFeatureOff); |
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, SetForcedTurnFeatureOn); |
@@ -230,6 +240,13 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> { |
// untouched. |
bool GetActiveGroup(ActiveGroup* active_group) const; |
+ // Returns the trial name and selected group name for this field trial via |
+ // the output parameter |field_trial_state|, but only if the trial has not |
+ // been disabled. In that case, true is returned and |field_trial_state| is |
+ // filled in; otherwise, the result is false and |field_trial_state| is left |
+ // untouched. |
+ bool GetState(FieldTrialState* field_trial_state) const; |
+ |
// Returns the group_name. A winner need not have been chosen. |
std::string group_name_internal() const { return group_name_; } |
@@ -404,6 +421,16 @@ class BASE_EXPORT FieldTrialList { |
// by |CreateTrialsFromString()|. |
static void StatesToString(std::string* output); |
+ // Creates a persistent representation of all FieldTrial instances for |
+ // resurrection in another process. This allows randomization to be done in |
+ // one process, and secondary processes can be synchronized on the result. |
+ // The resulting string contains the name and group name pairs of all |
+ // registered FieldTrials which have not been disabled, with "/" used |
+ // to separate all names and to terminate the string. All activated trials |
+ // have their name prefixed with "*". This string is parsed by |
+ // |CreateTrialsFromString()|. |
+ static void AllStatesToString(std::string* output); |
+ |
// Fills in the supplied vector |active_groups| (which must be empty when |
// called) with a snapshot of all registered FieldTrials for which the group |
// has been chosen and externally observed (via |group()|) and which have |