| 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 10 matching lines...) Expand all Loading... |
| 21 const chrome_variations::VariationID trial_base_id, | 21 const chrome_variations::VariationID trial_base_id, |
| 22 int num_trial_groups) { | 22 int num_trial_groups) { |
| 23 // Probability per group remains constant for all uniformity trials, what | 23 // Probability per group remains constant for all uniformity trials, what |
| 24 // changes is the probability divisor. | 24 // changes is the probability divisor. |
| 25 static const base::FieldTrial::Probability kProbabilityPerGroup = 1; | 25 static const base::FieldTrial::Probability kProbabilityPerGroup = 1; |
| 26 const std::string kDefaultGroupName = "default"; | 26 const std::string kDefaultGroupName = "default"; |
| 27 const base::FieldTrial::Probability divisor = num_trial_groups; | 27 const base::FieldTrial::Probability divisor = num_trial_groups; |
| 28 | 28 |
| 29 DCHECK_EQ(100 % num_trial_groups, 0); | 29 DCHECK_EQ(100 % num_trial_groups, 0); |
| 30 const int group_percent = 100 / num_trial_groups; | 30 const int group_percent = 100 / num_trial_groups; |
| 31 const std::string trial_name = StringPrintf(trial_name_string.c_str(), | 31 const std::string trial_name = base::StringPrintf(trial_name_string.c_str(), |
| 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, | 42 chrome_variations::GOOGLE_WEB_PROPERTIES, trial_name, kDefaultGroupName, |
| 43 trial_base_id); | 43 trial_base_id); |
| 44 chrome_variations::AssociateGoogleVariationID( | 44 chrome_variations::AssociateGoogleVariationID( |
| 45 chrome_variations::GOOGLE_UPDATE_SERVICE, trial_name, kDefaultGroupName, | 45 chrome_variations::GOOGLE_UPDATE_SERVICE, trial_name, kDefaultGroupName, |
| 46 trial_base_id); | 46 trial_base_id); |
| 47 | 47 |
| 48 // Loop starts with group 1 because the field trial automatically creates a | 48 // Loop starts with group 1 because the field trial automatically creates a |
| 49 // default group, which would be group 0. | 49 // default group, which would be group 0. |
| 50 for (int group_number = 1; group_number < num_trial_groups; ++group_number) { | 50 for (int group_number = 1; group_number < num_trial_groups; ++group_number) { |
| 51 const std::string group_name = StringPrintf("group_%02d", group_number); | 51 const std::string group_name = |
| 52 base::StringPrintf("group_%02d", group_number); |
| 52 DVLOG(1) << " Group name = " << group_name; | 53 DVLOG(1) << " Group name = " << group_name; |
| 53 trial->AppendGroup(group_name, kProbabilityPerGroup); | 54 trial->AppendGroup(group_name, kProbabilityPerGroup); |
| 54 chrome_variations::AssociateGoogleVariationID( | 55 chrome_variations::AssociateGoogleVariationID( |
| 55 chrome_variations::GOOGLE_WEB_PROPERTIES, trial_name, group_name, | 56 chrome_variations::GOOGLE_WEB_PROPERTIES, trial_name, group_name, |
| 56 static_cast<chrome_variations::VariationID>(trial_base_id + | 57 static_cast<chrome_variations::VariationID>(trial_base_id + |
| 57 group_number)); | 58 group_number)); |
| 58 chrome_variations::AssociateGoogleVariationID( | 59 chrome_variations::AssociateGoogleVariationID( |
| 59 chrome_variations::GOOGLE_UPDATE_SERVICE, trial_name, group_name, | 60 chrome_variations::GOOGLE_UPDATE_SERVICE, trial_name, group_name, |
| 60 static_cast<chrome_variations::VariationID>(trial_base_id + | 61 static_cast<chrome_variations::VariationID>(trial_base_id + |
| 61 group_number)); | 62 group_number)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // Setup a 5% session-randomized uniformity trial. | 121 // Setup a 5% session-randomized uniformity trial. |
| 121 const std::string kSessionRandomizedTrialName = | 122 const std::string kSessionRandomizedTrialName = |
| 122 "UMA-Session-Randomized-Uniformity-Trial-%d-Percent"; | 123 "UMA-Session-Randomized-Uniformity-Trial-%d-Percent"; |
| 123 SetupSingleUniformityFieldTrial(false, kSessionRandomizedTrialName, | 124 SetupSingleUniformityFieldTrial(false, kSessionRandomizedTrialName, |
| 124 chrome_variations::UNIFORMITY_SESSION_RANDOMIZED_5_PERCENT_BASE, 20); | 125 chrome_variations::UNIFORMITY_SESSION_RANDOMIZED_5_PERCENT_BASE, 20); |
| 125 | 126 |
| 126 SetupNewInstallUniformityTrial(install_date); | 127 SetupNewInstallUniformityTrial(install_date); |
| 127 } | 128 } |
| 128 | 129 |
| 129 } // namespace chrome_variations | 130 } // namespace chrome_variations |
| OLD | NEW |