OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/autocomplete/autocomplete_field_trial.h" | 5 #include "chrome/browser/autocomplete/autocomplete_field_trial.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "chrome/common/metrics/experiments_helper.h" | 11 #include "chrome/common/metrics/variations_util.h" |
12 #include "chrome/common/metrics/variation_ids.h" | 12 #include "chrome/common/metrics/variation_ids.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Field trial names. | 16 // Field trial names. |
17 static const char kDisallowInlineHQPFieldTrialName[] = | 17 static const char kDisallowInlineHQPFieldTrialName[] = |
18 "OmniboxDisallowInlineHQP"; | 18 "OmniboxDisallowInlineHQP"; |
19 static const char kSuggestFieldTrialName[] = "OmniboxSearchSuggest"; | 19 static const char kSuggestFieldTrialName[] = "OmniboxSearchSuggest"; |
20 static const char kHQPNewScoringFieldTrialName[] = "OmniboxHQPNewScoring"; | 20 static const char kHQPNewScoringFieldTrialName[] = "OmniboxHQPNewScoring"; |
21 | 21 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // make it sticky if possible). | 77 // make it sticky if possible). |
78 // Make it expire on October 1, 2012. | 78 // Make it expire on October 1, 2012. |
79 scoped_refptr<base::FieldTrial> trial( | 79 scoped_refptr<base::FieldTrial> trial( |
80 base::FieldTrialList::FactoryGetFieldTrial( | 80 base::FieldTrialList::FactoryGetFieldTrial( |
81 kSuggestFieldTrialName, kSuggestFieldTrialNumberOfGroups, | 81 kSuggestFieldTrialName, kSuggestFieldTrialNumberOfGroups, |
82 "0", 2012, 10, 1, NULL)); | 82 "0", 2012, 10, 1, NULL)); |
83 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) | 83 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) |
84 trial->UseOneTimeRandomization(); | 84 trial->UseOneTimeRandomization(); |
85 | 85 |
86 // Mark this group in suggest requests to Google. | 86 // Mark this group in suggest requests to Google. |
87 experiments_helper::AssociateGoogleVariationID( | 87 chrome_variations::AssociateGoogleVariationID( |
88 kSuggestFieldTrialName, "0", chrome_variations::kSuggestIDMin); | 88 kSuggestFieldTrialName, "0", chrome_variations::kSuggestIDMin); |
89 DCHECK_EQ(kSuggestFieldTrialNumberOfGroups, | 89 DCHECK_EQ(kSuggestFieldTrialNumberOfGroups, |
90 chrome_variations::kSuggestIDMax - chrome_variations::kSuggestIDMin + 1); | 90 chrome_variations::kSuggestIDMax - chrome_variations::kSuggestIDMin + 1); |
91 | 91 |
92 // We've already created one group; now just need to create | 92 // We've already created one group; now just need to create |
93 // kSuggestFieldTrialNumGroups - 1 more. Mark these groups in | 93 // kSuggestFieldTrialNumGroups - 1 more. Mark these groups in |
94 // suggest requests to Google. | 94 // suggest requests to Google. |
95 for (int i = 1; i < kSuggestFieldTrialNumberOfGroups; i++) { | 95 for (int i = 1; i < kSuggestFieldTrialNumberOfGroups; i++) { |
96 const std::string group_name = base::IntToString(i); | 96 const std::string group_name = base::IntToString(i); |
97 trial->AppendGroup(group_name, 1); | 97 trial->AppendGroup(group_name, 1); |
98 experiments_helper::AssociateGoogleVariationID( | 98 chrome_variations::AssociateGoogleVariationID( |
99 kSuggestFieldTrialName, group_name, | 99 kSuggestFieldTrialName, group_name, |
100 static_cast<chrome_variations::VariationID>( | 100 static_cast<chrome_variations::VariationID>( |
101 chrome_variations::kSuggestIDMin + i)); | 101 chrome_variations::kSuggestIDMin + i)); |
102 } | 102 } |
103 | 103 |
104 // Create inline History Quick Provider new scoring field trial. | 104 // Create inline History Quick Provider new scoring field trial. |
105 // Make it expire on January 14, 2013. | 105 // Make it expire on January 14, 2013. |
106 trial = base::FieldTrialList::FactoryGetFieldTrial( | 106 trial = base::FieldTrialList::FactoryGetFieldTrial( |
107 kHQPNewScoringFieldTrialName, kHQPNewScoringFieldTrialDivisor, | 107 kHQPNewScoringFieldTrialName, kHQPNewScoringFieldTrialDivisor, |
108 "Standard", 2013, 1, 14, NULL); | 108 "Standard", 2013, 1, 14, NULL); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 bool AutocompleteFieldTrial::InHQPNewScoringFieldTrialExperimentGroup() { | 158 bool AutocompleteFieldTrial::InHQPNewScoringFieldTrialExperimentGroup() { |
159 if (!InHQPNewScoringFieldTrial()) | 159 if (!InHQPNewScoringFieldTrial()) |
160 return false; | 160 return false; |
161 | 161 |
162 // Return true if we're in the experiment group. | 162 // Return true if we're in the experiment group. |
163 const int group = base::FieldTrialList::FindValue( | 163 const int group = base::FieldTrialList::FindValue( |
164 kHQPNewScoringFieldTrialName); | 164 kHQPNewScoringFieldTrialName); |
165 return group == hqp_new_scoring_experiment_group; | 165 return group == hqp_new_scoring_experiment_group; |
166 } | 166 } |
OLD | NEW |