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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #endif | 24 #endif |
25 | 25 |
26 ChromeBrowserFieldTrials::ChromeBrowserFieldTrials( | 26 ChromeBrowserFieldTrials::ChromeBrowserFieldTrials( |
27 const CommandLine& parsed_command_line) | 27 const CommandLine& parsed_command_line) |
28 : parsed_command_line_(parsed_command_line) { | 28 : parsed_command_line_(parsed_command_line) { |
29 } | 29 } |
30 | 30 |
31 ChromeBrowserFieldTrials::~ChromeBrowserFieldTrials() { | 31 ChromeBrowserFieldTrials::~ChromeBrowserFieldTrials() { |
32 } | 32 } |
33 | 33 |
| 34 namespace { |
| 35 |
| 36 // Base function used by all data reduction proxy field trials. A trial is |
| 37 // only conducted for installs that are in the "Enabled" group. They are always |
| 38 // enabled on DEV and BETA channels, and for STABLE, a percentage will be |
| 39 // controlled from the server. Until the percentage is learned from the server, |
| 40 // a client-side configuration is used. |
| 41 void DataCompressionProxyBaseFieldTrial( |
| 42 const char* trial_name, |
| 43 const base::FieldTrial::Probability enabled_group_probability, |
| 44 const base::FieldTrial::Probability total_probability) { |
| 45 const char kEnabled[] = "Enabled"; |
| 46 const char kDisabled[] = "Disabled"; |
| 47 |
| 48 // Find out if this is a stable channel. |
| 49 const bool kIsStableChannel = |
| 50 chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE; |
| 51 |
| 52 // Experiment enabled until Jan 1, 2020. By default, disabled. |
| 53 scoped_refptr<base::FieldTrial> trial( |
| 54 base::FieldTrialList::FactoryGetFieldTrial( |
| 55 trial_name, |
| 56 total_probability, |
| 57 kDisabled, 2020, 1, 1, base::FieldTrial::ONE_TIME_RANDOMIZED, NULL)); |
| 58 |
| 59 // Non-stable channels will run with probability 1. |
| 60 const int kEnabledGroup = trial->AppendGroup( |
| 61 kEnabled, |
| 62 kIsStableChannel ? enabled_group_probability : total_probability); |
| 63 |
| 64 const int v = trial->group(); |
| 65 VLOG(1) << trial_name << " enabled group id: " << kEnabledGroup |
| 66 << ". Selected group id: " << v; |
| 67 } |
| 68 |
| 69 void DataCompressionProxyFieldTrials() { |
| 70 // Governs the rollout of the compression proxy for Chrome on all platforms. |
| 71 // In all channels, the percentage will be controlled from the server, and is |
| 72 // configured to be 100% = 1000 / 1000 until overridden by the server. |
| 73 DataCompressionProxyBaseFieldTrial( |
| 74 "DataCompressionProxyRollout", 1000, 1000); |
| 75 |
| 76 // Governs the rollout of the _promo_ for the compression proxy |
| 77 // independently from the rollout of compression proxy. The enabled |
| 78 // percentage is configured to be 10% = 100 / 1000 until overridden by the |
| 79 // server. When this trial is "Enabled," users get a promo, whereas |
| 80 // otherwise, compression is available without a promo. |
| 81 DataCompressionProxyBaseFieldTrial( |
| 82 "DataCompressionProxyPromoVisibility", 100, 1000); |
| 83 } |
| 84 |
| 85 } // namespace |
| 86 |
34 void ChromeBrowserFieldTrials::SetupFieldTrials(const base::Time& install_time, | 87 void ChromeBrowserFieldTrials::SetupFieldTrials(const base::Time& install_time, |
35 PrefService* local_state) { | 88 PrefService* local_state) { |
36 DCHECK(!install_time.is_null()); | 89 DCHECK(!install_time.is_null()); |
37 | 90 |
38 // Field trials that are shared by all platforms. | 91 // Field trials that are shared by all platforms. |
39 chrome_variations::SetupUniformityFieldTrials(install_time); | 92 chrome_variations::SetupUniformityFieldTrials(install_time); |
40 InstantiateDynamicTrials(); | 93 InstantiateDynamicTrials(); |
| 94 DataCompressionProxyFieldTrials(); |
41 | 95 |
42 #if defined(OS_ANDROID) || defined(OS_IOS) | 96 #if defined(OS_ANDROID) || defined(OS_IOS) |
43 chrome::SetupMobileFieldTrials(parsed_command_line_); | 97 chrome::SetupMobileFieldTrials(parsed_command_line_); |
44 #else | 98 #else |
45 chrome::SetupDesktopFieldTrials( | 99 chrome::SetupDesktopFieldTrials( |
46 parsed_command_line_, local_state); | 100 parsed_command_line_, local_state); |
47 #endif | 101 #endif |
48 } | 102 } |
49 | 103 |
50 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { | 104 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { |
51 // Call |FindValue()| on the trials below, which may come from the server, to | 105 // Call |FindValue()| on the trials below, which may come from the server, to |
52 // ensure they get marked as "used" for the purposes of data reporting. | 106 // ensure they get marked as "used" for the purposes of data reporting. |
53 base::FieldTrialList::FindValue("UMA-Dynamic-Binary-Uniformity-Trial"); | 107 base::FieldTrialList::FindValue("UMA-Dynamic-Binary-Uniformity-Trial"); |
54 base::FieldTrialList::FindValue("UMA-Dynamic-Uniformity-Trial"); | 108 base::FieldTrialList::FindValue("UMA-Dynamic-Uniformity-Trial"); |
55 base::FieldTrialList::FindValue("InstantDummy"); | 109 base::FieldTrialList::FindValue("InstantDummy"); |
56 base::FieldTrialList::FindValue("InstantChannel"); | 110 base::FieldTrialList::FindValue("InstantChannel"); |
57 base::FieldTrialList::FindValue("Test0PercentDefault"); | 111 base::FieldTrialList::FindValue("Test0PercentDefault"); |
58 // The following trials are used from renderer process. | 112 // The following trials are used from renderer process. |
59 // Mark here so they will be sync-ed. | 113 // Mark here so they will be sync-ed. |
60 base::FieldTrialList::FindValue("CLD1VsCLD2"); | 114 base::FieldTrialList::FindValue("CLD1VsCLD2"); |
61 base::FieldTrialList::FindValue("MouseEventPreconnect"); | 115 base::FieldTrialList::FindValue("MouseEventPreconnect"); |
62 base::FieldTrialList::FindValue("UnauthorizedPluginInfoBar"); | 116 base::FieldTrialList::FindValue("UnauthorizedPluginInfoBar"); |
63 // Activate the autocomplete dynamic field trials. | 117 // Activate the autocomplete dynamic field trials. |
64 OmniboxFieldTrial::ActivateDynamicTrials(); | 118 OmniboxFieldTrial::ActivateDynamicTrials(); |
65 } | 119 } |
OLD | NEW |