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

Unified Diff: base/metrics/field_trial.h

Issue 9117037: Added a Unique ID for a Field Trial containing it's hashed name and the selected group ID. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 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') | base/metrics/field_trial.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/field_trial.h
===================================================================
--- base/metrics/field_trial.h (revision 118842)
+++ base/metrics/field_trial.h (working copy)
@@ -92,6 +92,12 @@
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{
Alexei Svitkine (slow) 2012/01/25 15:25:19 Nit: Add a space before {.
MAD 2012/01/25 17:02:33 Done.
+ uint32 name;
+ uint32 group;
+ };
// 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).
@@ -101,6 +107,9 @@
// to assign all the remaining probability to a group ('default').
static const int kDefaultGroupNumber;
+ // This value is reserved for an uninitialized hash value.
+ static const uint32 kReservedHashValue;
+
// The name is used to register the instance with the FieldTrialList class,
// and can be used to find the trial (only one trial can be present for each
// name). |name| and |default_group_name| may not be empty.
@@ -148,6 +157,10 @@
// number is used as the group name.
std::string group_name();
+ // Gets the unique identifier of the Field Trial, but only if a winner was
+ // elected. Returns true if a winner is returned, false otherwise.
Alexei Svitkine (slow) 2012/01/25 15:25:19 Can you reword this to either explain what you mea
MAD 2012/01/25 17:02:33 Done.
+ bool GetNameGroupId(NameGroupId* name_group_id);
+
// Return the default group name of the FieldTrial.
std::string default_group_name() const { return default_group_name_; }
@@ -174,6 +187,7 @@
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, HashClientId);
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, HashClientIdIsUniform);
FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, UseOneTimeRandomization);
+ FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, NameGroupIds);
friend class base::FieldTrialList;
@@ -190,9 +204,15 @@
static double HashClientId(const std::string& client_id,
const std::string& trial_name);
+ // Creates unique identifier for the trial by hashing the name string.
Alexei Svitkine (slow) 2012/01/25 15:25:19 The comment should probably mention that this hash
MAD 2012/01/25 17:02:33 Done.
+ 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_;
@@ -218,6 +238,10 @@
// 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_;
@@ -285,11 +309,15 @@
// Create a persistent representation of all FieldTrial instances and the
// |client_id()| state for resurrection in another process. This allows
- // randomization to be done in one process, and secondary processes can by
+ // randomization to be done in one process, and secondary processes can be
// synchronized on the result. The resulting string contains the
// |client_id()|, the names, the trial name, and a "/" separator.
static void StatesToString(std::string* output);
+ // Returns an array of Unique IDs for each currently running Field Trials.
Alexei Svitkine (slow) 2012/01/25 15:25:19 Can you expand this comment to explain what "curre
MAD 2012/01/25 17:02:33 Done.
+ static void GetFieldTrialNameGroupIds(
+ std::vector<FieldTrial::NameGroupId>* name_group_ids);
+
// Use a previously generated state string (re: StatesToString()) augment the
// current list of field tests to include the supplied tests, and using a 100%
// probability for each test, force them to have the same group string. This
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | base/metrics/field_trial.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698