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/prerender/prerender_field_trial.h" | 5 #include "chrome/browser/prerender/prerender_field_trial.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (channel == chrome::VersionInfo::CHANNEL_STABLE || | 193 if (channel == chrome::VersionInfo::CHANNEL_STABLE || |
194 channel == chrome::VersionInfo::CHANNEL_BETA) { | 194 channel == chrome::VersionInfo::CHANNEL_BETA) { |
195 kDisabledProbability = 1; | 195 kDisabledProbability = 1; |
196 } | 196 } |
197 scoped_refptr<base::FieldTrial> omnibox_prerender_trial( | 197 scoped_refptr<base::FieldTrial> omnibox_prerender_trial( |
198 base::FieldTrialList::FactoryGetFieldTrial( | 198 base::FieldTrialList::FactoryGetFieldTrial( |
199 kOmniboxTrialName, kDivisor, "OmniboxPrerenderEnabled", | 199 kOmniboxTrialName, kDivisor, "OmniboxPrerenderEnabled", |
200 2012, 12, 30, &g_omnibox_trial_default_group_number)); | 200 2012, 12, 30, &g_omnibox_trial_default_group_number)); |
201 omnibox_prerender_trial->AppendGroup("OmniboxPrerenderDisabled", | 201 omnibox_prerender_trial->AppendGroup("OmniboxPrerenderDisabled", |
202 kDisabledProbability); | 202 kDisabledProbability); |
203 | |
204 // Field trial to set weighting of hits. | |
205 const base::FieldTrial::Probability kFourProbability = 33; | |
206 const base::FieldTrial::Probability kEightProbability = 33; | |
207 | |
208 scoped_refptr<base::FieldTrial> weighting_trial( | |
209 base::FieldTrialList::FactoryGetFieldTrial( | |
210 "OmniboxPrerenderHitWeightingTrial", kDivisor, | |
211 "OmniboxPrerenderWeight1.0", 2012, 8, 30, NULL)); | |
212 const int kOmniboxWeightFourGroup = | |
213 weighting_trial->AppendGroup("OmniboxPrerenderWeight4.0", | |
214 kFourProbability); | |
215 const int kOmniboxWeightEightGroup = | |
216 weighting_trial->AppendGroup("OmniboxPrerenderWeight8.0", | |
217 kEightProbability); | |
218 const int group = weighting_trial->group(); | |
219 if (group == kOmniboxWeightFourGroup) | |
220 predictors::AutocompleteActionPredictor::set_hit_weight(4.0); | |
221 else if (group == kOmniboxWeightEightGroup) | |
222 predictors::AutocompleteActionPredictor::set_hit_weight(8.0); | |
223 } | 203 } |
224 | 204 |
225 bool IsOmniboxEnabled(Profile* profile) { | 205 bool IsOmniboxEnabled(Profile* profile) { |
226 if (!profile || profile->IsOffTheRecord()) | 206 if (!profile || profile->IsOffTheRecord()) |
227 return false; | 207 return false; |
228 | 208 |
229 if (!PrerenderManager::IsPrerenderingPossible()) | 209 if (!PrerenderManager::IsPrerenderingPossible()) |
230 return false; | 210 return false; |
231 | 211 |
232 // Override any field trial groups if the user has set a command line flag. | 212 // Override any field trial groups if the user has set a command line flag. |
(...skipping 11 matching lines...) Expand all Loading... |
244 | 224 |
245 DCHECK(switch_value == switches::kPrerenderFromOmniboxSwitchValueAuto); | 225 DCHECK(switch_value == switches::kPrerenderFromOmniboxSwitchValueAuto); |
246 } | 226 } |
247 | 227 |
248 const int group = base::FieldTrialList::FindValue(kOmniboxTrialName); | 228 const int group = base::FieldTrialList::FindValue(kOmniboxTrialName); |
249 return group == base::FieldTrial::kNotFinalized || | 229 return group == base::FieldTrial::kNotFinalized || |
250 group == g_omnibox_trial_default_group_number; | 230 group == g_omnibox_trial_default_group_number; |
251 } | 231 } |
252 | 232 |
253 } // namespace prerender | 233 } // namespace prerender |
OLD | NEW |