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 #ifndef CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ | 5 #ifndef CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ |
6 #define CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ | 6 #define CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 }; | 83 }; |
84 | 84 |
85 // This class manages the Omnibox field trials. | 85 // This class manages the Omnibox field trials. |
86 class OmniboxFieldTrial { | 86 class OmniboxFieldTrial { |
87 public: | 87 public: |
88 // A mapping that contains multipliers indicating that matches of the | 88 // A mapping that contains multipliers indicating that matches of the |
89 // specified type should have their relevance score multiplied by the | 89 // specified type should have their relevance score multiplied by the |
90 // given number. Omitted types are assumed to have multipliers of 1.0. | 90 // given number. Omitted types are assumed to have multipliers of 1.0. |
91 typedef std::map<AutocompleteMatchType::Type, float> DemotionMultipliers; | 91 typedef std::map<AutocompleteMatchType::Type, float> DemotionMultipliers; |
92 | 92 |
93 // Creates the static field trial groups. | |
94 // *** MUST NOT BE CALLED MORE THAN ONCE. *** | |
95 static void ActivateStaticTrials(); | |
96 | |
97 // Activates all dynamic field trials. The main difference between | 93 // Activates all dynamic field trials. The main difference between |
98 // the autocomplete dynamic and static field trials is that the former | 94 // the autocomplete dynamic and static field trials is that the former |
99 // don't require any code changes on the Chrome side as they are controlled | 95 // don't require any code changes on the Chrome side as they are controlled |
100 // on the server side. Chrome binary simply propagates all necessary | 96 // on the server side. Chrome binary simply propagates all necessary |
101 // information through the X-Client-Data header. | 97 // information through the X-Client-Data header. |
102 // This method, unlike ActivateStaticTrials(), may be called multiple times. | 98 // This method may be called multiple times. |
103 static void ActivateDynamicTrials(); | 99 static void ActivateDynamicTrials(); |
104 | 100 |
105 // Returns a bitmap containing AutocompleteProvider::Type values | 101 // Returns a bitmap containing AutocompleteProvider::Type values |
106 // that should be disabled in AutocompleteController. | 102 // that should be disabled in AutocompleteController. |
107 // This method simply goes over all autocomplete dynamic field trial groups | 103 // This method simply goes over all autocomplete dynamic field trial groups |
108 // and looks for group names like "ProvidersDisabled_NNN" where NNN is | 104 // and looks for group names like "ProvidersDisabled_NNN" where NNN is |
109 // an integer corresponding to a bitmap mask. All extracted bitmaps | 105 // an integer corresponding to a bitmap mask. All extracted bitmaps |
110 // are OR-ed together and returned as the final result. | 106 // are OR-ed together and returned as the final result. |
111 static int GetDisabledProviderTypes(); | 107 static int GetDisabledProviderTypes(); |
112 | 108 |
113 // Returns whether the user is in any dynamic field trial where the | 109 // Returns whether the user is in any dynamic field trial where the |
114 // group has a the prefix |group_prefix|. | 110 // group has a the prefix |group_prefix|. |
115 static bool HasDynamicFieldTrialGroupPrefix(const char *group_prefix); | 111 static bool HasDynamicFieldTrialGroupPrefix(const char *group_prefix); |
116 | 112 |
117 // --------------------------------------------------------- | 113 // --------------------------------------------------------- |
118 // For the suggest field trial. | 114 // For the suggest field trial. |
119 | 115 |
120 // Populates |field_trial_hash| with hashes of the active suggest field trial | 116 // Populates |field_trial_hash| with hashes of the active suggest field trial |
121 // names, if any. | 117 // names, if any. |
122 static void GetActiveSuggestFieldTrialHashes( | 118 static void GetActiveSuggestFieldTrialHashes( |
123 std::vector<uint32>* field_trial_hash); | 119 std::vector<uint32>* field_trial_hash); |
124 | 120 |
125 // --------------------------------------------------------- | 121 // --------------------------------------------------------- |
126 // For the HistoryURL provider disable culling redirects field trial. | |
127 | |
128 // Returns whether the user is in any group for this field trial. | |
129 // (Should always be true unless initialization went wrong.) | |
130 static bool InHUPCullRedirectsFieldTrial(); | |
131 | |
132 // Returns whether we should disable culling of redirects in | |
133 // HistoryURL provider. | |
134 static bool InHUPCullRedirectsFieldTrialExperimentGroup(); | |
135 | |
136 // --------------------------------------------------------- | |
137 // For the HistoryURL provider disable creating a shorter match | |
138 // field trial. | |
139 | |
140 // Returns whether the user is in any group for this field trial. | |
141 // (Should always be true unless initialization went wrong.) | |
142 static bool InHUPCreateShorterMatchFieldTrial(); | |
143 | |
144 // Returns whether we should disable creating a shorter match in | |
145 // HistoryURL provider. | |
146 static bool InHUPCreateShorterMatchFieldTrialExperimentGroup(); | |
147 | |
148 // --------------------------------------------------------- | |
149 // For the AutocompleteController "stop timer" field trial. | 122 // For the AutocompleteController "stop timer" field trial. |
150 | 123 |
151 // Returns the duration to be used for the AutocompleteController's stop | 124 // Returns the duration to be used for the AutocompleteController's stop |
152 // timer. Returns the default value of 1.5 seconds if the stop timer | 125 // timer. Returns the default value of 1.5 seconds if the stop timer |
153 // override experiment isn't active or if parsing the experiment-provided | 126 // override experiment isn't active or if parsing the experiment-provided |
154 // duration fails. | 127 // duration fails. |
155 static base::TimeDelta StopTimerFieldTrialDuration(); | 128 static base::TimeDelta StopTimerFieldTrialDuration(); |
156 | 129 |
157 // --------------------------------------------------------- | 130 // --------------------------------------------------------- |
158 // For the ZeroSuggestProvider field trial. | 131 // For the ZeroSuggestProvider field trial. |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 // prioritize different wildcard contexts, see the implementation. How to | 338 // prioritize different wildcard contexts, see the implementation. How to |
366 // interpret the value is left to the caller; this is rule-dependent. | 339 // interpret the value is left to the caller; this is rule-dependent. |
367 static std::string GetValueForRuleInContext( | 340 static std::string GetValueForRuleInContext( |
368 const std::string& rule, | 341 const std::string& rule, |
369 metrics::OmniboxEventProto::PageClassification page_classification); | 342 metrics::OmniboxEventProto::PageClassification page_classification); |
370 | 343 |
371 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); | 344 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); |
372 }; | 345 }; |
373 | 346 |
374 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ | 347 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ |
OLD | NEW |