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

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, first element is a hashed value of the name
+ // and the second one is the group identifier.
+ struct NameGroupId{
+ 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).
@@ -148,6 +154,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.
+ 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 +184,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 +201,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.
+ 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 +235,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.
jar (doing other things) 2012/01/24 21:51:23 Since you don't have synchronization, you need to
MAD 2012/01/25 00:14:48 Done.
+ uint32 group_name_hash_;
+
// When enable_field_trial_ is false, field trial reverts to the 'default'
// group.
bool enable_field_trial_;
@@ -285,11 +306,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.
+ 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