| Index: base/metrics/field_trial.h
|
| diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h
|
| index e2e543947a10a97595b828c63a432c7710aaab79..85225775962829f3184d07bf3d4714f70a84335a 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 FieldTrialState {
|
| + std::string trial_name;
|
| + std::string group_name;
|
| + bool activated;
|
| + };
|
| +
|
| typedef std::vector<ActiveGroup> ActiveGroups;
|
| + typedef std::vector<FieldTrialState> 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 |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 GetlState(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
|
| @@ -450,6 +477,11 @@ class BASE_EXPORT FieldTrialList {
|
| static size_t GetFieldTrialCount();
|
|
|
| private:
|
| + // 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(
|
| + FieldTrial::AllGroups* all_groups);
|
| +
|
| // A map from FieldTrial names to the actual instances.
|
| typedef std::map<std::string, FieldTrial*> RegistrationMap;
|
|
|
|
|