| 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" |
| 11 #include "chrome/browser/autocomplete/network_action_predictor.h" | 11 #include "chrome/browser/autocomplete/network_action_predictor.h" |
| 12 #include "chrome/browser/metrics/metrics_service.h" | 12 #include "chrome/browser/metrics/metrics_service.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/prerender/prerender_manager.h" | 14 #include "chrome/browser/prerender/prerender_manager.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/chrome_version_info.h" | 17 #include "chrome/common/chrome_version_info.h" |
| 18 | 18 |
| 19 namespace prerender { | 19 namespace prerender { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const char kOmniboxTrialName[] = "PrerenderFromOmnibox"; | 23 const char kOmniboxTrialName[] = "PrerenderFromOmnibox"; |
| 24 int g_omnibox_trial_default_group_number = -1; |
| 24 | 25 |
| 25 void SetupPrefetchFieldTrial() { | 26 void SetupPrefetchFieldTrial() { |
| 26 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 27 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 27 if (channel == chrome::VersionInfo::CHANNEL_STABLE || | 28 if (channel == chrome::VersionInfo::CHANNEL_STABLE || |
| 28 channel == chrome::VersionInfo::CHANNEL_BETA) { | 29 channel == chrome::VersionInfo::CHANNEL_BETA) { |
| 29 return; | 30 return; |
| 30 } | 31 } |
| 31 | 32 |
| 32 const base::FieldTrial::Probability divisor = 1000; | 33 const base::FieldTrial::Probability divisor = 1000; |
| 33 const base::FieldTrial::Probability prefetch_probability = 500; | 34 const base::FieldTrial::Probability prefetch_probability = 500; |
| 34 scoped_refptr<base::FieldTrial> trial( | 35 scoped_refptr<base::FieldTrial> trial( |
| 35 new base::FieldTrial("Prefetch", divisor, | 36 base::FieldTrialList::FactoryGetFieldTrial( |
| 36 "ContentPrefetchPrefetchOff", 2012, 6, 30)); | 37 "Prefetch", divisor, "ContentPrefetchPrefetchOff", |
| 38 2012, 6, 30, NULL)); |
| 37 const int kPrefetchOnGroup = trial->AppendGroup("ContentPrefetchPrefetchOn", | 39 const int kPrefetchOnGroup = trial->AppendGroup("ContentPrefetchPrefetchOn", |
| 38 prefetch_probability); | 40 prefetch_probability); |
| 39 PrerenderManager::SetIsPrefetchEnabled(trial->group() == kPrefetchOnGroup); | 41 PrerenderManager::SetIsPrefetchEnabled(trial->group() == kPrefetchOnGroup); |
| 40 } | 42 } |
| 41 | 43 |
| 42 void SetupPrerenderFieldTrial() { | 44 void SetupPrerenderFieldTrial() { |
| 43 base::FieldTrial::Probability divisor = 1000; | 45 base::FieldTrial::Probability divisor = 1000; |
| 44 | 46 |
| 45 base::FieldTrial::Probability exp1_probability = 166; | 47 base::FieldTrial::Probability exp1_probability = 166; |
| 46 base::FieldTrial::Probability exp1_5min_ttl_probability = 83; | 48 base::FieldTrial::Probability exp1_5min_ttl_probability = 83; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 61 no_use1_probability = 0; | 63 no_use1_probability = 0; |
| 62 exp2_probability = 490; | 64 exp2_probability = 490; |
| 63 exp2_5min_ttl_probability = 5; | 65 exp2_5min_ttl_probability = 5; |
| 64 control2_probability = 5; | 66 control2_probability = 5; |
| 65 no_use2_probability = 0; | 67 no_use2_probability = 0; |
| 66 } | 68 } |
| 67 CHECK_EQ(divisor, exp1_probability + exp1_5min_ttl_probability + | 69 CHECK_EQ(divisor, exp1_probability + exp1_5min_ttl_probability + |
| 68 control1_probability + no_use1_probability + exp2_probability + | 70 control1_probability + no_use1_probability + exp2_probability + |
| 69 exp2_5min_ttl_probability + control2_probability + | 71 exp2_5min_ttl_probability + control2_probability + |
| 70 no_use2_probability); | 72 no_use2_probability); |
| 73 int experiment_1_group = -1; |
| 71 scoped_refptr<base::FieldTrial> trial( | 74 scoped_refptr<base::FieldTrial> trial( |
| 72 new base::FieldTrial("Prerender", divisor, | 75 base::FieldTrialList::FactoryGetFieldTrial( |
| 73 "ContentPrefetchPrerender1", 2012, 6, 30)); | 76 "Prerender", divisor, "ContentPrefetchPrerender1", |
| 77 2012, 6, 30, &experiment_1_group)); |
| 74 | 78 |
| 75 const int kExperiment1Group = trial->kDefaultGroupNumber; | 79 const int experiment_15_min_TTL_group = |
| 76 const int kExperiment15minTTLGroup = | |
| 77 trial->AppendGroup("ContentPrefetchPrerenderExp5minTTL1", | 80 trial->AppendGroup("ContentPrefetchPrerenderExp5minTTL1", |
| 78 exp1_5min_ttl_probability); | 81 exp1_5min_ttl_probability); |
| 79 const int kControl1Group = | 82 const int control_1_group = |
| 80 trial->AppendGroup("ContentPrefetchPrerenderControl1", | 83 trial->AppendGroup("ContentPrefetchPrerenderControl1", |
| 81 control1_probability); | 84 control1_probability); |
| 82 const int kNoUse1Group = | 85 const int no_use_1_group = |
| 83 trial->AppendGroup("ContentPrefetchPrerenderNoUse1", | 86 trial->AppendGroup("ContentPrefetchPrerenderNoUse1", |
| 84 no_use1_probability); | 87 no_use1_probability); |
| 85 const int kExperiment2Group = | 88 const int experiment_2_group = |
| 86 trial->AppendGroup("ContentPrefetchPrerender2", | 89 trial->AppendGroup("ContentPrefetchPrerender2", |
| 87 exp2_probability); | 90 exp2_probability); |
| 88 const int kExperiment25minTTLGroup = | 91 const int experiment_25_min_TTL_group = |
| 89 trial->AppendGroup("ContentPrefetchPrerenderExp5minTTL2", | 92 trial->AppendGroup("ContentPrefetchPrerenderExp5minTTL2", |
| 90 exp2_5min_ttl_probability); | 93 exp2_5min_ttl_probability); |
| 91 const int kControl2Group = | 94 const int control_2_group = |
| 92 trial->AppendGroup("ContentPrefetchPrerenderControl2", | 95 trial->AppendGroup("ContentPrefetchPrerenderControl2", |
| 93 control2_probability); | 96 control2_probability); |
| 94 const int kNoUse2Group = | 97 const int no_use_2_group = |
| 95 trial->AppendGroup("ContentPrefetchPrerenderNoUse2", | 98 trial->AppendGroup("ContentPrefetchPrerenderNoUse2", |
| 96 no_use2_probability); | 99 no_use2_probability); |
| 97 const int trial_group = trial->group(); | 100 const int trial_group = trial->group(); |
| 98 if (trial_group == kExperiment1Group || | 101 if (trial_group == experiment_1_group || |
| 99 trial_group == kExperiment2Group) { | 102 trial_group == experiment_2_group) { |
| 100 PrerenderManager::SetMode( | 103 PrerenderManager::SetMode( |
| 101 PrerenderManager::PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP); | 104 PrerenderManager::PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP); |
| 102 } else if (trial_group == kExperiment15minTTLGroup || | 105 } else if (trial_group == experiment_15_min_TTL_group || |
| 103 trial_group == kExperiment25minTTLGroup) { | 106 trial_group == experiment_25_min_TTL_group) { |
| 104 PrerenderManager::SetMode( | 107 PrerenderManager::SetMode( |
| 105 PrerenderManager::PRERENDER_MODE_EXPERIMENT_5MIN_TTL_GROUP); | 108 PrerenderManager::PRERENDER_MODE_EXPERIMENT_5MIN_TTL_GROUP); |
| 106 } else if (trial_group == kControl1Group || | 109 } else if (trial_group == control_1_group || |
| 107 trial_group == kControl2Group) { | 110 trial_group == control_2_group) { |
| 108 PrerenderManager::SetMode( | 111 PrerenderManager::SetMode( |
| 109 PrerenderManager::PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP); | 112 PrerenderManager::PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP); |
| 110 } else if (trial_group == kNoUse1Group || | 113 } else if (trial_group == no_use_1_group || |
| 111 trial_group == kNoUse2Group) { | 114 trial_group == no_use_2_group) { |
| 112 PrerenderManager::SetMode( | 115 PrerenderManager::SetMode( |
| 113 PrerenderManager::PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP); | 116 PrerenderManager::PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP); |
| 114 } else { | 117 } else { |
| 115 NOTREACHED(); | 118 NOTREACHED(); |
| 116 } | 119 } |
| 117 } | 120 } |
| 118 | 121 |
| 119 } // end namespace | 122 } // end namespace |
| 120 | 123 |
| 121 void ConfigureOmniboxPrerender(); | 124 void ConfigureOmniboxPrerender(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // Field trial to see if we're enabled. | 188 // Field trial to see if we're enabled. |
| 186 const base::FieldTrial::Probability kDivisor = 100; | 189 const base::FieldTrial::Probability kDivisor = 100; |
| 187 | 190 |
| 188 base::FieldTrial::Probability kDisabledProbability = 10; | 191 base::FieldTrial::Probability kDisabledProbability = 10; |
| 189 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 192 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 190 if (channel == chrome::VersionInfo::CHANNEL_STABLE || | 193 if (channel == chrome::VersionInfo::CHANNEL_STABLE || |
| 191 channel == chrome::VersionInfo::CHANNEL_BETA) { | 194 channel == chrome::VersionInfo::CHANNEL_BETA) { |
| 192 kDisabledProbability = 1; | 195 kDisabledProbability = 1; |
| 193 } | 196 } |
| 194 scoped_refptr<base::FieldTrial> omnibox_prerender_trial( | 197 scoped_refptr<base::FieldTrial> omnibox_prerender_trial( |
| 195 new base::FieldTrial(kOmniboxTrialName, kDivisor, | 198 base::FieldTrialList::FactoryGetFieldTrial( |
| 196 "OmniboxPrerenderEnabled", 2012, 8, 30)); | 199 kOmniboxTrialName, kDivisor, "OmniboxPrerenderEnabled", |
| 200 2012, 8, 30, &g_omnibox_trial_default_group_number)); |
| 197 omnibox_prerender_trial->AppendGroup("OmniboxPrerenderDisabled", | 201 omnibox_prerender_trial->AppendGroup("OmniboxPrerenderDisabled", |
| 198 kDisabledProbability); | 202 kDisabledProbability); |
| 199 | 203 |
| 200 // Field trial to set weighting of hits. | 204 // Field trial to set weighting of hits. |
| 201 const base::FieldTrial::Probability kFourProbability = 33; | 205 const base::FieldTrial::Probability kFourProbability = 33; |
| 202 const base::FieldTrial::Probability kEightProbability = 33; | 206 const base::FieldTrial::Probability kEightProbability = 33; |
| 203 | 207 |
| 204 scoped_refptr<base::FieldTrial> weighting_trial( | 208 scoped_refptr<base::FieldTrial> weighting_trial( |
| 205 new base::FieldTrial("OmniboxPrerenderHitWeightingTrial", kDivisor, | 209 base::FieldTrialList::FactoryGetFieldTrial( |
| 206 "OmniboxPrerenderWeight1.0", 2012, 8, 30)); | 210 "OmniboxPrerenderHitWeightingTrial", kDivisor, |
| 211 "OmniboxPrerenderWeight1.0", 2012, 8, 30, NULL)); |
| 207 const int kOmniboxWeightFourGroup = | 212 const int kOmniboxWeightFourGroup = |
| 208 weighting_trial->AppendGroup("OmniboxPrerenderWeight4.0", | 213 weighting_trial->AppendGroup("OmniboxPrerenderWeight4.0", |
| 209 kFourProbability); | 214 kFourProbability); |
| 210 const int kOmniboxWeightEightGroup = | 215 const int kOmniboxWeightEightGroup = |
| 211 weighting_trial->AppendGroup("OmniboxPrerenderWeight8.0", | 216 weighting_trial->AppendGroup("OmniboxPrerenderWeight8.0", |
| 212 kEightProbability); | 217 kEightProbability); |
| 213 const int group = weighting_trial->group(); | 218 const int group = weighting_trial->group(); |
| 214 if (group == kOmniboxWeightFourGroup) | 219 if (group == kOmniboxWeightFourGroup) |
| 215 NetworkActionPredictor::set_hit_weight(4.0); | 220 NetworkActionPredictor::set_hit_weight(4.0); |
| 216 else if (group == kOmniboxWeightEightGroup) | 221 else if (group == kOmniboxWeightEightGroup) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 235 return true; | 240 return true; |
| 236 | 241 |
| 237 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueDisabled) | 242 if (switch_value == switches::kPrerenderFromOmniboxSwitchValueDisabled) |
| 238 return false; | 243 return false; |
| 239 | 244 |
| 240 DCHECK(switch_value == switches::kPrerenderFromOmniboxSwitchValueAuto); | 245 DCHECK(switch_value == switches::kPrerenderFromOmniboxSwitchValueAuto); |
| 241 } | 246 } |
| 242 | 247 |
| 243 const int group = base::FieldTrialList::FindValue(kOmniboxTrialName); | 248 const int group = base::FieldTrialList::FindValue(kOmniboxTrialName); |
| 244 return group == base::FieldTrial::kNotFinalized || | 249 return group == base::FieldTrial::kNotFinalized || |
| 245 group == base::FieldTrial::kDefaultGroupNumber; | 250 group == g_omnibox_trial_default_group_number; |
| 246 } | 251 } |
| 247 | 252 |
| 248 } // namespace prerender | 253 } // namespace prerender |
| OLD | NEW |