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/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 // Field trial names. | 15 // Field trial names. |
16 static const char kAggressiveHUPFieldTrialName[] = | |
17 "OmniboxAggressiveHistoryURLProvider"; | |
18 static const char kDisallowInlineHQPFieldTrialName[] = | 16 static const char kDisallowInlineHQPFieldTrialName[] = |
19 "OmniboxDisallowInlineHQP"; | 17 "OmniboxDisallowInlineHQP"; |
20 static const char kSuggestFieldTrialName[] = "OmniboxSearchSuggest"; | 18 static const char kSuggestFieldTrialName[] = "OmniboxSearchSuggest"; |
21 | 19 |
22 // Field trial experiment probabilities. | 20 // Field trial experiment probabilities. |
23 | 21 |
24 // For aggressive History URL Provider field trial, put 50% ( = 50/100 ) | |
25 // of the users in the aggressive experiment group. | |
26 const base::FieldTrial::Probability kAggressiveHUPFieldTrialDivisor = 100; | |
27 const base::FieldTrial::Probability | |
28 kAggressiveHUPFieldTrialExperimentFraction = 50; | |
29 | |
30 // For inline History Quick Provider field trial, put 10% ( = 10/100 ) | 22 // For inline History Quick Provider field trial, put 10% ( = 10/100 ) |
31 // of the users in the disallow-inline experiment group. | 23 // of the users in the disallow-inline experiment group. |
32 const base::FieldTrial::Probability kDisallowInlineHQPFieldTrialDivisor = 100; | 24 const base::FieldTrial::Probability kDisallowInlineHQPFieldTrialDivisor = 100; |
33 const base::FieldTrial::Probability | 25 const base::FieldTrial::Probability |
34 kDisallowInlineHQPFieldTrialExperimentFraction = 10; | 26 kDisallowInlineHQPFieldTrialExperimentFraction = 10; |
35 | 27 |
36 // For the search suggestion field trial, divide the people in the | 28 // For the search suggestion field trial, divide the people in the |
37 // trial into 20 equally-sized buckets. The suggest provider backend | 29 // trial into 20 equally-sized buckets. The suggest provider backend |
38 // will decide what behavior (if any) to change based on the group. | 30 // will decide what behavior (if any) to change based on the group. |
39 const int kSuggestFieldTrialNumberOfGroups = 20; | 31 const int kSuggestFieldTrialNumberOfGroups = 20; |
40 | 32 |
41 // Field trial IDs. | 33 // Field trial IDs. |
42 // Though they are not literally "const", they are set only once, in | 34 // Though they are not literally "const", they are set only once, in |
43 // Activate() below. | 35 // Activate() below. |
44 | 36 |
45 // Field trial ID for the aggressive History URL Provider experiment group. | |
46 int aggressive_hup_experiment_group = 0; | |
47 | |
48 // Field trial ID for the disallow-inline History Quick Provider | 37 // Field trial ID for the disallow-inline History Quick Provider |
49 // experiment group. | 38 // experiment group. |
50 int disallow_inline_hqp_experiment_group = 0; | 39 int disallow_inline_hqp_experiment_group = 0; |
51 | 40 |
52 } | 41 } |
53 | 42 |
54 | 43 |
55 void AutocompleteFieldTrial::Activate() { | 44 void AutocompleteFieldTrial::Activate() { |
56 // Because users tend to use omnibox without attention to it--habits | 45 // Because users tend to use omnibox without attention to it--habits |
57 // get ingrained, users tend to learn that a particular suggestion is | 46 // get ingrained, users tend to learn that a particular suggestion is |
58 // at a particular spot in the drop-down--we're going to make these | 47 // at a particular spot in the drop-down--we're going to make these |
59 // field trials sticky. We want users to stay in them once assigned | 48 // field trials sticky. We want users to stay in them once assigned |
60 // so they have a better experience and also so we don't get weird | 49 // so they have a better experience and also so we don't get weird |
61 // effects as omnibox ranking keeps changing and users learn they can't | 50 // effects as omnibox ranking keeps changing and users learn they can't |
62 // trust the omnibox. Hence, to create the field trials we require | 51 // trust the omnibox. Hence, to create the field trials we require |
63 // that field trials can be made sticky. | 52 // that field trials can be made sticky. |
64 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) { // sticky trials | 53 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) { // sticky trials |
65 // Create aggressive History URL Provider field trial. | 54 // Create inline History Quick Provider field trial. |
66 // Make it expire on August 1, 2012. | 55 // Make it expire on November 8, 2012. |
67 scoped_refptr<base::FieldTrial> trial( | 56 scoped_refptr<base::FieldTrial> trial( |
68 base::FieldTrialList::FactoryGetFieldTrial( | 57 base::FieldTrialList::FactoryGetFieldTrial( |
69 kAggressiveHUPFieldTrialName, kAggressiveHUPFieldTrialDivisor, | |
70 "Standard", 2012, 8, 1, NULL)); | |
71 trial->UseOneTimeRandomization(); | |
72 aggressive_hup_experiment_group = trial->AppendGroup("Aggressive", | |
73 kAggressiveHUPFieldTrialExperimentFraction); | |
74 | |
75 // Create inline History Quick Provider field trial. | |
76 // Make it expire on November 8, 2012. | |
77 trial = base::FieldTrialList::FactoryGetFieldTrial( | |
78 kDisallowInlineHQPFieldTrialName, kDisallowInlineHQPFieldTrialDivisor, | 58 kDisallowInlineHQPFieldTrialName, kDisallowInlineHQPFieldTrialDivisor, |
79 "Standard", 2012, 11, 8, NULL); | 59 "Standard", 2012, 11, 8, NULL)); |
80 trial->UseOneTimeRandomization(); | 60 trial->UseOneTimeRandomization(); |
81 disallow_inline_hqp_experiment_group = trial->AppendGroup("DisallowInline", | 61 disallow_inline_hqp_experiment_group = trial->AppendGroup("DisallowInline", |
82 kDisallowInlineHQPFieldTrialExperimentFraction); | 62 kDisallowInlineHQPFieldTrialExperimentFraction); |
83 } | 63 } |
84 | 64 |
85 // Create the suggest field trial (regardless of sticky-ness status, but | 65 // Create the suggest field trial (regardless of sticky-ness status, but |
86 // make it sticky if possible). | 66 // make it sticky if possible). |
87 // Make it expire on October 1, 2012. | 67 // Make it expire on October 1, 2012. |
88 scoped_refptr<base::FieldTrial> trial( | 68 scoped_refptr<base::FieldTrial> trial( |
89 base::FieldTrialList::FactoryGetFieldTrial( | 69 base::FieldTrialList::FactoryGetFieldTrial( |
90 kSuggestFieldTrialName, kSuggestFieldTrialNumberOfGroups, | 70 kSuggestFieldTrialName, kSuggestFieldTrialNumberOfGroups, |
91 "0", 2012, 10, 1, NULL)); | 71 "0", 2012, 10, 1, NULL)); |
92 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) | 72 if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) |
93 trial->UseOneTimeRandomization(); | 73 trial->UseOneTimeRandomization(); |
94 // We've already created one group; now just need to create | 74 // We've already created one group; now just need to create |
95 // kSuggestFieldTrialNumGroups - 1 more. | 75 // kSuggestFieldTrialNumGroups - 1 more. |
96 for (int i = 1; i < kSuggestFieldTrialNumberOfGroups; i++) | 76 for (int i = 1; i < kSuggestFieldTrialNumberOfGroups; i++) |
97 trial->AppendGroup(base::StringPrintf("%d", i), 1); | 77 trial->AppendGroup(base::StringPrintf("%d", i), 1); |
98 } | 78 } |
99 | 79 |
100 bool AutocompleteFieldTrial::InAggressiveHUPFieldTrial() { | |
101 return base::FieldTrialList::TrialExists(kAggressiveHUPFieldTrialName); | |
102 } | |
103 | |
104 bool AutocompleteFieldTrial::InAggressiveHUPFieldTrialExperimentGroup() { | |
105 if (!base::FieldTrialList::TrialExists(kAggressiveHUPFieldTrialName)) | |
106 return false; | |
107 | |
108 // Return true if we're in the aggressive experiment group. | |
109 const int group = base::FieldTrialList::FindValue( | |
110 kAggressiveHUPFieldTrialName); | |
111 return group == aggressive_hup_experiment_group; | |
112 } | |
113 | |
114 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrial() { | 80 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrial() { |
115 return base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName); | 81 return base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName); |
116 } | 82 } |
117 | 83 |
118 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() { | 84 bool AutocompleteFieldTrial::InDisallowInlineHQPFieldTrialExperimentGroup() { |
119 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName)) | 85 if (!base::FieldTrialList::TrialExists(kDisallowInlineHQPFieldTrialName)) |
120 return false; | 86 return false; |
121 | 87 |
122 // Return true if we're in the experiment group. | 88 // Return true if we're in the experiment group. |
123 const int group = base::FieldTrialList::FindValue( | 89 const int group = base::FieldTrialList::FindValue( |
(...skipping 18 matching lines...) Expand all Loading... |
142 // get numbers that we know are 0, 1, 2, ... | 108 // get numbers that we know are 0, 1, 2, ... |
143 int AutocompleteFieldTrial::GetSuggestGroupNameAsNumber() { | 109 int AutocompleteFieldTrial::GetSuggestGroupNameAsNumber() { |
144 int group_num; | 110 int group_num; |
145 base::StringToInt(GetSuggestGroupName(), &group_num); | 111 base::StringToInt(GetSuggestGroupName(), &group_num); |
146 return group_num; | 112 return group_num; |
147 } | 113 } |
148 | 114 |
149 int AutocompleteFieldTrial::GetSuggestNumberOfGroups() { | 115 int AutocompleteFieldTrial::GetSuggestNumberOfGroups() { |
150 return kSuggestFieldTrialNumberOfGroups; | 116 return kSuggestFieldTrialNumberOfGroups; |
151 } | 117 } |
OLD | NEW |