Prevent chrome://net-internals/#export from flickering
[chromium-blink-merge.git] / chrome / browser / chrome_browser_field_trials_mobile.cc
bloba3caf4f24205a6c720b4a6097de7d4d697707ae2
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
3 // found in the LICENSE file.
5 #include "chrome/browser/chrome_browser_field_trials_mobile.h"
7 #include <string>
9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h"
11 #include "base/prefs/pref_service.h"
12 #include "base/tracked_objects.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/chrome_version_info.h"
16 #if defined(OS_ANDROID)
17 #include "chrome/browser/prerender/prerender_field_trial.h"
18 #endif
20 namespace chrome {
22 namespace {
24 // Base function used by all data reduction proxy field trials. A trial is
25 // only conducted for installs that are in the "Enabled" group. They are always
26 // enabled on DEV and BETA channels, and for STABLE, a percentage will be
27 // controlled from the server. Until the percentage is learned from the server,
28 // a client-side configuration is used.
29 void DataCompressionProxyBaseFieldTrial(
30 const char* trial_name,
31 const base::FieldTrial::Probability enabled_group_probability,
32 const base::FieldTrial::Probability total_probability) {
33 const char kEnabled[] = "Enabled";
34 const char kDisabled[] = "Disabled";
36 // Find out if this is a stable channel.
37 const bool kIsStableChannel =
38 chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE;
40 // Experiment enabled until Jan 1, 2015. By default, disabled.
41 scoped_refptr<base::FieldTrial> trial(
42 base::FieldTrialList::FactoryGetFieldTrial(
43 trial_name,
44 total_probability,
45 kDisabled, 2015, 1, 1, base::FieldTrial::ONE_TIME_RANDOMIZED, NULL));
47 // Non-stable channels will run with probability 1.
48 trial->AppendGroup(
49 kEnabled,
50 kIsStableChannel ? enabled_group_probability : total_probability);
52 trial->group();
55 void SetupDataCompressionProxyFieldTrials() {
56 // Governs the rollout of the _promo_ for the compression proxy
57 // independently from the rollout of compression proxy. The enabled
58 // percentage is configured to be 10% = 100 / 1000 until overridden by the
59 // server. When this trial is "Enabled," users get a promo, whereas
60 // otherwise, compression is available without a promo.
61 DataCompressionProxyBaseFieldTrial(
62 "DataCompressionProxyPromoVisibility", 100, 1000);
65 } // namespace
67 void SetupMobileFieldTrials(const base::CommandLine& parsed_command_line) {
68 SetupDataCompressionProxyFieldTrials();
69 #if defined(OS_ANDROID)
70 prerender::ConfigurePrerender(parsed_command_line);
72 // Force-enable profiler timing depending on the field trial.
73 if (base::FieldTrialList::FindFullName("ProfilerTiming") == "Enable")
74 tracked_objects::ThreadData::EnableProfilerTiming();
75 #endif
78 } // namespace chrome