Split the field trial setup code into desktop and mobile files.

BUG=233551
TEST=No visible impact.

Review URL: https://chromiumcodereview.appspot.com/14247021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195654 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/OWNERS b/chrome/browser/OWNERS
index bea9e666..e66ca4d 100644
--- a/chrome/browser/OWNERS
+++ b/chrome/browser/OWNERS
@@ -5,7 +5,7 @@
 per-file chrome_content_browser_client.cc=*
 per-file chrome_content_browser_client.h=*
 
-per-file chrome_browser_field_trials.*[email protected]
-per-file chrome_browser_field_trials.*[email protected]
+per-file chrome_browser_field_trials*[email protected]
+per-file chrome_browser_field_trials*[email protected]
 
 per-file enumerate_modules_model*[email protected]
\ No newline at end of file
diff --git a/chrome/browser/chrome_browser_field_trials.cc b/chrome/browser/chrome_browser_field_trials.cc
index 700f38d..6122086 100644
--- a/chrome/browser/chrome_browser_field_trials.cc
+++ b/chrome/browser/chrome_browser_field_trials.cc
@@ -6,35 +6,21 @@
 
 #include <string>
 
-#include "apps/field_trial_names.h"
-#include "apps/pref_names.h"
 #include "base/command_line.h"
 #include "base/metrics/field_trial.h"
 #include "base/prefs/pref_service.h"
 #include "base/string_util.h"
-#include "base/stringprintf.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/sys_string_conversions.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/auto_launch_trial.h"
-#include "chrome/browser/google/google_util.h"
-#include "chrome/browser/gpu/chrome_gpu_util.h"
+#include "base/time.h"
 #include "chrome/browser/omnibox/omnibox_field_trial.h"
-#include "chrome/browser/prerender/prerender_field_trial.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
-#include "chrome/browser/ui/sync/one_click_signin_helper.h"
 #include "chrome/common/chrome_switches.h"
-#include "chrome/common/chrome_version_info.h"
 #include "chrome/common/metrics/variations/uniformity_field_trials.h"
-#include "chrome/common/metrics/variations/variations_util.h"
 #include "chrome/common/pref_names.h"
-#include "net/spdy/spdy_session.h"
-#include "ui/base/layout.h"
 
-#if defined(OS_WIN)
-#include "net/socket/tcp_client_socket_win.h"
-#endif  // defined(OS_WIN)
+#if defined(OS_ANDROID) || defined(OS_IOS)
+#include "chrome/browser/chrome_browser_field_trials_mobile.h"
+#else
+#include "chrome/browser/chrome_browser_field_trials_desktop.h"
+#endif
 
 ChromeBrowserFieldTrials::ChromeBrowserFieldTrials(
     const CommandLine& parsed_command_line)
@@ -49,155 +35,18 @@
       local_state->GetInt64(prefs::kInstallDate));
   DCHECK(!install_time.is_null());
 
+  // Field trials that are shared by all platforms.
   chrome_variations::SetupUniformityFieldTrials(install_time);
   SetUpSimpleCacheFieldTrial();
-
-#if !defined(OS_ANDROID) && !defined(OS_IOS)
-  SetupDesktopFieldTrials(local_state);
-#endif  // !defined(OS_ANDROID) && !defined(OS_IOS)
-
-#if defined(OS_ANDROID) || defined(OS_IOS)
-  SetupMobileFieldTrials();
-#endif  // defined(OS_ANDROID) || defined(OS_IOS)
-
   InstantiateDynamicTrials();
-}
-
 
 #if defined(OS_ANDROID) || defined(OS_IOS)
-void ChromeBrowserFieldTrials::SetupMobileFieldTrials() {
-  DataCompressionProxyFieldTrial();
-}
-
-// Governs the rollout of the compression proxy for Chrome on mobile platforms.
-// Always enabled in DEV and BETA versions.
-// Stable percentage will be controlled from server.
-void ChromeBrowserFieldTrials::DataCompressionProxyFieldTrial() {
-  const char kDataCompressionProxyFieldTrialName[] =
-      "DataCompressionProxyRollout";
-  const base::FieldTrial::Probability kDataCompressionProxyDivisor = 1000;
-
-  // 10/1000 = 1% for starters.
-  const base::FieldTrial::Probability kDataCompressionProxyStable = 10;
-  const char kEnabled[] = "Enabled";
-  const char kDisabled[] = "Disabled";
-
-  // Find out if this is a stable channel.
-  const bool kIsStableChannel =
-      chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE;
-
-  // Experiment enabled until Jan 1, 2015. By default, disabled.
-  scoped_refptr<base::FieldTrial> trial(
-      base::FieldTrialList::FactoryGetFieldTrial(
-          kDataCompressionProxyFieldTrialName, kDataCompressionProxyDivisor,
-          kDisabled, 2015, 1, 1, NULL));
-
-  // We want our trial results to be persistent.
-  trial->UseOneTimeRandomization();
-  // Non-stable channels will run with probability 1.
-  const int kEnabledGroup = trial->AppendGroup(
-      kEnabled,
-      kIsStableChannel ?
-          kDataCompressionProxyStable : kDataCompressionProxyDivisor);
-
-  const int v = trial->group();
-  VLOG(1) << "DataCompression proxy enabled group id: " << kEnabledGroup
-          << ". Selected group id: " << v;
-}
-#endif  // defined(OS_ANDROID) || defined(OS_IOS)
-
-void ChromeBrowserFieldTrials::SetupDesktopFieldTrials(
-    PrefService* local_state) {
-  prerender::ConfigurePrefetchAndPrerender(parsed_command_line_);
-  SpdyFieldTrial();
-  AutoLaunchChromeFieldTrial();
-  gpu_util::InitializeCompositingFieldTrial();
-  OmniboxFieldTrial::ActivateStaticTrials();
-  SetUpInfiniteCacheFieldTrial();
-  SetUpCacheSensitivityAnalysisFieldTrial();
-  DisableShowProfileSwitcherTrialIfNecessary();
-  WindowsOverlappedTCPReadsFieldTrial();
-#if defined(ENABLE_ONE_CLICK_SIGNIN)
-  OneClickSigninHelper::InitializeFieldTrial();
+  chrome::SetupMobileFieldTrials(
+      parsed_command_line_, install_time, local_state);
+#else
+  chrome::SetupDesktopFieldTrials(
+      parsed_command_line_, install_time, local_state);
 #endif
-  SetupAppLauncherFieldTrial(local_state);
-}
-
-void ChromeBrowserFieldTrials::SetupAppLauncherFieldTrial(
-    PrefService* local_state) {
-  if (base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName) ==
-      apps::kResetShowLauncherPromoPrefGroupName) {
-    local_state->SetBoolean(apps::prefs::kShowAppLauncherPromo, true);
-  }
-}
-
-// When --use-spdy not set, users will be in A/B test for spdy.
-// group A (npn_with_spdy): this means npn and spdy are enabled. In case server
-//                          supports spdy, browser will use spdy.
-// group B (npn_with_http): this means npn is enabled but spdy won't be used.
-//                          Http is still used for all requests.
-//           default group: no npn or spdy is involved. The "old" non-spdy
-//                          chrome behavior.
-void ChromeBrowserFieldTrials::SpdyFieldTrial() {
-  // Setup SPDY CWND Field trial.
-  const base::FieldTrial::Probability kSpdyCwndDivisor = 100;
-  const base::FieldTrial::Probability kSpdyCwnd16 = 20;     // fixed at 16
-  const base::FieldTrial::Probability kSpdyCwnd10 = 20;     // fixed at 10
-  const base::FieldTrial::Probability kSpdyCwndMin16 = 20;  // no less than 16
-  const base::FieldTrial::Probability kSpdyCwndMin10 = 20;  // no less than 10
-
-  // After June 30, 2013 builds, it will always be in default group
-  // (cwndDynamic).
-  scoped_refptr<base::FieldTrial> trial(
-      base::FieldTrialList::FactoryGetFieldTrial(
-          "SpdyCwnd", kSpdyCwndDivisor, "cwndDynamic", 2013, 6, 30, NULL));
-
-  trial->AppendGroup("cwnd10", kSpdyCwnd10);
-  trial->AppendGroup("cwnd16", kSpdyCwnd16);
-  trial->AppendGroup("cwndMin16", kSpdyCwndMin16);
-  trial->AppendGroup("cwndMin10", kSpdyCwndMin10);
-}
-
-void ChromeBrowserFieldTrials::AutoLaunchChromeFieldTrial() {
-  std::string brand;
-  google_util::GetBrand(&brand);
-
-  // Create a 100% field trial based on the brand code.
-  if (auto_launch_trial::IsInExperimentGroup(brand)) {
-    base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
-                                           kAutoLaunchTrialAutoLaunchGroup);
-  } else if (auto_launch_trial::IsInControlGroup(brand)) {
-    base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
-                                           kAutoLaunchTrialControlGroup);
-  }
-}
-
-void ChromeBrowserFieldTrials::SetUpInfiniteCacheFieldTrial() {
-  const base::FieldTrial::Probability kDivisor = 100;
-
-  base::FieldTrial::Probability infinite_cache_probability = 0;
-
-  scoped_refptr<base::FieldTrial> trial(
-      base::FieldTrialList::FactoryGetFieldTrial("InfiniteCache", kDivisor,
-                                                 "No", 2013, 12, 31, NULL));
-  trial->UseOneTimeRandomization();
-  trial->AppendGroup("Yes", infinite_cache_probability);
-  trial->AppendGroup("Control", infinite_cache_probability);
-}
-
-void ChromeBrowserFieldTrials::DisableShowProfileSwitcherTrialIfNecessary() {
-  // This trial is created by the VariationsService, but it needs to be disabled
-  // if multi-profiles isn't enabled or if browser frame avatar menu is
-  // always hidden (Chrome OS).
-  bool avatar_menu_always_hidden = false;
-#if defined(OS_CHROMEOS)
-  avatar_menu_always_hidden = true;
-#endif
-  base::FieldTrial* trial = base::FieldTrialList::Find("ShowProfileSwitcher");
-  if (trial && (!ProfileManager::IsMultipleProfilesEnabled() ||
-                avatar_menu_always_hidden)) {
-    trial->Disable();
-  }
 }
 
 // Sets up the experiment. The actual cache backend choice is made in the net/
@@ -233,63 +82,6 @@
   }
 }
 
-void ChromeBrowserFieldTrials::SetUpCacheSensitivityAnalysisFieldTrial() {
-  const base::FieldTrial::Probability kDivisor = 100;
-
-  base::FieldTrial::Probability sensitivity_analysis_probability = 0;
-
-#if defined(OS_ANDROID)
-  switch (chrome::VersionInfo::GetChannel()) {
-    case chrome::VersionInfo::CHANNEL_DEV:
-      sensitivity_analysis_probability = 10;
-      break;
-    case chrome::VersionInfo::CHANNEL_BETA:
-      sensitivity_analysis_probability = 5;
-      break;
-    case chrome::VersionInfo::CHANNEL_STABLE:
-      sensitivity_analysis_probability = 1;
-      break;
-    default:
-      break;
-  }
-#endif
-
-  scoped_refptr<base::FieldTrial> trial(
-      base::FieldTrialList::FactoryGetFieldTrial("CacheSensitivityAnalysis",
-                                                 kDivisor, "No",
-                                                 2013, 06, 15, NULL));
-  trial->AppendGroup("ControlA", sensitivity_analysis_probability);
-  trial->AppendGroup("ControlB", sensitivity_analysis_probability);
-  trial->AppendGroup("100A", sensitivity_analysis_probability);
-  trial->AppendGroup("100B", sensitivity_analysis_probability);
-  trial->AppendGroup("200A", sensitivity_analysis_probability);
-  trial->AppendGroup("200B", sensitivity_analysis_probability);
-  // TODO(gavinp,rvargas): Re-add 400 group to field trial if results justify.
-}
-
-void ChromeBrowserFieldTrials::WindowsOverlappedTCPReadsFieldTrial() {
-#if defined(OS_WIN)
-  if (parsed_command_line_.HasSwitch(switches::kOverlappedRead)) {
-    std::string option =
-        parsed_command_line_.GetSwitchValueASCII(switches::kOverlappedRead);
-    if (LowerCaseEqualsASCII(option, "off"))
-      net::TCPClientSocketWin::DisableOverlappedReads();
-  } else {
-    const base::FieldTrial::Probability kDivisor = 2;  // 1 in 2 chance
-    const base::FieldTrial::Probability kOverlappedReadProbability = 1;
-    scoped_refptr<base::FieldTrial> overlapped_reads_trial(
-        base::FieldTrialList::FactoryGetFieldTrial("OverlappedReadImpact",
-            kDivisor, "OverlappedReadEnabled", 2013, 6, 1, NULL));
-    int overlapped_reads_disabled_group =
-        overlapped_reads_trial->AppendGroup("OverlappedReadDisabled",
-                                            kOverlappedReadProbability);
-    int assigned_group = overlapped_reads_trial->group();
-    if (assigned_group == overlapped_reads_disabled_group)
-      net::TCPClientSocketWin::DisableOverlappedReads();
-  }
-#endif
-}
-
 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() {
   // Call |FindValue()| on the trials below, which may come from the server, to
   // ensure they get marked as "used" for the purposes of data reporting.
diff --git a/chrome/browser/chrome_browser_field_trials.h b/chrome/browser/chrome_browser_field_trials.h
index dfb9017d..db43359 100644
--- a/chrome/browser/chrome_browser_field_trials.h
+++ b/chrome/browser/chrome_browser_field_trials.h
@@ -7,7 +7,6 @@
 
 #include "base/basictypes.h"
 #include "base/command_line.h"
-#include "base/time.h"
 
 class PrefService;
 
@@ -21,56 +20,6 @@
   void SetupFieldTrials(PrefService* local_state);
 
  private:
-  // Sets up common desktop-only field trials.
-  // Add an invocation of your field trial init function to this method, or to
-  // SetupFieldTrials if it is for all platforms.
-  // |local_state| is needed by some other methods called from within this one.
-  void SetupDesktopFieldTrials(PrefService* local_state);
-
-#if defined(OS_ANDROID) || defined(OS_IOS)
-  // Sets up mobile-only field trials.
-  // Add invocation of your field trial initialization code in this method.
-  void SetupMobileFieldTrials();
-
-  // Mobile compression rollout field trial.
-  void DataCompressionProxyFieldTrial();
-#endif  // defined(OS_ANDROID) || defined(OS_IOS)
-
-  // This is not quite a field trial initialization, but it's an initialization
-  // that depends on a field trial, so why not? :-)
-  // |local_state| is needed to reset a local pref based on the chosen group.
-  void SetupAppLauncherFieldTrial(PrefService* local_state);
-
-  // A/B test for spdy when --use-spdy not set.
-  void SpdyFieldTrial();
-
-  // Field trial to see what disabling DNS pre-resolution does to
-  // latency of page loads.
-  void PredictorFieldTrial();
-
-  // A field trial to see what effects launching Chrome automatically on
-  // computer startup has on retention and usage of Chrome.
-  void AutoLaunchChromeFieldTrial();
-
-  // A collection of one-time-randomized and session-randomized field trials
-  // intended to test the uniformity and correctness of the field trial control,
-  // bucketing and reporting systems.
-  void SetupUniformityFieldTrials(const base::Time& install_date);
-
-  // Sets up the InfiniteCache field trial.
-  void SetUpInfiniteCacheFieldTrial();
-
-  // Sets up field trials for doing Cache Sensitivity Analysis.
-  void SetUpCacheSensitivityAnalysisFieldTrial();
-
-  // Disables the show profile switcher field trial if multi-profiles is not
-  // enabled.
-  void DisableShowProfileSwitcherTrialIfNecessary();
-
-  // A field trial to determine the impact of using non-blocking reads for
-  // TCP sockets on Windows instead of overlapped I/O.
-  void WindowsOverlappedTCPReadsFieldTrial();
-
   // A field trial to check the simple cache performance.
   void SetUpSimpleCacheFieldTrial();
 
diff --git a/chrome/browser/chrome_browser_field_trials_desktop.cc b/chrome/browser/chrome_browser_field_trials_desktop.cc
new file mode 100644
index 0000000..6a005506
--- /dev/null
+++ b/chrome/browser/chrome_browser_field_trials_desktop.cc
@@ -0,0 +1,191 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chrome_browser_field_trials_desktop.h"
+
+#include <string>
+
+#include "apps/field_trial_names.h"
+#include "apps/pref_names.h"
+#include "base/command_line.h"
+#include "base/metrics/field_trial.h"
+#include "base/prefs/pref_service.h"
+#include "base/string_util.h"
+#include "chrome/browser/auto_launch_trial.h"
+#include "chrome/browser/google/google_util.h"
+#include "chrome/browser/gpu/chrome_gpu_util.h"
+#include "chrome/browser/omnibox/omnibox_field_trial.h"
+#include "chrome/browser/prerender/prerender_field_trial.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
+#include "chrome/browser/ui/sync/one_click_signin_helper.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_version_info.h"
+#include "chrome/common/metrics/variations/variations_util.h"
+#include "net/spdy/spdy_session.h"
+#include "ui/base/layout.h"
+
+#if defined(OS_WIN)
+#include "net/socket/tcp_client_socket_win.h"
+#endif  // defined(OS_WIN)
+
+namespace chrome {
+
+namespace {
+
+void SetupAppLauncherFieldTrial(PrefService* local_state) {
+  if (base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName) ==
+      apps::kResetShowLauncherPromoPrefGroupName) {
+    local_state->SetBoolean(apps::prefs::kShowAppLauncherPromo, true);
+  }
+}
+
+// When --use-spdy not set, users will be in A/B test for spdy.
+// group A (npn_with_spdy): this means npn and spdy are enabled. In case server
+//                          supports spdy, browser will use spdy.
+// group B (npn_with_http): this means npn is enabled but spdy won't be used.
+//                          Http is still used for all requests.
+//           default group: no npn or spdy is involved. The "old" non-spdy
+//                          chrome behavior.
+void SpdyFieldTrial() {
+  // Setup SPDY CWND Field trial.
+  const base::FieldTrial::Probability kSpdyCwndDivisor = 100;
+  const base::FieldTrial::Probability kSpdyCwnd16 = 20;     // fixed at 16
+  const base::FieldTrial::Probability kSpdyCwnd10 = 20;     // fixed at 10
+  const base::FieldTrial::Probability kSpdyCwndMin16 = 20;  // no less than 16
+  const base::FieldTrial::Probability kSpdyCwndMin10 = 20;  // no less than 10
+
+  // After June 30, 2013 builds, it will always be in default group
+  // (cwndDynamic).
+  scoped_refptr<base::FieldTrial> trial(
+      base::FieldTrialList::FactoryGetFieldTrial(
+          "SpdyCwnd", kSpdyCwndDivisor, "cwndDynamic", 2013, 6, 30, NULL));
+
+  trial->AppendGroup("cwnd10", kSpdyCwnd10);
+  trial->AppendGroup("cwnd16", kSpdyCwnd16);
+  trial->AppendGroup("cwndMin16", kSpdyCwndMin16);
+  trial->AppendGroup("cwndMin10", kSpdyCwndMin10);
+}
+
+void AutoLaunchChromeFieldTrial() {
+  std::string brand;
+  google_util::GetBrand(&brand);
+
+  // Create a 100% field trial based on the brand code.
+  if (auto_launch_trial::IsInExperimentGroup(brand)) {
+    base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
+                                           kAutoLaunchTrialAutoLaunchGroup);
+  } else if (auto_launch_trial::IsInControlGroup(brand)) {
+    base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
+                                           kAutoLaunchTrialControlGroup);
+  }
+}
+
+void SetUpInfiniteCacheFieldTrial() {
+  const base::FieldTrial::Probability kDivisor = 100;
+
+  base::FieldTrial::Probability infinite_cache_probability = 0;
+
+  scoped_refptr<base::FieldTrial> trial(
+      base::FieldTrialList::FactoryGetFieldTrial("InfiniteCache", kDivisor,
+                                                 "No", 2013, 12, 31, NULL));
+  trial->UseOneTimeRandomization();
+  trial->AppendGroup("Yes", infinite_cache_probability);
+  trial->AppendGroup("Control", infinite_cache_probability);
+}
+
+void DisableShowProfileSwitcherTrialIfNecessary() {
+  // This trial is created by the VariationsService, but it needs to be disabled
+  // if multi-profiles isn't enabled or if browser frame avatar menu is
+  // always hidden (Chrome OS).
+  bool avatar_menu_always_hidden = false;
+#if defined(OS_CHROMEOS)
+  avatar_menu_always_hidden = true;
+#endif
+  base::FieldTrial* trial = base::FieldTrialList::Find("ShowProfileSwitcher");
+  if (trial && (!ProfileManager::IsMultipleProfilesEnabled() ||
+                avatar_menu_always_hidden)) {
+    trial->Disable();
+  }
+}
+
+void SetUpCacheSensitivityAnalysisFieldTrial() {
+  const base::FieldTrial::Probability kDivisor = 100;
+
+  base::FieldTrial::Probability sensitivity_analysis_probability = 0;
+
+#if defined(OS_ANDROID)
+  switch (chrome::VersionInfo::GetChannel()) {
+    case chrome::VersionInfo::CHANNEL_DEV:
+      sensitivity_analysis_probability = 10;
+      break;
+    case chrome::VersionInfo::CHANNEL_BETA:
+      sensitivity_analysis_probability = 5;
+      break;
+    case chrome::VersionInfo::CHANNEL_STABLE:
+      sensitivity_analysis_probability = 1;
+      break;
+    default:
+      break;
+  }
+#endif
+
+  scoped_refptr<base::FieldTrial> trial(
+      base::FieldTrialList::FactoryGetFieldTrial("CacheSensitivityAnalysis",
+                                                 kDivisor, "No",
+                                                 2013, 06, 15, NULL));
+  trial->AppendGroup("ControlA", sensitivity_analysis_probability);
+  trial->AppendGroup("ControlB", sensitivity_analysis_probability);
+  trial->AppendGroup("100A", sensitivity_analysis_probability);
+  trial->AppendGroup("100B", sensitivity_analysis_probability);
+  trial->AppendGroup("200A", sensitivity_analysis_probability);
+  trial->AppendGroup("200B", sensitivity_analysis_probability);
+  // TODO(gavinp,rvargas): Re-add 400 group to field trial if results justify.
+}
+
+void WindowsOverlappedTCPReadsFieldTrial(
+    const CommandLine& parsed_command_line) {
+#if defined(OS_WIN)
+  if (parsed_command_line.HasSwitch(switches::kOverlappedRead)) {
+    std::string option =
+        parsed_command_line.GetSwitchValueASCII(switches::kOverlappedRead);
+    if (LowerCaseEqualsASCII(option, "off"))
+      net::TCPClientSocketWin::DisableOverlappedReads();
+  } else {
+    const base::FieldTrial::Probability kDivisor = 2;  // 1 in 2 chance
+    const base::FieldTrial::Probability kOverlappedReadProbability = 1;
+    scoped_refptr<base::FieldTrial> overlapped_reads_trial(
+        base::FieldTrialList::FactoryGetFieldTrial("OverlappedReadImpact",
+            kDivisor, "OverlappedReadEnabled", 2013, 6, 1, NULL));
+    int overlapped_reads_disabled_group =
+        overlapped_reads_trial->AppendGroup("OverlappedReadDisabled",
+                                            kOverlappedReadProbability);
+    int assigned_group = overlapped_reads_trial->group();
+    if (assigned_group == overlapped_reads_disabled_group)
+      net::TCPClientSocketWin::DisableOverlappedReads();
+  }
+#endif
+}
+
+}  // namespace
+
+void SetupDesktopFieldTrials(const CommandLine& parsed_command_line,
+                             const base::Time& install_time,
+                             PrefService* local_state) {
+  prerender::ConfigurePrefetchAndPrerender(parsed_command_line);
+  SpdyFieldTrial();
+  AutoLaunchChromeFieldTrial();
+  gpu_util::InitializeCompositingFieldTrial();
+  OmniboxFieldTrial::ActivateStaticTrials();
+  SetUpInfiniteCacheFieldTrial();
+  SetUpCacheSensitivityAnalysisFieldTrial();
+  DisableShowProfileSwitcherTrialIfNecessary();
+  WindowsOverlappedTCPReadsFieldTrial(parsed_command_line);
+#if defined(ENABLE_ONE_CLICK_SIGNIN)
+  OneClickSigninHelper::InitializeFieldTrial();
+#endif
+  SetupAppLauncherFieldTrial(local_state);
+}
+
+}  // namespace chrome
diff --git a/chrome/browser/chrome_browser_field_trials_desktop.h b/chrome/browser/chrome_browser_field_trials_desktop.h
new file mode 100644
index 0000000..16358cd
--- /dev/null
+++ b/chrome/browser/chrome_browser_field_trials_desktop.h
@@ -0,0 +1,27 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROME_BROWSER_FIELD_TRIALS_DESKTOP_H_
+#define CHROME_BROWSER_CHROME_BROWSER_FIELD_TRIALS_DESKTOP_H_
+
+#include "base/basictypes.h"
+#include "base/time.h"
+
+class CommandLine;
+class PrefService;
+
+namespace chrome {
+
+// Sets up common desktop-only field trials.
+// Add an invocation of your field trial init function to this method, or to
+// SetupFieldTrials in chrome_browser_field_trials.cc if it is for all
+// platforms.
+// |local_state| is needed by some other methods called from within this one.
+void SetupDesktopFieldTrials(const CommandLine& parsed_command_line,
+                             const base::Time& install_time,
+                             PrefService* local_state);
+
+}  // namespace chrome
+
+#endif  // CHROME_BROWSER_CHROME_BROWSER_FIELD_TRIALS_DESKTOP_H_
diff --git a/chrome/browser/chrome_browser_field_trials_mobile.cc b/chrome/browser/chrome_browser_field_trials_mobile.cc
new file mode 100644
index 0000000..7fb1896e
--- /dev/null
+++ b/chrome/browser/chrome_browser_field_trials_mobile.cc
@@ -0,0 +1,62 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chrome_browser_field_trials_mobile.h"
+
+#include <string>
+
+#include "base/command_line.h"
+#include "base/metrics/field_trial.h"
+#include "base/prefs/pref_service.h"
+#include "chrome/common/chrome_version_info.h"
+
+namespace chrome {
+
+namespace {
+
+// Governs the rollout of the compression proxy for Chrome on mobile platforms.
+// Always enabled in DEV and BETA versions.
+// Stable percentage will be controlled from server.
+void DataCompressionProxyFieldTrial() {
+  const char kDataCompressionProxyFieldTrialName[] =
+      "DataCompressionProxyRollout";
+  const base::FieldTrial::Probability kDataCompressionProxyDivisor = 1000;
+
+  // 10/1000 = 1% for starters.
+  const base::FieldTrial::Probability kDataCompressionProxyStable = 10;
+  const char kEnabled[] = "Enabled";
+  const char kDisabled[] = "Disabled";
+
+  // Find out if this is a stable channel.
+  const bool kIsStableChannel =
+      chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE;
+
+  // Experiment enabled until Jan 1, 2015. By default, disabled.
+  scoped_refptr<base::FieldTrial> trial(
+      base::FieldTrialList::FactoryGetFieldTrial(
+          kDataCompressionProxyFieldTrialName, kDataCompressionProxyDivisor,
+          kDisabled, 2015, 1, 1, NULL));
+
+  // We want our trial results to be persistent.
+  trial->UseOneTimeRandomization();
+  // Non-stable channels will run with probability 1.
+  const int kEnabledGroup = trial->AppendGroup(
+      kEnabled,
+      kIsStableChannel ?
+          kDataCompressionProxyStable : kDataCompressionProxyDivisor);
+
+  const int v = trial->group();
+  VLOG(1) << "DataCompression proxy enabled group id: " << kEnabledGroup
+          << ". Selected group id: " << v;
+}
+
+}  // namespace
+
+void SetupMobileFieldTrials(const CommandLine& parsed_command_line,
+                            const base::Time& install_time,
+                            PrefService* local_state) {
+  DataCompressionProxyFieldTrial();
+}
+
+}  // namespace chrome
diff --git a/chrome/browser/chrome_browser_field_trials_mobile.h b/chrome/browser/chrome_browser_field_trials_mobile.h
new file mode 100644
index 0000000..4aca806c
--- /dev/null
+++ b/chrome/browser/chrome_browser_field_trials_mobile.h
@@ -0,0 +1,26 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROME_BROWSER_FIELD_TRIALS_MOBILE_H_
+#define CHROME_BROWSER_CHROME_BROWSER_FIELD_TRIALS_MOBILE_H_
+
+#include "base/basictypes.h"
+#include "base/time.h"
+
+class CommandLine;
+class PrefService;
+
+namespace chrome {
+
+// Sets up mobile-only field trials.
+// Add an invocation of your field trial init function to this method, or to
+// SetupFieldTrials in chrome_browser_field_trials.cc if it is for all
+// platforms.
+void SetupMobileFieldTrials(const CommandLine& parsed_command_line,
+                            const base::Time& install_time,
+                            PrefService* local_state);
+
+}  // namespace chrome
+
+#endif  // CHROME_BROWSER_CHROME_BROWSER_FIELD_TRIALS_MOBILE_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index a228b9f5..42c8bbd 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -327,6 +327,10 @@
         'browser/chrome_browser_application_mac.mm',
         'browser/chrome_browser_field_trials.cc',
         'browser/chrome_browser_field_trials.h',
+        'browser/chrome_browser_field_trials_desktop.cc',
+        'browser/chrome_browser_field_trials_desktop.h',
+        'browser/chrome_browser_field_trials_mobile.cc',
+        'browser/chrome_browser_field_trials_mobile.h',
         'browser/chrome_browser_main.cc',
         'browser/chrome_browser_main.h',
         'browser/chrome_browser_main_android.cc',
@@ -2628,8 +2632,15 @@
             'browser/sessions/session_service_factory.h',
           ],
         }],
-        ['OS!="android" and OS!="ios"', {
+        ['OS=="android" or OS=="ios"', {
           'sources!': [
+            'browser/chrome_browser_field_trials_desktop.cc',
+            'browser/chrome_browser_field_trials_desktop.h',
+          ],
+        }, {  # OS!="android" and OS!="ios"
+          'sources!': [
+            'browser/chrome_browser_field_trials_mobile.cc',
+            'browser/chrome_browser_field_trials_mobile.h',
             'browser/metrics/variations/eula_accepted_notifier_mobile.cc',
             'browser/metrics/variations/eula_accepted_notifier_mobile.h',
             'browser/metrics/variations/variations_request_scheduler_mobile.cc',