Index: base/metrics/field_trial.h |
diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h |
index e2e543947a10a97595b828c63a432c7710aaab79..bd125a28e952482358d4b7ec18a94b54d363a47e 100644 |
--- a/base/metrics/field_trial.h |
+++ b/base/metrics/field_trial.h |
@@ -106,7 +106,16 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> { |
std::string group_name; |
}; |
+ // A triplet representing a Field Trial, its selected group and whether it's |
+ // active. |
+ struct AllGroup { |
Alexei Svitkine (slow)
2014/11/05 16:17:13
AllGroup is a weird name.
How about FieldTrialSta
|
+ std::string trial_name; |
+ std::string group_name; |
+ bool activated; |
+ }; |
+ |
typedef std::vector<ActiveGroup> ActiveGroups; |
+ typedef std::vector<AllGroup> AllGroups; |
// A return value to indicate that a given instance has not yet had a group |
// assignment (and hence is not yet participating in the trial). |
@@ -180,6 +189,7 @@ 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, DuplicateRestore); |
@@ -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 |all_group|, but only if the trial |
+ // has not been disabled. In that case, true is returned and |all_group| |
+ // is filled in; otherwise, the result is false and |all_group| is left |
+ // untouched. |
+ bool GetAllGroup(AllGroup* all_group) 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 |
@@ -411,6 +438,11 @@ class BASE_EXPORT FieldTrialList { |
static void GetActiveFieldTrialGroups( |
FieldTrial::ActiveGroups* active_groups); |
+ // Fills in the supplied vector |all_groups| (which must be empty when called) |
+ // with a snapshot of all registered FieldTrials which have not been disabled. |
+ static void GetAllFieldTrialGroups( |
Alexei Svitkine (slow)
2014/11/05 16:17:14
Does this need to be public?
Georges Khalil
2014/11/05 20:00:12
No, moved it to private.
|
+ FieldTrial::AllGroups* all_groups); |
+ |
// Use a state string (re: StatesToString()) to augment the current list of |
// field trials to include the supplied trials, and using a 100% probability |
// for each trial, force them to have the same group string. This is commonly |