| 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/chrome_browser_field_trials.h" | 5 #include "chrome/browser/chrome_browser_field_trials.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/auto_launch_trial.h" | 16 #include "chrome/browser/auto_launch_trial.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_field_trial.h" | 17 #include "chrome/browser/autocomplete/autocomplete_field_trial.h" |
| 18 #include "chrome/browser/chrome_gpu_util.h" | 18 #include "chrome/browser/chrome_gpu_util.h" |
| 19 #include "chrome/browser/google/google_util.h" | 19 #include "chrome/browser/google/google_util.h" |
| 20 #include "chrome/browser/metrics/variations/variations_service.h" |
| 20 #include "chrome/browser/prerender/prerender_field_trial.h" | 21 #include "chrome/browser/prerender/prerender_field_trial.h" |
| 21 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 22 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
| 22 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 23 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/chrome_version_info.h" | 25 #include "chrome/common/chrome_version_info.h" |
| 25 #include "chrome/common/metrics/variations/variations_util.h" | 26 #include "chrome/common/metrics/variations/variations_util.h" |
| 26 #include "net/socket/client_socket_pool_base.h" | 27 #include "net/socket/client_socket_pool_base.h" |
| 27 #include "net/spdy/spdy_session.h" | 28 #include "net/spdy/spdy_session.h" |
| 28 #include "ui/base/layout.h" | 29 #include "ui/base/layout.h" |
| 29 | 30 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 group_number)); | 75 group_number)); |
| 75 } | 76 } |
| 76 | 77 |
| 77 // Now that all groups have been appended, call group() on the trial to | 78 // Now that all groups have been appended, call group() on the trial to |
| 78 // ensure that our trial is registered. This resolves an off-by-one issue | 79 // ensure that our trial is registered. This resolves an off-by-one issue |
| 79 // where the default group never gets chosen if we don't "use" the trial. | 80 // where the default group never gets chosen if we don't "use" the trial. |
| 80 const int chosen_group = trial->group(); | 81 const int chosen_group = trial->group(); |
| 81 DVLOG(1) << "Chosen Group: " << chosen_group; | 82 DVLOG(1) << "Chosen Group: " << chosen_group; |
| 82 } | 83 } |
| 83 | 84 |
| 85 // Setup a 50% uniformity trial for new installs only. This is accomplished by |
| 86 // disabling the trial on clients that were installed before a specified date. |
| 87 void SetupNewInstallUniformityTrial(const base::Time& install_date) { |
| 88 const base::Time::Exploded kStartDate = { |
| 89 2012, 11, 0, 6, // Nov 6, 2012 |
| 90 0, 0, 0, 0 // 00:00:00.000 |
| 91 }; |
| 92 scoped_refptr<base::FieldTrial> trial( |
| 93 base::FieldTrialList::FactoryGetFieldTrial( |
| 94 "UMA-New-Install-Uniformity-Trial", 100, "Disabled", |
| 95 2015, 1, 1, NULL)); |
| 96 trial->UseOneTimeRandomization(); |
| 97 trial->AppendGroup("Control", 50); |
| 98 trial->AppendGroup("Experiment", 50); |
| 99 const base::Time start_date = base::Time::FromLocalExploded(kStartDate); |
| 100 if (install_date < start_date) |
| 101 trial->Disable(); |
| 102 else |
| 103 trial->group(); |
| 104 } |
| 105 |
| 84 void SetSocketReusePolicy(int warmest_socket_trial_group, | 106 void SetSocketReusePolicy(int warmest_socket_trial_group, |
| 85 const int socket_policy[], | 107 const int socket_policy[], |
| 86 int num_groups) { | 108 int num_groups) { |
| 87 const int* result = std::find(socket_policy, socket_policy + num_groups, | 109 const int* result = std::find(socket_policy, socket_policy + num_groups, |
| 88 warmest_socket_trial_group); | 110 warmest_socket_trial_group); |
| 89 DCHECK_NE(result, socket_policy + num_groups) | 111 DCHECK_NE(result, socket_policy + num_groups) |
| 90 << "Not a valid socket reuse policy group"; | 112 << "Not a valid socket reuse policy group"; |
| 91 net::SetSocketReusePolicy(result - socket_policy); | 113 net::SetSocketReusePolicy(result - socket_policy); |
| 92 } | 114 } |
| 93 | 115 |
| 94 } // namespace | 116 } // namespace |
| 95 | 117 |
| 96 ChromeBrowserFieldTrials::ChromeBrowserFieldTrials( | 118 ChromeBrowserFieldTrials::ChromeBrowserFieldTrials( |
| 97 const CommandLine& parsed_command_line) : | 119 const CommandLine& parsed_command_line) : |
| 98 parsed_command_line_(parsed_command_line) { | 120 parsed_command_line_(parsed_command_line) { |
| 99 } | 121 } |
| 100 | 122 |
| 101 ChromeBrowserFieldTrials::~ChromeBrowserFieldTrials() { | 123 ChromeBrowserFieldTrials::~ChromeBrowserFieldTrials() { |
| 102 } | 124 } |
| 103 | 125 |
| 104 void ChromeBrowserFieldTrials::SetupFieldTrials() { | 126 void ChromeBrowserFieldTrials::SetupFieldTrials( |
| 127 const base::Time& install_time) { |
| 105 prerender::ConfigurePrefetchAndPrerender(parsed_command_line_); | 128 prerender::ConfigurePrefetchAndPrerender(parsed_command_line_); |
| 106 SpdyFieldTrial(); | 129 SpdyFieldTrial(); |
| 107 WarmConnectionFieldTrial(); | 130 WarmConnectionFieldTrial(); |
| 108 AutoLaunchChromeFieldTrial(); | 131 AutoLaunchChromeFieldTrial(); |
| 109 gpu_util::InitializeCompositingFieldTrial(); | 132 gpu_util::InitializeCompositingFieldTrial(); |
| 110 SetupUniformityFieldTrials(); | 133 SetupUniformityFieldTrials(install_time); |
| 111 AutocompleteFieldTrial::Activate(); | 134 AutocompleteFieldTrial::Activate(); |
| 112 DisableNewTabFieldTrialIfNecesssary(); | 135 DisableNewTabFieldTrialIfNecesssary(); |
| 113 SetUpSafeBrowsingInterstitialFieldTrial(); | 136 SetUpSafeBrowsingInterstitialFieldTrial(); |
| 114 SetUpInfiniteCacheFieldTrial(); | 137 SetUpInfiniteCacheFieldTrial(); |
| 115 SetUpCacheSensitivityAnalysisFieldTrial(); | 138 SetUpCacheSensitivityAnalysisFieldTrial(); |
| 116 WindowsOverlappedTCPReadsFieldTrial(); | 139 WindowsOverlappedTCPReadsFieldTrial(); |
| 117 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 140 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
| 118 OneClickSigninHelper::InitializeFieldTrial(); | 141 OneClickSigninHelper::InitializeFieldTrial(); |
| 119 #endif | 142 #endif |
| 120 InstantiateDynamicTrials(); | 143 InstantiateDynamicTrials(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // Create a 100% field trial based on the brand code. | 227 // Create a 100% field trial based on the brand code. |
| 205 if (auto_launch_trial::IsInExperimentGroup(brand)) { | 228 if (auto_launch_trial::IsInExperimentGroup(brand)) { |
| 206 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName, | 229 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName, |
| 207 kAutoLaunchTrialAutoLaunchGroup); | 230 kAutoLaunchTrialAutoLaunchGroup); |
| 208 } else if (auto_launch_trial::IsInControlGroup(brand)) { | 231 } else if (auto_launch_trial::IsInControlGroup(brand)) { |
| 209 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName, | 232 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName, |
| 210 kAutoLaunchTrialControlGroup); | 233 kAutoLaunchTrialControlGroup); |
| 211 } | 234 } |
| 212 } | 235 } |
| 213 | 236 |
| 214 void ChromeBrowserFieldTrials::SetupUniformityFieldTrials() { | 237 void ChromeBrowserFieldTrials::SetupUniformityFieldTrials( |
| 238 const base::Time& install_date) { |
| 215 // One field trial will be created for each entry in this array. The i'th | 239 // One field trial will be created for each entry in this array. The i'th |
| 216 // field trial will have |trial_sizes[i]| groups in it, including the default | 240 // field trial will have |trial_sizes[i]| groups in it, including the default |
| 217 // group. Each group will have a probability of 1/|trial_sizes[i]|. | 241 // group. Each group will have a probability of 1/|trial_sizes[i]|. |
| 218 const int num_trial_groups[] = { 100, 20, 10, 5, 2 }; | 242 const int num_trial_groups[] = { 100, 20, 10, 5, 2 }; |
| 219 | 243 |
| 220 // Declare our variation ID bases along side this array so we can loop over it | 244 // Declare our variation ID bases along side this array so we can loop over it |
| 221 // and assign the IDs appropriately. So for example, the 1 percent experiments | 245 // and assign the IDs appropriately. So for example, the 1 percent experiments |
| 222 // should have a size of 100 (100/100 = 1). | 246 // should have a size of 100 (100/100 = 1). |
| 223 const chrome_variations::VariationID trial_base_ids[] = { | 247 const chrome_variations::VariationID trial_base_ids[] = { |
| 224 chrome_variations::kUniformity1PercentBase, | 248 chrome_variations::kUniformity1PercentBase, |
| 225 chrome_variations::kUniformity5PercentBase, | 249 chrome_variations::kUniformity5PercentBase, |
| 226 chrome_variations::kUniformity10PercentBase, | 250 chrome_variations::kUniformity10PercentBase, |
| 227 chrome_variations::kUniformity20PercentBase, | 251 chrome_variations::kUniformity20PercentBase, |
| 228 chrome_variations::kUniformity50PercentBase | 252 chrome_variations::kUniformity50PercentBase |
| 229 }; | 253 }; |
| 230 | 254 |
| 231 const std::string kOneTimeRandomizedTrialName = | 255 const std::string kOneTimeRandomizedTrialName = |
| 232 "UMA-Uniformity-Trial-%d-Percent"; | 256 "UMA-Uniformity-Trial-%d-Percent"; |
| 233 for (size_t i = 0; i < arraysize(num_trial_groups); ++i) { | 257 for (size_t i = 0; i < arraysize(num_trial_groups); ++i) { |
| 234 SetupSingleUniformityFieldTrial(true, kOneTimeRandomizedTrialName, | 258 SetupSingleUniformityFieldTrial(true, kOneTimeRandomizedTrialName, |
| 235 trial_base_ids[i], num_trial_groups[i]); | 259 trial_base_ids[i], num_trial_groups[i]); |
| 236 } | 260 } |
| 237 | 261 |
| 238 // Setup a 5% session-randomized uniformity trial. | 262 // Setup a 5% session-randomized uniformity trial. |
| 239 const std::string kSessionRandomizedTrialName = | 263 const std::string kSessionRandomizedTrialName = |
| 240 "UMA-Session-Randomized-Uniformity-Trial-%d-Percent"; | 264 "UMA-Session-Randomized-Uniformity-Trial-%d-Percent"; |
| 241 SetupSingleUniformityFieldTrial(false, kSessionRandomizedTrialName, | 265 SetupSingleUniformityFieldTrial(false, kSessionRandomizedTrialName, |
| 242 chrome_variations::kUniformitySessionRandomized5PercentBase, 20); | 266 chrome_variations::kUniformitySessionRandomized5PercentBase, 20); |
| 267 |
| 268 SetupNewInstallUniformityTrial(install_date); |
| 243 } | 269 } |
| 244 | 270 |
| 245 void ChromeBrowserFieldTrials::DisableNewTabFieldTrialIfNecesssary() { | 271 void ChromeBrowserFieldTrials::DisableNewTabFieldTrialIfNecesssary() { |
| 246 // The new tab button field trial will get created in variations_service.cc | 272 // The new tab button field trial will get created in variations_service.cc |
| 247 // through the variations server. However, since there are no HiDPI assets | 273 // through the variations server. However, since there are no HiDPI assets |
| 248 // for it, disable it for non-desktop layouts. | 274 // for it, disable it for non-desktop layouts. |
| 249 base::FieldTrial* trial = base::FieldTrialList::Find("NewTabButton"); | 275 base::FieldTrial* trial = base::FieldTrialList::Find("NewTabButton"); |
| 250 if (trial) { | 276 if (trial) { |
| 251 bool using_hidpi_assets = false; | 277 bool using_hidpi_assets = false; |
| 252 #if defined(ENABLE_HIDPI) && defined(OS_WIN) | 278 #if defined(ENABLE_HIDPI) && defined(OS_WIN) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 #endif | 360 #endif |
| 335 } | 361 } |
| 336 | 362 |
| 337 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { | 363 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { |
| 338 // Call |FindValue()| on the trials below, which may come from the server, to | 364 // Call |FindValue()| on the trials below, which may come from the server, to |
| 339 // ensure they get marked as "used" for the purposes of data reporting. | 365 // ensure they get marked as "used" for the purposes of data reporting. |
| 340 base::FieldTrialList::FindValue("UMA-Dynamic-Binary-Uniformity-Trial"); | 366 base::FieldTrialList::FindValue("UMA-Dynamic-Binary-Uniformity-Trial"); |
| 341 base::FieldTrialList::FindValue("UMA-Dynamic-Uniformity-Trial"); | 367 base::FieldTrialList::FindValue("UMA-Dynamic-Uniformity-Trial"); |
| 342 base::FieldTrialList::FindValue("InstantDummy"); | 368 base::FieldTrialList::FindValue("InstantDummy"); |
| 343 } | 369 } |
| OLD | NEW |