Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/chrome_browser_field_trials_desktop.cc

Issue 14247021: Split the field trial setup code into desktop and mobile files. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_desktop.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "apps/field_trial_names.h" 9 #include "apps/field_trial_names.h"
10 #include "apps/pref_names.h" 10 #include "apps/pref_names.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/stringprintf.h"
16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/sys_string_conversions.h"
18 #include "base/utf_string_conversions.h"
19 #include "chrome/browser/auto_launch_trial.h" 15 #include "chrome/browser/auto_launch_trial.h"
20 #include "chrome/browser/google/google_util.h" 16 #include "chrome/browser/google/google_util.h"
21 #include "chrome/browser/gpu/chrome_gpu_util.h" 17 #include "chrome/browser/gpu/chrome_gpu_util.h"
22 #include "chrome/browser/omnibox/omnibox_field_trial.h" 18 #include "chrome/browser/omnibox/omnibox_field_trial.h"
23 #include "chrome/browser/prerender/prerender_field_trial.h" 19 #include "chrome/browser/prerender/prerender_field_trial.h"
24 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 21 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
26 #include "chrome/browser/ui/sync/one_click_signin_helper.h" 22 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
27 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/chrome_version_info.h" 24 #include "chrome/common/chrome_version_info.h"
29 #include "chrome/common/metrics/variations/uniformity_field_trials.h"
30 #include "chrome/common/metrics/variations/variations_util.h" 25 #include "chrome/common/metrics/variations/variations_util.h"
31 #include "chrome/common/pref_names.h"
32 #include "net/spdy/spdy_session.h" 26 #include "net/spdy/spdy_session.h"
33 #include "ui/base/layout.h" 27 #include "ui/base/layout.h"
34 28
35 #if defined(OS_WIN) 29 #if defined(OS_WIN)
36 #include "net/socket/tcp_client_socket_win.h" 30 #include "net/socket/tcp_client_socket_win.h"
37 #endif // defined(OS_WIN) 31 #endif // defined(OS_WIN)
38 32
39 ChromeBrowserFieldTrials::ChromeBrowserFieldTrials( 33 namespace chrome {
40 const CommandLine& parsed_command_line)
41 : parsed_command_line_(parsed_command_line) {
42 }
43 34
44 ChromeBrowserFieldTrials::~ChromeBrowserFieldTrials() { 35 namespace {
45 }
46 36
47 void ChromeBrowserFieldTrials::SetupFieldTrials(PrefService* local_state) { 37 void SetupAppLauncherFieldTrial(PrefService* local_state) {
48 const base::Time install_time = base::Time::FromTimeT(
49 local_state->GetInt64(prefs::kInstallDate));
50 DCHECK(!install_time.is_null());
51
52 chrome_variations::SetupUniformityFieldTrials(install_time);
53 SetUpSimpleCacheFieldTrial();
54
55 #if !defined(OS_ANDROID) && !defined(OS_IOS)
56 SetupDesktopFieldTrials(local_state);
57 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
58
59 #if defined(OS_ANDROID) || defined(OS_IOS)
60 SetupMobileFieldTrials();
61 #endif // defined(OS_ANDROID) || defined(OS_IOS)
62
63 InstantiateDynamicTrials();
64 }
65
66
67 #if defined(OS_ANDROID) || defined(OS_IOS)
68 void ChromeBrowserFieldTrials::SetupMobileFieldTrials() {
69 DataCompressionProxyFieldTrial();
70 }
71
72 // Governs the rollout of the compression proxy for Chrome on mobile platforms.
73 // Always enabled in DEV and BETA versions.
74 // Stable percentage will be controlled from server.
75 void ChromeBrowserFieldTrials::DataCompressionProxyFieldTrial() {
76 const char kDataCompressionProxyFieldTrialName[] =
77 "DataCompressionProxyRollout";
78 const base::FieldTrial::Probability kDataCompressionProxyDivisor = 1000;
79
80 // 10/1000 = 1% for starters.
81 const base::FieldTrial::Probability kDataCompressionProxyStable = 10;
82 const char kEnabled[] = "Enabled";
83 const char kDisabled[] = "Disabled";
84
85 // Find out if this is a stable channel.
86 const bool kIsStableChannel =
87 chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE;
88
89 // Experiment enabled until Jan 1, 2015. By default, disabled.
90 scoped_refptr<base::FieldTrial> trial(
91 base::FieldTrialList::FactoryGetFieldTrial(
92 kDataCompressionProxyFieldTrialName, kDataCompressionProxyDivisor,
93 kDisabled, 2015, 1, 1, NULL));
94
95 // We want our trial results to be persistent.
96 trial->UseOneTimeRandomization();
97 // Non-stable channels will run with probability 1.
98 const int kEnabledGroup = trial->AppendGroup(
99 kEnabled,
100 kIsStableChannel ?
101 kDataCompressionProxyStable : kDataCompressionProxyDivisor);
102
103 const int v = trial->group();
104 VLOG(1) << "DataCompression proxy enabled group id: " << kEnabledGroup
105 << ". Selected group id: " << v;
106 }
107 #endif // defined(OS_ANDROID) || defined(OS_IOS)
108
109 void ChromeBrowserFieldTrials::SetupDesktopFieldTrials(
110 PrefService* local_state) {
111 prerender::ConfigurePrefetchAndPrerender(parsed_command_line_);
112 SpdyFieldTrial();
113 AutoLaunchChromeFieldTrial();
114 gpu_util::InitializeCompositingFieldTrial();
115 OmniboxFieldTrial::ActivateStaticTrials();
116 SetUpInfiniteCacheFieldTrial();
117 SetUpCacheSensitivityAnalysisFieldTrial();
118 DisableShowProfileSwitcherTrialIfNecessary();
119 WindowsOverlappedTCPReadsFieldTrial();
120 #if defined(ENABLE_ONE_CLICK_SIGNIN)
121 OneClickSigninHelper::InitializeFieldTrial();
122 #endif
123 SetupAppLauncherFieldTrial(local_state);
124 }
125
126 void ChromeBrowserFieldTrials::SetupAppLauncherFieldTrial(
127 PrefService* local_state) {
128 if (base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName) == 38 if (base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName) ==
129 apps::kResetShowLauncherPromoPrefGroupName) { 39 apps::kResetShowLauncherPromoPrefGroupName) {
130 local_state->SetBoolean(apps::prefs::kShowAppLauncherPromo, true); 40 local_state->SetBoolean(apps::prefs::kShowAppLauncherPromo, true);
131 } 41 }
132 } 42 }
133 43
134 // When --use-spdy not set, users will be in A/B test for spdy. 44 // When --use-spdy not set, users will be in A/B test for spdy.
135 // group A (npn_with_spdy): this means npn and spdy are enabled. In case server 45 // group A (npn_with_spdy): this means npn and spdy are enabled. In case server
136 // supports spdy, browser will use spdy. 46 // supports spdy, browser will use spdy.
137 // group B (npn_with_http): this means npn is enabled but spdy won't be used. 47 // group B (npn_with_http): this means npn is enabled but spdy won't be used.
138 // Http is still used for all requests. 48 // Http is still used for all requests.
139 // default group: no npn or spdy is involved. The "old" non-spdy 49 // default group: no npn or spdy is involved. The "old" non-spdy
140 // chrome behavior. 50 // chrome behavior.
141 void ChromeBrowserFieldTrials::SpdyFieldTrial() { 51 void SpdyFieldTrial() {
142 // Setup SPDY CWND Field trial. 52 // Setup SPDY CWND Field trial.
143 const base::FieldTrial::Probability kSpdyCwndDivisor = 100; 53 const base::FieldTrial::Probability kSpdyCwndDivisor = 100;
144 const base::FieldTrial::Probability kSpdyCwnd16 = 20; // fixed at 16 54 const base::FieldTrial::Probability kSpdyCwnd16 = 20; // fixed at 16
145 const base::FieldTrial::Probability kSpdyCwnd10 = 20; // fixed at 10 55 const base::FieldTrial::Probability kSpdyCwnd10 = 20; // fixed at 10
146 const base::FieldTrial::Probability kSpdyCwndMin16 = 20; // no less than 16 56 const base::FieldTrial::Probability kSpdyCwndMin16 = 20; // no less than 16
147 const base::FieldTrial::Probability kSpdyCwndMin10 = 20; // no less than 10 57 const base::FieldTrial::Probability kSpdyCwndMin10 = 20; // no less than 10
148 58
149 // After June 30, 2013 builds, it will always be in default group 59 // After June 30, 2013 builds, it will always be in default group
150 // (cwndDynamic). 60 // (cwndDynamic).
151 scoped_refptr<base::FieldTrial> trial( 61 scoped_refptr<base::FieldTrial> trial(
152 base::FieldTrialList::FactoryGetFieldTrial( 62 base::FieldTrialList::FactoryGetFieldTrial(
153 "SpdyCwnd", kSpdyCwndDivisor, "cwndDynamic", 2013, 6, 30, NULL)); 63 "SpdyCwnd", kSpdyCwndDivisor, "cwndDynamic", 2013, 6, 30, NULL));
154 64
155 trial->AppendGroup("cwnd10", kSpdyCwnd10); 65 trial->AppendGroup("cwnd10", kSpdyCwnd10);
156 trial->AppendGroup("cwnd16", kSpdyCwnd16); 66 trial->AppendGroup("cwnd16", kSpdyCwnd16);
157 trial->AppendGroup("cwndMin16", kSpdyCwndMin16); 67 trial->AppendGroup("cwndMin16", kSpdyCwndMin16);
158 trial->AppendGroup("cwndMin10", kSpdyCwndMin10); 68 trial->AppendGroup("cwndMin10", kSpdyCwndMin10);
159 } 69 }
160 70
161 void ChromeBrowserFieldTrials::AutoLaunchChromeFieldTrial() { 71 void AutoLaunchChromeFieldTrial() {
162 std::string brand; 72 std::string brand;
163 google_util::GetBrand(&brand); 73 google_util::GetBrand(&brand);
164 74
165 // Create a 100% field trial based on the brand code. 75 // Create a 100% field trial based on the brand code.
166 if (auto_launch_trial::IsInExperimentGroup(brand)) { 76 if (auto_launch_trial::IsInExperimentGroup(brand)) {
167 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName, 77 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
168 kAutoLaunchTrialAutoLaunchGroup); 78 kAutoLaunchTrialAutoLaunchGroup);
169 } else if (auto_launch_trial::IsInControlGroup(brand)) { 79 } else if (auto_launch_trial::IsInControlGroup(brand)) {
170 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName, 80 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
171 kAutoLaunchTrialControlGroup); 81 kAutoLaunchTrialControlGroup);
172 } 82 }
173 } 83 }
174 84
175 void ChromeBrowserFieldTrials::SetUpInfiniteCacheFieldTrial() { 85 void SetUpInfiniteCacheFieldTrial() {
176 const base::FieldTrial::Probability kDivisor = 100; 86 const base::FieldTrial::Probability kDivisor = 100;
177 87
178 base::FieldTrial::Probability infinite_cache_probability = 0; 88 base::FieldTrial::Probability infinite_cache_probability = 0;
179 89
180 scoped_refptr<base::FieldTrial> trial( 90 scoped_refptr<base::FieldTrial> trial(
181 base::FieldTrialList::FactoryGetFieldTrial("InfiniteCache", kDivisor, 91 base::FieldTrialList::FactoryGetFieldTrial("InfiniteCache", kDivisor,
182 "No", 2013, 12, 31, NULL)); 92 "No", 2013, 12, 31, NULL));
183 trial->UseOneTimeRandomization(); 93 trial->UseOneTimeRandomization();
184 trial->AppendGroup("Yes", infinite_cache_probability); 94 trial->AppendGroup("Yes", infinite_cache_probability);
185 trial->AppendGroup("Control", infinite_cache_probability); 95 trial->AppendGroup("Control", infinite_cache_probability);
186 } 96 }
187 97
188 void ChromeBrowserFieldTrials::DisableShowProfileSwitcherTrialIfNecessary() { 98 void DisableShowProfileSwitcherTrialIfNecessary() {
189 // This trial is created by the VariationsService, but it needs to be disabled 99 // This trial is created by the VariationsService, but it needs to be disabled
190 // if multi-profiles isn't enabled or if browser frame avatar menu is 100 // if multi-profiles isn't enabled or if browser frame avatar menu is
191 // always hidden (Chrome OS). 101 // always hidden (Chrome OS).
192 bool avatar_menu_always_hidden = false; 102 bool avatar_menu_always_hidden = false;
193 #if defined(OS_CHROMEOS) 103 #if defined(OS_CHROMEOS)
194 avatar_menu_always_hidden = true; 104 avatar_menu_always_hidden = true;
195 #endif 105 #endif
196 base::FieldTrial* trial = base::FieldTrialList::Find("ShowProfileSwitcher"); 106 base::FieldTrial* trial = base::FieldTrialList::Find("ShowProfileSwitcher");
197 if (trial && (!ProfileManager::IsMultipleProfilesEnabled() || 107 if (trial && (!ProfileManager::IsMultipleProfilesEnabled() ||
198 avatar_menu_always_hidden)) { 108 avatar_menu_always_hidden)) {
199 trial->Disable(); 109 trial->Disable();
200 } 110 }
201 } 111 }
202 112
203 // Sets up the experiment. The actual cache backend choice is made in the net/ 113 void SetUpCacheSensitivityAnalysisFieldTrial() {
204 // internals by looking at the experiment state.
205 void ChromeBrowserFieldTrials::SetUpSimpleCacheFieldTrial() {
206 if (parsed_command_line_.HasSwitch(switches::kUseSimpleCacheBackend)) {
207 const std::string opt_value = parsed_command_line_.GetSwitchValueASCII(
208 switches::kUseSimpleCacheBackend);
209 const base::FieldTrial::Probability kDivisor = 100;
210 scoped_refptr<base::FieldTrial> trial(
211 base::FieldTrialList::FactoryGetFieldTrial("SimpleCacheTrial", kDivisor,
212 "ExperimentNo", 2013, 12, 31,
213 NULL));
214 trial->UseOneTimeRandomization();
215 if (LowerCaseEqualsASCII(opt_value, "off")) {
216 trial->AppendGroup("ExplicitNo", kDivisor);
217 return;
218 }
219 if (LowerCaseEqualsASCII(opt_value, "on")) {
220 trial->AppendGroup("ExplicitYes", kDivisor);
221 return;
222 }
223 #if defined(OS_ANDROID)
224 if (LowerCaseEqualsASCII(opt_value, "experiment")) {
225 // TODO(pasko): Make this the default on Android when the simple cache
226 // adds a few more necessary features. Also adjust the probability.
227 const base::FieldTrial::Probability kSimpleCacheProbability = 1;
228 trial->AppendGroup("ExperimentYes", kSimpleCacheProbability);
229 trial->AppendGroup("ExperimentControl", kSimpleCacheProbability);
230 trial->group();
231 }
232 #endif
233 }
234 }
235
236 void ChromeBrowserFieldTrials::SetUpCacheSensitivityAnalysisFieldTrial() {
237 const base::FieldTrial::Probability kDivisor = 100; 114 const base::FieldTrial::Probability kDivisor = 100;
238 115
239 base::FieldTrial::Probability sensitivity_analysis_probability = 0; 116 base::FieldTrial::Probability sensitivity_analysis_probability = 0;
240 117
241 #if defined(OS_ANDROID) 118 #if defined(OS_ANDROID)
242 switch (chrome::VersionInfo::GetChannel()) { 119 switch (chrome::VersionInfo::GetChannel()) {
243 case chrome::VersionInfo::CHANNEL_DEV: 120 case chrome::VersionInfo::CHANNEL_DEV:
244 sensitivity_analysis_probability = 10; 121 sensitivity_analysis_probability = 10;
245 break; 122 break;
246 case chrome::VersionInfo::CHANNEL_BETA: 123 case chrome::VersionInfo::CHANNEL_BETA:
(...skipping 13 matching lines...) Expand all
260 2013, 06, 15, NULL)); 137 2013, 06, 15, NULL));
261 trial->AppendGroup("ControlA", sensitivity_analysis_probability); 138 trial->AppendGroup("ControlA", sensitivity_analysis_probability);
262 trial->AppendGroup("ControlB", sensitivity_analysis_probability); 139 trial->AppendGroup("ControlB", sensitivity_analysis_probability);
263 trial->AppendGroup("100A", sensitivity_analysis_probability); 140 trial->AppendGroup("100A", sensitivity_analysis_probability);
264 trial->AppendGroup("100B", sensitivity_analysis_probability); 141 trial->AppendGroup("100B", sensitivity_analysis_probability);
265 trial->AppendGroup("200A", sensitivity_analysis_probability); 142 trial->AppendGroup("200A", sensitivity_analysis_probability);
266 trial->AppendGroup("200B", sensitivity_analysis_probability); 143 trial->AppendGroup("200B", sensitivity_analysis_probability);
267 // TODO(gavinp,rvargas): Re-add 400 group to field trial if results justify. 144 // TODO(gavinp,rvargas): Re-add 400 group to field trial if results justify.
268 } 145 }
269 146
270 void ChromeBrowserFieldTrials::WindowsOverlappedTCPReadsFieldTrial() { 147 void WindowsOverlappedTCPReadsFieldTrial(
148 const CommandLine& parsed_command_line) {
271 #if defined(OS_WIN) 149 #if defined(OS_WIN)
272 if (parsed_command_line_.HasSwitch(switches::kOverlappedRead)) { 150 if (parsed_command_line.HasSwitch(switches::kOverlappedRead)) {
273 std::string option = 151 std::string option =
274 parsed_command_line_.GetSwitchValueASCII(switches::kOverlappedRead); 152 parsed_command_line.GetSwitchValueASCII(switches::kOverlappedRead);
275 if (LowerCaseEqualsASCII(option, "off")) 153 if (LowerCaseEqualsASCII(option, "off"))
276 net::TCPClientSocketWin::DisableOverlappedReads(); 154 net::TCPClientSocketWin::DisableOverlappedReads();
277 } else { 155 } else {
278 const base::FieldTrial::Probability kDivisor = 2; // 1 in 2 chance 156 const base::FieldTrial::Probability kDivisor = 2; // 1 in 2 chance
279 const base::FieldTrial::Probability kOverlappedReadProbability = 1; 157 const base::FieldTrial::Probability kOverlappedReadProbability = 1;
280 scoped_refptr<base::FieldTrial> overlapped_reads_trial( 158 scoped_refptr<base::FieldTrial> overlapped_reads_trial(
281 base::FieldTrialList::FactoryGetFieldTrial("OverlappedReadImpact", 159 base::FieldTrialList::FactoryGetFieldTrial("OverlappedReadImpact",
282 kDivisor, "OverlappedReadEnabled", 2013, 6, 1, NULL)); 160 kDivisor, "OverlappedReadEnabled", 2013, 6, 1, NULL));
283 int overlapped_reads_disabled_group = 161 int overlapped_reads_disabled_group =
284 overlapped_reads_trial->AppendGroup("OverlappedReadDisabled", 162 overlapped_reads_trial->AppendGroup("OverlappedReadDisabled",
285 kOverlappedReadProbability); 163 kOverlappedReadProbability);
286 int assigned_group = overlapped_reads_trial->group(); 164 int assigned_group = overlapped_reads_trial->group();
287 if (assigned_group == overlapped_reads_disabled_group) 165 if (assigned_group == overlapped_reads_disabled_group)
288 net::TCPClientSocketWin::DisableOverlappedReads(); 166 net::TCPClientSocketWin::DisableOverlappedReads();
289 } 167 }
290 #endif 168 #endif
291 } 169 }
292 170
293 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { 171 } // namespace
294 // Call |FindValue()| on the trials below, which may come from the server, to 172
295 // ensure they get marked as "used" for the purposes of data reporting. 173 void SetupDesktopFieldTrials(const CommandLine& parsed_command_line,
296 base::FieldTrialList::FindValue("UMA-Dynamic-Binary-Uniformity-Trial"); 174 const base::Time& install_time,
297 base::FieldTrialList::FindValue("UMA-Dynamic-Uniformity-Trial"); 175 PrefService* local_state) {
298 base::FieldTrialList::FindValue("InstantDummy"); 176 prerender::ConfigurePrefetchAndPrerender(parsed_command_line);
299 base::FieldTrialList::FindValue("InstantChannel"); 177 SpdyFieldTrial();
300 base::FieldTrialList::FindValue("Test0PercentDefault"); 178 AutoLaunchChromeFieldTrial();
301 // Activate the autocomplete dynamic field trials. 179 gpu_util::InitializeCompositingFieldTrial();
302 OmniboxFieldTrial::ActivateDynamicTrials(); 180 OmniboxFieldTrial::ActivateStaticTrials();
181 SetUpInfiniteCacheFieldTrial();
182 SetUpCacheSensitivityAnalysisFieldTrial();
183 DisableShowProfileSwitcherTrialIfNecessary();
184 WindowsOverlappedTCPReadsFieldTrial(parsed_command_line);
185 #if defined(ENABLE_ONE_CLICK_SIGNIN)
186 OneClickSigninHelper::InitializeFieldTrial();
187 #endif
188 SetupAppLauncherFieldTrial(local_state);
303 } 189 }
190
191 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698