Index: base/metrics/field_trial.h |
=================================================================== |
--- base/metrics/field_trial.h (revision 71223) |
+++ base/metrics/field_trial.h (working copy) |
@@ -66,6 +66,7 @@ |
#include <map> |
#include <string> |
+#include "base/gtest_prod_util.h" |
#include "base/lock.h" |
#include "base/ref_counted.h" |
#include "base/time.h" |
@@ -78,21 +79,22 @@ |
// 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 kNotParticipating; |
+ static const int kNotFinalized; |
- // Provide an easy way to assign all remaining probability to a group. Note |
- // that this will force an instance to participate, and make it illegal to |
- // attempt to probabalistically add any other groups to the trial. When doing |
- // A/B tests with timings, it is often best to define all groups, so that |
- // histograms will get unique names via the MakeName() methods. |
- static const Probability kAllRemainingProbability; |
+ // This is the group number of the 'default' group. This provides an easy way |
+ // to assign all the remaining probability to a group ('default'). |
+ static const int kDefaultGroupNumber; |
// 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). |
// Group probabilities that are later supplied must sum to less than or equal |
- // to the total_probability. |
- FieldTrial(const std::string& name, Probability total_probability); |
+ // to the total_probability. Arguments year, month and day_of_month specify |
+ // the expiration time. If the build time is after the expiration time then |
+ // the field trial reverts to the 'default' group. |
+ FieldTrial(const std::string& name, Probability total_probability, |
+ const std::string& default_group_name, const int year, |
+ const int month, const int day_of_month); |
// Establish the name and probability of the next group in this trial. |
// Sometimes, based on construction randomization, this call may causes the |
@@ -103,9 +105,12 @@ |
std::string name() const { return name_; } |
// Return the randomly selected group number that was assigned. |
- // Return kNotParticipating if the instance is not participating in the |
- // experiment. |
- int group() const { return group_; } |
+ // Return kDefaultGroupNumber if the instance is in the 'default' group. |
+ // Note that this will force an instance to participate, and make it illegal |
+ // to attempt to probabalistically add any other groups to the trial. When |
+ // doing A/B tests with timings, it is often best to define all groups, so |
+ // that histograms will get unique names via the MakeName() methods. |
jar (doing other things)
2011/01/15 20:52:47
Comment looks great up to the last sentence.
The
|
+ int group(); |
// If the field trial is not in an experiment, this returns the empty string. |
// if the group's name is empty, a name of "_" concatenated with the group |
@@ -121,10 +126,25 @@ |
static void EnableBenchmarking(); |
private: |
+ // Allow tests to access our innards for testing purposes. |
+ FRIEND_TEST(FieldTrialTest, Registration); |
+ FRIEND_TEST(FieldTrialTest, AbsoluteProbabilities); |
+ FRIEND_TEST(FieldTrialTest, RemainingProbability); |
+ FRIEND_TEST(FieldTrialTest, FiftyFiftyProbability); |
+ FRIEND_TEST(FieldTrialTest, MiddleProbabilities); |
+ FRIEND_TEST(FieldTrialTest, OneWinner); |
+ FRIEND_TEST(FieldTrialTest, DisableProbability); |
+ FRIEND_TEST(FieldTrialTest, Save); |
+ FRIEND_TEST(FieldTrialTest, DuplicateRestore); |
+ FRIEND_TEST(FieldTrialTest, MakeName); |
+ |
friend class RefCounted<FieldTrial>; |
virtual ~FieldTrial(); |
+ // Get build time. |
+ static Time GetBuildTime(); |
+ |
// The name of the field trial, as can be found via the FieldTrialList. |
// This is empty of the trial is not in the experiment. |
const std::string name_; |
@@ -133,6 +153,9 @@ |
// This is the scaling factor used to adjust supplied probabilities. |
Probability divisor_; |
+ // The name of the default group. |
+ const std::string default_group_name_; |
+ |
// The randomly selected probability that is used to select a group (or have |
// the instance not participate). It is the product of divisor_ and a random |
// number between [0, 1). |
@@ -144,15 +167,26 @@ |
int next_group_number_; |
// The pseudo-randomly assigned group number. |
- // This is kNotParticipating if no group has been assigned. |
+ // This is kNotFinalized if no group has been assigned. |
int group_; |
// A textual name for the randomly selected group, including the Trial name. |
// If this Trial is not a member of an group, this string is empty. |
std::string group_name_; |
+ // The expiration_year_, expiration_month_ and expiration_day_of_month_ are |
+ // used to compute expiration time. If expiration time is after the build time |
+ // of the module, then field trial reverts to the 'default' group. |
+ int expiration_year_; |
+ int expiration_month_; |
+ int expiration_day_of_month_; |
+ |
+ // When disable_field_trial_ is true, field trial reverts to the 'default' |
+ // group. |
+ bool disable_field_trial_; |
+ |
// When benchmarking is enabled, field trials all revert to the 'default' |
- // bucket. |
+ // group. |
static bool enable_benchmarking_; |
DISALLOW_COPY_AND_ASSIGN(FieldTrial); |