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

Unified Diff: base/metrics/field_trial.h

Issue 700953002: Send all field trials from the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@finch4
Patch Set: Responded to comments. Created 5 years, 11 months 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 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
« 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