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

Unified Diff: base/metrics/field_trial.h

Issue 10151017: Remove the hash fields from FieldTrials. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: MAD comments. Reshuffled test methods. Created 8 years, 8 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') | chrome/common/metrics/experiments_helper.h » ('J')
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 be58a9367f0ab258dbfe6100438617bd759bdffd..78db19fc4fad8cec1c83665219220a529318cbed 100644
--- a/base/metrics/field_trial.h
+++ b/base/metrics/field_trial.h
@@ -92,13 +92,15 @@ class FieldTrialList;
class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
public:
typedef int Probability; // Probability type for being selected in a trial.
- // The Unique ID of a trial, where the name and group identifiers are
- // hashes of the trial and group name strings.
- struct NameGroupId {
- uint32 name;
- uint32 group;
+
+ // A pair representing a Field Trial and its selected group.
+ struct SelectedGroup {
+ std::string trial;
+ std::string group;
};
+ typedef std::vector<SelectedGroup> SelectedGroups;
+
// 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).
static const int kNotFinalized;
@@ -135,21 +137,17 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
// is used as the group name. This causes a winner to be chosen if none was.
std::string group_name();
- // Gets the unique identifier of the Field Trial, but only if a group was
+ // Gets the SelectedGroup of the Field Trial, but only if a group was
// officially chosen, otherwise name_group_id is left untouched and false
- // is returned. When true is returned, the name and group ids were
- // successfully set in name_group_id.
- bool GetNameGroupId(NameGroupId* name_group_id);
+ // is returned. When true is returned, the trial and group names were
+ // successfully set in selected_group.
+ bool GetSelectedGroup(SelectedGroup* selected_group);
// Helper function for the most common use: as an argument to specify the
// name of a HISTOGRAM. Use the original histogram name as the name_prefix.
static std::string MakeName(const std::string& name_prefix,
const std::string& trial_name);
- // Helper function to create a NameGroupId from |trial_name| and |group_name|.
- static NameGroupId MakeNameGroupId(const std::string& trial_name,
- const std::string& group_name);
-
// Enable benchmarking sets field trials to a common setting.
static void EnableBenchmarking();
@@ -167,7 +165,6 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, MakeName);
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, HashClientId);
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, HashClientIdIsUniform);
- FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, HashName);
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, NameGroupIds);
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, UseOneTimeRandomization);
@@ -200,16 +197,9 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
static double HashClientId(const std::string& client_id,
const std::string& trial_name);
- // Creates unique identifier for the trial by hashing a name string, whether
- // it's for the field trial or the group name.
- static uint32 HashName(const std::string& name);
-
// The name of the field trial, as can be found via the FieldTrialList.
const std::string name_;
- // The hashed name of the field trial to be sent as a unique identifier.
- const uint32 name_hash_;
-
// The maximum sum of all probabilities supplied, which corresponds to 100%.
// This is the scaling factor used to adjust supplied probabilities.
const Probability divisor_;
@@ -235,10 +225,6 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
// has been called.
std::string group_name_;
- // The hashed name of the group to be sent as a unique identifier.
- // Is not valid while group_ is equal to kNotFinalized.
- uint32 group_name_hash_;
-
// When enable_field_trial_ is false, field trial reverts to the 'default'
// group.
bool enable_field_trial_;
@@ -251,9 +237,6 @@ class BASE_EXPORT FieldTrial : public RefCounted<FieldTrial> {
// group.
static bool enable_benchmarking_;
- // This value is reserved for an uninitialized hash value.
- static const uint32 kReservedHashValue;
-
DISALLOW_COPY_AND_ASSIGN(FieldTrial);
};
@@ -343,11 +326,11 @@ class BASE_EXPORT FieldTrialList {
// string is parsed by CreateTrialsFromString().
static void StatesToString(std::string* output);
- // Returns an array of Unique IDs for each Field Trial that has a chosen
- // group. Field Trials for which a group has not been chosen yet are NOT
+ // Returns an array of SelectedGroup objects, each representing a chosen Field
jar (doing other things) 2012/04/26 22:24:22 nit: (even in pre-existing comentary): It doesn't
SteveT 2012/04/26 23:42:47 Very true. Done.
+ // Trial group. Field Trials for which a group has not been chosen yet are NOT
// returned in this list.
- static void GetFieldTrialNameGroupIds(
- std::vector<FieldTrial::NameGroupId>* name_group_ids);
+ static void GetFieldTrialSelectedGroups(
+ FieldTrial::SelectedGroups* selected_groups);
// Use a state string (re: StatesToString()) to augment the current list of
// field tests to include the supplied tests, and using a 100% probability for
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | chrome/common/metrics/experiments_helper.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698