OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/metrics/variations/uniformity_field_trials.h" | 5 #include "chrome/common/metrics/variations/uniformity_field_trials.h" |
6 | 6 |
7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/common/metrics/variations/variations_util.h" | 10 #include "chrome/common/metrics/variations/variations_util.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 group_percent); | 32 group_percent); |
33 | 33 |
34 DVLOG(1) << "Trial name = " << trial_name; | 34 DVLOG(1) << "Trial name = " << trial_name; |
35 | 35 |
36 scoped_refptr<base::FieldTrial> trial( | 36 scoped_refptr<base::FieldTrial> trial( |
37 base::FieldTrialList::FactoryGetFieldTrial( | 37 base::FieldTrialList::FactoryGetFieldTrial( |
38 trial_name, divisor, kDefaultGroupName, 2015, 1, 1, NULL)); | 38 trial_name, divisor, kDefaultGroupName, 2015, 1, 1, NULL)); |
39 if (one_time_randomized) | 39 if (one_time_randomized) |
40 trial->UseOneTimeRandomization(); | 40 trial->UseOneTimeRandomization(); |
41 chrome_variations::AssociateGoogleVariationID( | 41 chrome_variations::AssociateGoogleVariationID( |
42 chrome_variations::GOOGLE_WEB_PROPERTIES, trial_name, kDefaultGroupName, | |
43 trial_base_id); | |
44 chrome_variations::AssociateGoogleVariationID( | |
45 chrome_variations::GOOGLE_UPDATE_SERVICE, trial_name, kDefaultGroupName, | 42 chrome_variations::GOOGLE_UPDATE_SERVICE, trial_name, kDefaultGroupName, |
46 trial_base_id); | 43 trial_base_id); |
47 | 44 |
48 // Loop starts with group 1 because the field trial automatically creates a | 45 // Loop starts with group 1 because the field trial automatically creates a |
49 // default group, which would be group 0. | 46 // default group, which would be group 0. |
50 for (int group_number = 1; group_number < num_trial_groups; ++group_number) { | 47 for (int group_number = 1; group_number < num_trial_groups; ++group_number) { |
51 const std::string group_name = | 48 const std::string group_name = |
52 base::StringPrintf("group_%02d", group_number); | 49 base::StringPrintf("group_%02d", group_number); |
53 DVLOG(1) << " Group name = " << group_name; | 50 DVLOG(1) << " Group name = " << group_name; |
54 trial->AppendGroup(group_name, kProbabilityPerGroup); | 51 trial->AppendGroup(group_name, kProbabilityPerGroup); |
55 chrome_variations::AssociateGoogleVariationID( | 52 chrome_variations::AssociateGoogleVariationID( |
56 chrome_variations::GOOGLE_WEB_PROPERTIES, trial_name, group_name, | |
57 static_cast<chrome_variations::VariationID>(trial_base_id + | |
58 group_number)); | |
59 chrome_variations::AssociateGoogleVariationID( | |
60 chrome_variations::GOOGLE_UPDATE_SERVICE, trial_name, group_name, | 53 chrome_variations::GOOGLE_UPDATE_SERVICE, trial_name, group_name, |
61 static_cast<chrome_variations::VariationID>(trial_base_id + | 54 static_cast<chrome_variations::VariationID>(trial_base_id + |
62 group_number)); | 55 group_number)); |
63 } | 56 } |
64 | 57 |
65 // Now that all groups have been appended, call group() on the trial to | 58 // Now that all groups have been appended, call group() on the trial to |
66 // ensure that our trial is registered. This resolves an off-by-one issue | 59 // ensure that our trial is registered. This resolves an off-by-one issue |
67 // where the default group never gets chosen if we don't "use" the trial. | 60 // where the default group never gets chosen if we don't "use" the trial. |
68 const int chosen_group = trial->group(); | 61 const int chosen_group = trial->group(); |
69 DVLOG(1) << "Chosen Group: " << chosen_group; | 62 DVLOG(1) << "Chosen Group: " << chosen_group; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Setup a 5% session-randomized uniformity trial. | 114 // Setup a 5% session-randomized uniformity trial. |
122 const std::string kSessionRandomizedTrialName = | 115 const std::string kSessionRandomizedTrialName = |
123 "UMA-Session-Randomized-Uniformity-Trial-%d-Percent"; | 116 "UMA-Session-Randomized-Uniformity-Trial-%d-Percent"; |
124 SetupSingleUniformityFieldTrial(false, kSessionRandomizedTrialName, | 117 SetupSingleUniformityFieldTrial(false, kSessionRandomizedTrialName, |
125 chrome_variations::UNIFORMITY_SESSION_RANDOMIZED_5_PERCENT_BASE, 20); | 118 chrome_variations::UNIFORMITY_SESSION_RANDOMIZED_5_PERCENT_BASE, 20); |
126 | 119 |
127 SetupNewInstallUniformityTrial(install_date); | 120 SetupNewInstallUniformityTrial(install_date); |
128 } | 121 } |
129 | 122 |
130 } // namespace chrome_variations | 123 } // namespace chrome_variations |
OLD | NEW |