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

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

Issue 10827080: Extract ChromeBrowserFieldTrials out of ChromeBrowserMainParts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chrome_browser_main.h ('k') | chrome/browser/chrome_browser_main_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_main.h" 5 #include "chrome/browser/chrome_browser_main.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/debug/trace_event.h" 14 #include "base/debug/trace_event.h"
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/metrics/field_trial.h" 17 #include "base/metrics/field_trial.h"
18 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/process_info.h" 20 #include "base/process_info.h"
21 #include "base/process_util.h" 21 #include "base/process_util.h"
22 #include "base/run_loop.h" 22 #include "base/run_loop.h"
23 #include "base/string_number_conversions.h" 23 #include "base/string_number_conversions.h"
24 #include "base/string_piece.h" 24 #include "base/string_piece.h"
25 #include "base/string_split.h" 25 #include "base/string_split.h"
26 #include "base/string_util.h"
27 #include "base/stringprintf.h"
28 #include "base/sys_string_conversions.h" 26 #include "base/sys_string_conversions.h"
29 #include "base/threading/platform_thread.h" 27 #include "base/threading/platform_thread.h"
30 #include "base/time.h" 28 #include "base/time.h"
31 #include "base/utf_string_conversions.h" 29 #include "base/utf_string_conversions.h"
32 #include "base/values.h" 30 #include "base/values.h"
33 #include "build/build_config.h" 31 #include "build/build_config.h"
34 #include "chrome/browser/about_flags.h" 32 #include "chrome/browser/about_flags.h"
35 #include "chrome/browser/auto_launch_trial.h"
36 #include "chrome/browser/autocomplete/autocomplete_field_trial.h"
37 #include "chrome/browser/browser_process.h" 33 #include "chrome/browser/browser_process.h"
38 #include "chrome/browser/browser_process_impl.h" 34 #include "chrome/browser/browser_process_impl.h"
39 #include "chrome/browser/browser_shutdown.h" 35 #include "chrome/browser/browser_shutdown.h"
40 #include "chrome/browser/chrome_browser_main_extra_parts.h" 36 #include "chrome/browser/chrome_browser_main_extra_parts.h"
41 #include "chrome/browser/defaults.h" 37 #include "chrome/browser/defaults.h"
42 #include "chrome/browser/extensions/default_apps_trial.h"
43 #include "chrome/browser/extensions/extension_protocols.h" 38 #include "chrome/browser/extensions/extension_protocols.h"
44 #include "chrome/browser/extensions/extension_service.h" 39 #include "chrome/browser/extensions/extension_service.h"
45 #include "chrome/browser/extensions/extensions_startup.h" 40 #include "chrome/browser/extensions/extensions_startup.h"
46 #include "chrome/browser/first_run/upgrade_util.h" 41 #include "chrome/browser/first_run/upgrade_util.h"
47 #include "chrome/browser/google/google_search_counter.h" 42 #include "chrome/browser/google/google_search_counter.h"
48 #include "chrome/browser/google/google_util.h" 43 #include "chrome/browser/google/google_util.h"
49 #include "chrome/browser/gpu_blacklist.h" 44 #include "chrome/browser/gpu_blacklist.h"
50 #include "chrome/browser/gpu_util.h"
51 #include "chrome/browser/jankometer.h" 45 #include "chrome/browser/jankometer.h"
52 #include "chrome/browser/language_usage_metrics.h" 46 #include "chrome/browser/language_usage_metrics.h"
53 #include "chrome/browser/managed_mode.h" 47 #include "chrome/browser/managed_mode.h"
54 #include "chrome/browser/metrics/field_trial_synchronizer.h" 48 #include "chrome/browser/metrics/field_trial_synchronizer.h"
55 #include "chrome/browser/metrics/metrics_log.h" 49 #include "chrome/browser/metrics/metrics_log.h"
56 #include "chrome/browser/metrics/metrics_service.h" 50 #include "chrome/browser/metrics/metrics_service.h"
57 #include "chrome/browser/metrics/thread_watcher.h" 51 #include "chrome/browser/metrics/thread_watcher.h"
58 #include "chrome/browser/metrics/tracking_synchronizer.h" 52 #include "chrome/browser/metrics/tracking_synchronizer.h"
59 #include "chrome/browser/metrics/variations_service.h" 53 #include "chrome/browser/metrics/variations_service.h"
60 #include "chrome/browser/nacl_host/nacl_process_host.h" 54 #include "chrome/browser/nacl_host/nacl_process_host.h"
61 #include "chrome/browser/net/chrome_net_log.h" 55 #include "chrome/browser/net/chrome_net_log.h"
62 #include "chrome/browser/net/predictor.h"
63 #include "chrome/browser/notifications/desktop_notification_service.h" 56 #include "chrome/browser/notifications/desktop_notification_service.h"
64 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 57 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
65 #include "chrome/browser/page_cycler/page_cycler.h" 58 #include "chrome/browser/page_cycler/page_cycler.h"
66 #include "chrome/browser/plugin_prefs.h" 59 #include "chrome/browser/plugin_prefs.h"
67 #include "chrome/browser/prefs/pref_service.h" 60 #include "chrome/browser/prefs/pref_service.h"
68 #include "chrome/browser/prefs/pref_value_store.h" 61 #include "chrome/browser/prefs/pref_value_store.h"
69 #include "chrome/browser/prefs/scoped_user_pref_update.h" 62 #include "chrome/browser/prefs/scoped_user_pref_update.h"
70 #include "chrome/browser/prerender/prerender_field_trial.h"
71 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 63 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
72 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" 64 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h"
73 #include "chrome/browser/process_singleton.h" 65 #include "chrome/browser/process_singleton.h"
74 #include "chrome/browser/profiles/profile.h" 66 #include "chrome/browser/profiles/profile.h"
75 #include "chrome/browser/profiles/profile_manager.h" 67 #include "chrome/browser/profiles/profile_manager.h"
76 #include "chrome/browser/search_engines/search_engine_type.h" 68 #include "chrome/browser/search_engines/search_engine_type.h"
77 #include "chrome/browser/search_engines/template_url.h" 69 #include "chrome/browser/search_engines/template_url.h"
78 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 70 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
79 #include "chrome/browser/search_engines/template_url_service.h" 71 #include "chrome/browser/search_engines/template_url_service.h"
80 #include "chrome/browser/search_engines/template_url_service_factory.h" 72 #include "chrome/browser/search_engines/template_url_service_factory.h"
81 #include "chrome/browser/service/service_process_control.h" 73 #include "chrome/browser/service/service_process_control.h"
82 #include "chrome/browser/shell_integration.h" 74 #include "chrome/browser/shell_integration.h"
83 #include "chrome/browser/translate/translate_manager.h" 75 #include "chrome/browser/translate/translate_manager.h"
84 #include "chrome/browser/ui/browser.h" 76 #include "chrome/browser/ui/browser.h"
85 #include "chrome/browser/ui/browser_finder.h" 77 #include "chrome/browser/ui/browser_finder.h"
86 #include "chrome/browser/ui/browser_ui_prefs.h" 78 #include "chrome/browser/ui/browser_ui_prefs.h"
87 #include "chrome/browser/ui/startup/startup_browser_creator.h" 79 #include "chrome/browser/ui/startup/startup_browser_creator.h"
88 #include "chrome/browser/ui/uma_browsing_activity_observer.h" 80 #include "chrome/browser/ui/uma_browsing_activity_observer.h"
89 #include "chrome/browser/ui/user_data_dir_dialog.h" 81 #include "chrome/browser/ui/user_data_dir_dialog.h"
90 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" 82 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h"
91 #include "chrome/common/child_process_logging.h" 83 #include "chrome/common/child_process_logging.h"
92 #include "chrome/common/chrome_constants.h" 84 #include "chrome/common/chrome_constants.h"
93 #include "chrome/common/chrome_paths.h" 85 #include "chrome/common/chrome_paths.h"
94 #include "chrome/common/chrome_result_codes.h" 86 #include "chrome/common/chrome_result_codes.h"
95 #include "chrome/common/chrome_switches.h" 87 #include "chrome/common/chrome_switches.h"
96 #include "chrome/common/chrome_version_info.h"
97 #include "chrome/common/env_vars.h" 88 #include "chrome/common/env_vars.h"
98 #include "chrome/common/json_pref_store.h" 89 #include "chrome/common/json_pref_store.h"
99 #include "chrome/common/jstemplate_builder.h" 90 #include "chrome/common/jstemplate_builder.h"
100 #include "chrome/common/logging_chrome.h" 91 #include "chrome/common/logging_chrome.h"
101 #include "chrome/common/metrics/experiments_helper.h" 92 #include "chrome/common/metrics/experiments_helper.h"
102 #include "chrome/common/net/net_resource_provider.h" 93 #include "chrome/common/net/net_resource_provider.h"
103 #include "chrome/common/pref_names.h" 94 #include "chrome/common/pref_names.h"
104 #include "chrome/common/profiling.h" 95 #include "chrome/common/profiling.h"
105 #include "chrome/installer/util/google_update_settings.h" 96 #include "chrome/installer/util/google_update_settings.h"
106 #include "content/public/browser/browser_thread.h" 97 #include "content/public/browser/browser_thread.h"
107 #include "content/public/browser/gpu_data_manager.h" 98 #include "content/public/browser/gpu_data_manager.h"
108 #include "content/public/browser/render_process_host.h" 99 #include "content/public/browser/render_process_host.h"
109 #include "content/public/common/content_client.h" 100 #include "content/public/common/content_client.h"
110 #include "content/public/common/main_function_params.h" 101 #include "content/public/common/main_function_params.h"
111 #include "grit/app_locale_settings.h" 102 #include "grit/app_locale_settings.h"
112 #include "grit/browser_resources.h" 103 #include "grit/browser_resources.h"
113 #include "grit/chromium_strings.h" 104 #include "grit/chromium_strings.h"
114 #include "grit/generated_resources.h" 105 #include "grit/generated_resources.h"
115 #include "grit/platform_locale_settings.h" 106 #include "grit/platform_locale_settings.h"
116 #include "net/base/net_module.h" 107 #include "net/base/net_module.h"
117 #include "net/base/sdch_manager.h" 108 #include "net/base/sdch_manager.h"
118 #include "net/base/ssl_config_service.h" 109 #include "net/base/ssl_config_service.h"
119 #include "net/cookies/cookie_monster.h" 110 #include "net/cookies/cookie_monster.h"
120 #include "net/http/http_basic_stream.h"
121 #include "net/http/http_network_layer.h"
122 #include "net/http/http_stream_factory.h" 111 #include "net/http/http_stream_factory.h"
123 #include "net/socket/client_socket_pool_base.h"
124 #include "net/socket/client_socket_pool_manager.h"
125 #include "net/spdy/spdy_session.h" 112 #include "net/spdy/spdy_session.h"
126 #include "net/spdy/spdy_session_pool.h" 113 #include "net/spdy/spdy_session_pool.h"
127 #include "net/url_request/url_request.h" 114 #include "net/url_request/url_request.h"
128 #include "net/websockets/websocket_job.h" 115 #include "net/websockets/websocket_job.h"
129 #include "ui/base/l10n/l10n_util.h" 116 #include "ui/base/l10n/l10n_util.h"
130 #include "ui/base/layout.h" 117 #include "ui/base/layout.h"
131 #include "ui/base/resource/resource_bundle.h" 118 #include "ui/base/resource/resource_bundle.h"
132 #include "ui/base/resource/resource_handle.h" 119 #include "ui/base/resource/resource_handle.h"
133 120
134 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 121 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
135 #include "chrome/browser/first_run/upgrade_util_linux.h" 122 #include "chrome/browser/first_run/upgrade_util_linux.h"
136 #endif 123 #endif
137 124
138 #if defined(OS_CHROMEOS) 125 #if defined(OS_CHROMEOS)
139 #include "chrome/browser/chromeos/cros/cros_library.h" 126 #include "chrome/browser/chromeos/cros/cros_library.h"
140 #include "chrome/browser/chromeos/cros_settings.h" 127 #include "chrome/browser/chromeos/cros_settings.h"
141 #include "chrome/browser/chromeos/cros_settings_names.h" 128 #include "chrome/browser/chromeos/cros_settings_names.h"
142 #endif 129 #endif
143 130
144 // TODO(port): several win-only methods have been pulled out of this, but 131 // TODO(port): several win-only methods have been pulled out of this, but
145 // BrowserMain() as a whole needs to be broken apart so that it's usable by 132 // BrowserMain() as a whole needs to be broken apart so that it's usable by
146 // other platforms. For now, it's just a stub. This is a serious work in 133 // other platforms. For now, it's just a stub. This is a serious work in
147 // progress and should not be taken as an indication of a real refactoring. 134 // progress and should not be taken as an indication of a real refactoring.
148 135
149 #if defined(OS_WIN) 136 #if defined(OS_WIN)
150 #include "base/environment.h" // For PreRead experiment. 137 #include "base/environment.h" // For PreRead experiment.
151 #include "base/win/windows_version.h" 138 #include "base/win/windows_version.h"
152 #include "chrome/browser/browser_trial.h"
153 #include "chrome/browser/browser_util_win.h" 139 #include "chrome/browser/browser_util_win.h"
154 #include "chrome/browser/chrome_browser_main_win.h" 140 #include "chrome/browser/chrome_browser_main_win.h"
155 #include "chrome/browser/first_run/try_chrome_dialog_view.h" 141 #include "chrome/browser/first_run/try_chrome_dialog_view.h"
156 #include "chrome/browser/first_run/upgrade_util_win.h" 142 #include "chrome/browser/first_run/upgrade_util_win.h"
157 #include "chrome/browser/net/url_fixer_upper.h" 143 #include "chrome/browser/net/url_fixer_upper.h"
158 #include "chrome/browser/ui/network_profile_bubble.h" 144 #include "chrome/browser/ui/network_profile_bubble.h"
159 #include "chrome/installer/util/helper.h" 145 #include "chrome/installer/util/helper.h"
160 #include "chrome/installer/util/install_util.h" 146 #include "chrome/installer/util/install_util.h"
161 #include "chrome/installer/util/shell_util.h" 147 #include "chrome/installer/util/shell_util.h"
162 #include "net/base/net_util.h" 148 #include "net/base/net_util.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 gpu_blacklist->UpdateGpuDataManager(); 416 gpu_blacklist->UpdateGpuDataManager();
431 } 417 }
432 418
433 #if defined(OS_MACOSX) 419 #if defined(OS_MACOSX)
434 OSStatus KeychainCallback(SecKeychainEvent keychain_event, 420 OSStatus KeychainCallback(SecKeychainEvent keychain_event,
435 SecKeychainCallbackInfo* info, void* context) { 421 SecKeychainCallbackInfo* info, void* context) {
436 return noErr; 422 return noErr;
437 } 423 }
438 #endif 424 #endif
439 425
440 void SetSocketReusePolicy(int warmest_socket_trial_group,
441 const int socket_policy[],
442 int num_groups) {
443 const int* result = std::find(socket_policy, socket_policy + num_groups,
444 warmest_socket_trial_group);
445 DCHECK_NE(result, socket_policy + num_groups)
446 << "Not a valid socket reuse policy group";
447 net::SetSocketReusePolicy(result - socket_policy);
448 }
449
450 // This code is specific to the Windows-only PreReadExperiment field-trial. 426 // This code is specific to the Windows-only PreReadExperiment field-trial.
451 void AddPreReadHistogramTime(const char* name, base::TimeDelta time) { 427 void AddPreReadHistogramTime(const char* name, base::TimeDelta time) {
452 const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1)); 428 const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1));
453 const base::TimeDelta kMax(base::TimeDelta::FromHours(1)); 429 const base::TimeDelta kMax(base::TimeDelta::FromHours(1));
454 static const size_t kBuckets(100); 430 static const size_t kBuckets(100);
455 431
456 // FactoryTimeGet will always return a pointer to the same histogram object, 432 // FactoryTimeGet will always return a pointer to the same histogram object,
457 // keyed on its name. There's no need for us to store it explicitly anywhere. 433 // keyed on its name. There's no need for us to store it explicitly anywhere.
458 base::Histogram* counter = base::Histogram::FactoryTimeGet( 434 base::Histogram* counter = base::Histogram::FactoryTimeGet(
459 name, kMin, kMax, kBuckets, base::Histogram::kUmaTargetedHistogramFlag); 435 name, kMin, kMax, kBuckets, base::Histogram::kUmaTargetedHistogramFlag);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( 467 StartupBrowserCreator::ProcessCommandLineAlreadyRunning(
492 command_line, current_directory); 468 command_line, current_directory);
493 return true; 469 return true;
494 } 470 }
495 471
496 bool HasImportSwitch(const CommandLine& command_line) { 472 bool HasImportSwitch(const CommandLine& command_line) {
497 return (command_line.HasSwitch(switches::kImport) || 473 return (command_line.HasSwitch(switches::kImport) ||
498 command_line.HasSwitch(switches::kImportFromFile)); 474 command_line.HasSwitch(switches::kImportFromFile));
499 } 475 }
500 476
501 // Set up a uniformity field trial. |one_time_randomized| indicates if the
502 // field trial is one-time randomized or session-randomized. |trial_name_string|
503 // must contain a "%d" since the percentage of the group will be inserted in
504 // the trial name. |num_trial_groups| must be a divisor of 100 (e.g. 5, 20)
505 void SetupSingleUniformityFieldTrial(
506 bool one_time_randomized,
507 const std::string& trial_name_string,
508 const chrome_variations::VariationID trial_base_id,
509 int num_trial_groups) {
510 // Probability per group remains constant for all uniformity trials, what
511 // changes is the probability divisor.
512 static const base::FieldTrial::Probability kProbabilityPerGroup = 1;
513 const std::string kDefaultGroupName = "default";
514 const base::FieldTrial::Probability divisor = num_trial_groups;
515
516 DCHECK_EQ(100 % num_trial_groups, 0);
517 const int group_percent = 100 / num_trial_groups;
518 const std::string trial_name = StringPrintf(trial_name_string.c_str(),
519 group_percent);
520
521 DVLOG(1) << "Trial name = " << trial_name;
522
523 scoped_refptr<base::FieldTrial> trial(
524 base::FieldTrialList::FactoryGetFieldTrial(
525 trial_name, divisor, kDefaultGroupName, 2015, 1, 1, NULL));
526 if (one_time_randomized)
527 trial->UseOneTimeRandomization();
528 experiments_helper::AssociateGoogleVariationID(trial_name, kDefaultGroupName,
529 trial_base_id);
530 // Loop starts with group 1 because the field trial automatically creates a
531 // default group, which would be group 0.
532 for (int group_number = 1; group_number < num_trial_groups; ++group_number) {
533 const std::string group_name = StringPrintf("group_%02d", group_number);
534 DVLOG(1) << " Group name = " << group_name;
535 trial->AppendGroup(group_name, kProbabilityPerGroup);
536 experiments_helper::AssociateGoogleVariationID(trial_name, group_name,
537 static_cast<chrome_variations::VariationID>(trial_base_id +
538 group_number));
539 }
540
541 // Now that all groups have been appended, call group() on the trial to
542 // ensure that our trial is registered. This resolves an off-by-one issue
543 // where the default group never gets chosen if we don't "use" the trial.
544 const int chosen_group = trial->group();
545 DVLOG(1) << "Chosen Group: " << chosen_group;
546 }
547
548 } // namespace 477 } // namespace
549 478
550 namespace chrome_browser { 479 namespace chrome_browser {
551 // This error message is not localized because we failed to load the 480 // This error message is not localized because we failed to load the
552 // localization data files. 481 // localization data files.
553 const char kMissingLocaleDataTitle[] = "Missing File Error"; 482 const char kMissingLocaleDataTitle[] = "Missing File Error";
554 const char kMissingLocaleDataMessage[] = 483 const char kMissingLocaleDataMessage[] =
555 "Unable to find locale data files. Please reinstall."; 484 "Unable to find locale data files. Please reinstall.";
556 } // namespace chrome_browser 485 } // namespace chrome_browser
557 486
558 // BrowserMainParts ------------------------------------------------------------ 487 // BrowserMainParts ------------------------------------------------------------
559 488
560 // static 489 // static
561 bool ChromeBrowserMainParts::disable_enforcing_cookie_policies_for_tests_ = 490 bool ChromeBrowserMainParts::disable_enforcing_cookie_policies_for_tests_ =
562 false; 491 false;
563 492
564 ChromeBrowserMainParts::ChromeBrowserMainParts( 493 ChromeBrowserMainParts::ChromeBrowserMainParts(
565 const content::MainFunctionParams& parameters) 494 const content::MainFunctionParams& parameters)
566 : parameters_(parameters), 495 : parameters_(parameters),
567 parsed_command_line_(parameters.command_line), 496 parsed_command_line_(parameters.command_line),
568 result_code_(content::RESULT_CODE_NORMAL_EXIT), 497 result_code_(content::RESULT_CODE_NORMAL_EXIT),
569 startup_watcher_(new StartupTimeBomb()), 498 startup_watcher_(new StartupTimeBomb()),
570 shutdown_watcher_(new ShutdownWatcherHelper()), 499 shutdown_watcher_(new ShutdownWatcherHelper()),
500 browser_field_trials_(parameters.command_line),
571 record_search_engine_(false), 501 record_search_engine_(false),
572 translate_manager_(NULL), 502 translate_manager_(NULL),
573 profile_(NULL), 503 profile_(NULL),
574 run_message_loop_(true), 504 run_message_loop_(true),
575 notify_result_(ProcessSingleton::PROCESS_NONE), 505 notify_result_(ProcessSingleton::PROCESS_NONE),
576 is_first_run_(false), 506 is_first_run_(false),
577 first_run_ui_bypass_(false), 507 first_run_ui_bypass_(false),
578 local_state_(NULL), 508 local_state_(NULL),
579 restart_last_session_(false) { 509 restart_last_session_(false) {
580 // If we're running tests (ui_task is non-null). 510 // If we're running tests (ui_task is non-null).
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 bool ret = base::FieldTrialList::CreateTrialsFromString(persistent); 554 bool ret = base::FieldTrialList::CreateTrialsFromString(persistent);
625 CHECK(ret) << "Invalid --" << switches::kForceFieldTrials << 555 CHECK(ret) << "Invalid --" << switches::kForceFieldTrials <<
626 " list specified."; 556 " list specified.";
627 } 557 }
628 #endif // NDEBUG 558 #endif // NDEBUG
629 559
630 chrome_variations::VariationsService* variations_service = 560 chrome_variations::VariationsService* variations_service =
631 browser_process_->variations_service(); 561 browser_process_->variations_service();
632 variations_service->CreateTrialsFromSeed(browser_process_->local_state()); 562 variations_service->CreateTrialsFromSeed(browser_process_->local_state());
633 563
634 SetupFieldTrials(local_state_->IsManagedPreference( 564 browser_field_trials_.SetupFieldTrials(
635 prefs::kMaxConnectionsPerProxy)); 565 local_state_->IsManagedPreference(prefs::kMaxConnectionsPerProxy));
636 566
637 SetupPlatformFieldTrials(); 567 SetupPlatformFieldTrials();
638 568
639 // Initialize FieldTrialSynchronizer system. This is a singleton and is used 569 // Initialize FieldTrialSynchronizer system. This is a singleton and is used
640 // for posting tasks via base::Bind. Its deleted when it goes out of scope. 570 // for posting tasks via base::Bind. Its deleted when it goes out of scope.
641 // Even though base::Bind does AddRef and Release, the object will not be 571 // Even though base::Bind does AddRef and Release, the object will not be
642 // deleted after the Task is executed. 572 // deleted after the Task is executed.
643 field_trial_synchronizer_ = new FieldTrialSynchronizer(); 573 field_trial_synchronizer_ = new FieldTrialSynchronizer();
644 } 574 }
645 575
646 // This is an A/B test for the maximum number of persistent connections per
647 // host. Currently Chrome, Firefox, and IE8 have this value set at 6. Safari
648 // uses 4, and Fasterfox (a plugin for Firefox that supposedly configures it to
649 // run faster) uses 8. We would like to see how much of an effect this value has
650 // on browsing. Too large a value might cause us to run into SYN flood detection
651 // mechanisms.
652 void ChromeBrowserMainParts::ConnectionFieldTrial() {
653 const base::FieldTrial::Probability kConnectDivisor = 100;
654 const base::FieldTrial::Probability kConnectProbability = 1; // 1% prob.
655
656 // This (6) is the current default value. Having this group declared here
657 // makes it straightforward to modify |kConnectProbability| such that the same
658 // probability value will be assigned to all the other groups, while
659 // preserving the remainder of the of probability space to the default value.
660 int connect_6 = -1;
661
662 // After June 30, 2011 builds, it will always be in default group.
663 scoped_refptr<base::FieldTrial> connect_trial(
664 base::FieldTrialList::FactoryGetFieldTrial(
665 "ConnCountImpact", kConnectDivisor, "conn_count_6", 2011, 6, 30,
666 &connect_6));
667
668 const int connect_5 = connect_trial->AppendGroup("conn_count_5",
669 kConnectProbability);
670 const int connect_7 = connect_trial->AppendGroup("conn_count_7",
671 kConnectProbability);
672 const int connect_8 = connect_trial->AppendGroup("conn_count_8",
673 kConnectProbability);
674 const int connect_9 = connect_trial->AppendGroup("conn_count_9",
675 kConnectProbability);
676
677 const int connect_trial_group = connect_trial->group();
678
679 int max_sockets = 0;
680 if (connect_trial_group == connect_5) {
681 max_sockets = 5;
682 } else if (connect_trial_group == connect_6) {
683 max_sockets = 6;
684 } else if (connect_trial_group == connect_7) {
685 max_sockets = 7;
686 } else if (connect_trial_group == connect_8) {
687 max_sockets = 8;
688 } else if (connect_trial_group == connect_9) {
689 max_sockets = 9;
690 } else {
691 NOTREACHED();
692 }
693 net::ClientSocketPoolManager::set_max_sockets_per_group(
694 net::HttpNetworkSession::NORMAL_SOCKET_POOL, max_sockets);
695 }
696
697 // A/B test for determining a value for unused socket timeout. Currently the
698 // timeout defaults to 10 seconds. Having this value set too low won't allow us
699 // to take advantage of idle sockets. Setting it to too high could possibly
700 // result in more ERR_CONNECTION_RESETs, since some servers will kill a socket
701 // before we time it out. Since these are "unused" sockets, we won't retry the
702 // connection and instead show an error to the user. So we need to be
703 // conservative here. We've seen that some servers will close the socket after
704 // as short as 10 seconds. See http://crbug.com/84313 for more details.
705 void ChromeBrowserMainParts::SocketTimeoutFieldTrial() {
706 const base::FieldTrial::Probability kIdleSocketTimeoutDivisor = 100;
707 // 1% probability for all experimental settings.
708 const base::FieldTrial::Probability kSocketTimeoutProbability = 1;
709
710 // After June 30, 2011 builds, it will always be in default group.
711 int socket_timeout_10 = -1;
712 scoped_refptr<base::FieldTrial> socket_timeout_trial(
713 base::FieldTrialList::FactoryGetFieldTrial(
714 "IdleSktToImpact", kIdleSocketTimeoutDivisor, "idle_timeout_10",
715 2011, 6, 30, &socket_timeout_10));
716
717 const int socket_timeout_5 =
718 socket_timeout_trial->AppendGroup("idle_timeout_5",
719 kSocketTimeoutProbability);
720 const int socket_timeout_20 =
721 socket_timeout_trial->AppendGroup("idle_timeout_20",
722 kSocketTimeoutProbability);
723
724 const int idle_to_trial_group = socket_timeout_trial->group();
725
726 if (idle_to_trial_group == socket_timeout_5) {
727 net::ClientSocketPool::set_unused_idle_socket_timeout(
728 base::TimeDelta::FromSeconds(5));
729 } else if (idle_to_trial_group == socket_timeout_10) {
730 net::ClientSocketPool::set_unused_idle_socket_timeout(
731 base::TimeDelta::FromSeconds(10));
732 } else if (idle_to_trial_group == socket_timeout_20) {
733 net::ClientSocketPool::set_unused_idle_socket_timeout(
734 base::TimeDelta::FromSeconds(20));
735 } else {
736 NOTREACHED();
737 }
738 }
739
740 void ChromeBrowserMainParts::ProxyConnectionsFieldTrial() {
741 const base::FieldTrial::Probability kProxyConnectionsDivisor = 100;
742 // 25% probability
743 const base::FieldTrial::Probability kProxyConnectionProbability = 1;
744
745 // This (32 connections per proxy server) is the current default value.
746 // Declaring it here allows us to easily re-assign the probability space while
747 // maintaining that the default group always has the remainder of the "share",
748 // which allows for cleaner and quicker changes down the line if needed.
749 int proxy_connections_32 = -1;
750
751 // After June 30, 2011 builds, it will always be in default group.
752 scoped_refptr<base::FieldTrial> proxy_connection_trial(
753 base::FieldTrialList::FactoryGetFieldTrial(
754 "ProxyConnectionImpact", kProxyConnectionsDivisor,
755 "proxy_connections_32", 2011, 6, 30, &proxy_connections_32));
756
757 // The number of max sockets per group cannot be greater than the max number
758 // of sockets per proxy server. We tried using 8, and it can easily
759 // lead to total browser stalls.
760 const int proxy_connections_16 =
761 proxy_connection_trial->AppendGroup("proxy_connections_16",
762 kProxyConnectionProbability);
763 const int proxy_connections_64 =
764 proxy_connection_trial->AppendGroup("proxy_connections_64",
765 kProxyConnectionProbability);
766
767 const int proxy_connections_trial_group = proxy_connection_trial->group();
768
769 int max_sockets = 0;
770 if (proxy_connections_trial_group == proxy_connections_16) {
771 max_sockets = 16;
772 } else if (proxy_connections_trial_group == proxy_connections_32) {
773 max_sockets = 32;
774 } else if (proxy_connections_trial_group == proxy_connections_64) {
775 max_sockets = 64;
776 } else {
777 NOTREACHED();
778 }
779 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server(
780 net::HttpNetworkSession::NORMAL_SOCKET_POOL, max_sockets);
781 }
782
783 // When --use-spdy not set, users will be in A/B test for spdy.
784 // group A (npn_with_spdy): this means npn and spdy are enabled. In case server
785 // supports spdy, browser will use spdy.
786 // group B (npn_with_http): this means npn is enabled but spdy won't be used.
787 // Http is still used for all requests.
788 // default group: no npn or spdy is involved. The "old" non-spdy
789 // chrome behavior.
790 void ChromeBrowserMainParts::SpdyFieldTrial() {
791 bool use_field_trial = true;
792 if (parsed_command_line().HasSwitch(switches::kUseSpdy)) {
793 std::string spdy_mode =
794 parsed_command_line().GetSwitchValueASCII(switches::kUseSpdy);
795 net::HttpNetworkLayer::EnableSpdy(spdy_mode);
796 use_field_trial = false;
797 }
798 if (parsed_command_line().HasSwitch(switches::kEnableSpdy3)) {
799 net::HttpStreamFactory::EnableNpnSpdy3();
800 use_field_trial = false;
801 } else if (parsed_command_line().HasSwitch(switches::kEnableNpn)) {
802 net::HttpStreamFactory::EnableNpnSpdy();
803 use_field_trial = false;
804 } else if (parsed_command_line().HasSwitch(switches::kEnableNpnHttpOnly)) {
805 net::HttpStreamFactory::EnableNpnHttpOnly();
806 use_field_trial = false;
807 }
808 if (use_field_trial) {
809 const base::FieldTrial::Probability kSpdyDivisor = 100;
810 // Enable SPDY/3 for 95% of the users, HTTP (no SPDY) for 1% of the users
811 // and SPDY/2 for 4% of the users.
812 base::FieldTrial::Probability npnhttp_probability = 1;
813 base::FieldTrial::Probability spdy3_probability = 95;
814
815 #if defined(OS_CHROMEOS)
816 // Always enable SPDY (spdy/2 or spdy/3) on Chrome OS
817 npnhttp_probability = 0;
818 #endif // !defined(OS_CHROMEOS)
819
820 // NPN with spdy support is the default.
821 int npn_spdy_grp = -1;
822
823 // After June 30, 2013 builds, it will always be in default group.
824 scoped_refptr<base::FieldTrial> trial(
825 base::FieldTrialList::FactoryGetFieldTrial(
826 "SpdyImpact", kSpdyDivisor, "npn_with_spdy", 2013, 6, 30,
827 &npn_spdy_grp));
828
829 // NPN with only http support, no spdy.
830 int npn_http_grp = trial->AppendGroup("npn_with_http", npnhttp_probability);
831
832 // NPN with http/1.1, spdy/2, and spdy/3 support.
833 int spdy3_grp = trial->AppendGroup("spdy3", spdy3_probability);
834
835 int trial_grp = trial->group();
836 if (trial_grp == npn_spdy_grp) {
837 net::HttpStreamFactory::EnableNpnSpdy();
838 } else if (trial_grp == npn_http_grp) {
839 net::HttpStreamFactory::EnableNpnHttpOnly();
840 } else if (trial_grp == spdy3_grp) {
841 net::HttpStreamFactory::EnableNpnSpdy3();
842 } else {
843 NOTREACHED();
844 }
845 }
846
847 // Setup SPDY CWND Field trial.
848 const base::FieldTrial::Probability kSpdyCwndDivisor = 100;
849 const base::FieldTrial::Probability kSpdyCwnd16 = 20; // fixed at 16
850 const base::FieldTrial::Probability kSpdyCwnd10 = 20; // fixed at 10
851 const base::FieldTrial::Probability kSpdyCwndMin16 = 20; // no less than 16
852 const base::FieldTrial::Probability kSpdyCwndMin10 = 20; // no less than 10
853
854 // After June 30, 2013 builds, it will always be in default group
855 // (cwndDynamic).
856 scoped_refptr<base::FieldTrial> trial(
857 base::FieldTrialList::FactoryGetFieldTrial(
858 "SpdyCwnd", kSpdyCwndDivisor, "cwndDynamic", 2013, 6, 30, NULL));
859
860 trial->AppendGroup("cwnd10", kSpdyCwnd10);
861 trial->AppendGroup("cwnd16", kSpdyCwnd16);
862 trial->AppendGroup("cwndMin16", kSpdyCwndMin16);
863 trial->AppendGroup("cwndMin10", kSpdyCwndMin10);
864
865 if (parsed_command_line().HasSwitch(switches::kMaxSpdyConcurrentStreams)) {
866 int value = 0;
867 base::StringToInt(parsed_command_line().GetSwitchValueASCII(
868 switches::kMaxSpdyConcurrentStreams),
869 &value);
870 if (value > 0)
871 net::SpdySession::set_max_concurrent_streams(value);
872 }
873 }
874
875 // If --socket-reuse-policy is not specified, run an A/B test for choosing the
876 // warmest socket.
877 void ChromeBrowserMainParts::WarmConnectionFieldTrial() {
878 const CommandLine& command_line = parsed_command_line();
879 if (command_line.HasSwitch(switches::kSocketReusePolicy)) {
880 std::string socket_reuse_policy_str = command_line.GetSwitchValueASCII(
881 switches::kSocketReusePolicy);
882 int policy = -1;
883 base::StringToInt(socket_reuse_policy_str, &policy);
884
885 const int policy_list[] = { 0, 1, 2 };
886 VLOG(1) << "Setting socket_reuse_policy = " << policy;
887 SetSocketReusePolicy(policy, policy_list, arraysize(policy_list));
888 return;
889 }
890
891 const base::FieldTrial::Probability kWarmSocketDivisor = 100;
892 const base::FieldTrial::Probability kWarmSocketProbability = 33;
893
894 // Default value is USE_LAST_ACCESSED_SOCKET.
895 int last_accessed_socket = -1;
896
897 // After January 30, 2013 builds, it will always be in default group.
898 scoped_refptr<base::FieldTrial> warmest_socket_trial(
899 base::FieldTrialList::FactoryGetFieldTrial(
900 "WarmSocketImpact", kWarmSocketDivisor, "last_accessed_socket",
901 2013, 1, 30, &last_accessed_socket));
902
903 const int warmest_socket = warmest_socket_trial->AppendGroup(
904 "warmest_socket", kWarmSocketProbability);
905 const int warm_socket = warmest_socket_trial->AppendGroup(
906 "warm_socket", kWarmSocketProbability);
907
908 const int warmest_socket_trial_group = warmest_socket_trial->group();
909
910 const int policy_list[] = { warmest_socket, warm_socket,
911 last_accessed_socket };
912 SetSocketReusePolicy(warmest_socket_trial_group, policy_list,
913 arraysize(policy_list));
914 }
915
916 // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is
917 // specified, run an A/B test for automatically establishing backup TCP
918 // connections when a certain timeout value is exceeded.
919 void ChromeBrowserMainParts::ConnectBackupJobsFieldTrial() {
920 if (parsed_command_line().HasSwitch(switches::kEnableConnectBackupJobs)) {
921 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
922 true);
923 } else if (parsed_command_line().HasSwitch(
924 switches::kDisableConnectBackupJobs)) {
925 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
926 false);
927 } else {
928 const base::FieldTrial::Probability kConnectBackupJobsDivisor = 100;
929 // 1% probability.
930 const base::FieldTrial::Probability kConnectBackupJobsProbability = 1;
931 // After June 30, 2011 builds, it will always be in default group.
932 int connect_backup_jobs_enabled = -1;
933 scoped_refptr<base::FieldTrial> trial(
934 base::FieldTrialList::FactoryGetFieldTrial("ConnnectBackupJobs",
935 kConnectBackupJobsDivisor, "ConnectBackupJobsEnabled",
936 2011, 6, 30, &connect_backup_jobs_enabled));
937 trial->AppendGroup("ConnectBackupJobsDisabled",
938 kConnectBackupJobsProbability);
939 const int trial_group = trial->group();
940 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
941 trial_group == connect_backup_jobs_enabled);
942 }
943 }
944
945 void ChromeBrowserMainParts::PredictorFieldTrial() {
946 const base::FieldTrial::Probability kDivisor = 1000;
947 // For each option (i.e., non-default), we have a fixed probability.
948 // 0.1% probability.
949 const base::FieldTrial::Probability kProbabilityPerGroup = 1;
950
951 // After June 30, 2011 builds, it will always be in default group
952 // (default_enabled_prefetch).
953 scoped_refptr<base::FieldTrial> trial(
954 base::FieldTrialList::FactoryGetFieldTrial(
955 "DnsImpact", kDivisor, "default_enabled_prefetch", 2011, 10, 30,
956 NULL));
957
958 // First option is to disable prefetching completely.
959 int disabled_prefetch = trial->AppendGroup("disabled_prefetch",
960 kProbabilityPerGroup);
961
962 // We're running two experiments at the same time. The first set of trials
963 // modulates the delay-time until we declare a congestion event (and purge
964 // our queue). The second modulates the number of concurrent resolutions
965 // we do at any time. Users are in exactly one trial (or the default) during
966 // any one run, and hence only one experiment at a time.
967 // Experiment 1:
968 // Set congestion detection at 250, 500, or 750ms, rather than the 1 second
969 // default.
970 int max_250ms_prefetch = trial->AppendGroup("max_250ms_queue_prefetch",
971 kProbabilityPerGroup);
972 int max_500ms_prefetch = trial->AppendGroup("max_500ms_queue_prefetch",
973 kProbabilityPerGroup);
974 int max_750ms_prefetch = trial->AppendGroup("max_750ms_queue_prefetch",
975 kProbabilityPerGroup);
976 // Set congestion detection at 2 seconds instead of the 1 second default.
977 int max_2s_prefetch = trial->AppendGroup("max_2s_queue_prefetch",
978 kProbabilityPerGroup);
979 // Experiment 2:
980 // Set max simultaneous resoultions to 2, 4, or 6, and scale the congestion
981 // limit proportionally (so we don't impact average probability of asserting
982 // congesion very much).
983 int max_2_concurrent_prefetch = trial->AppendGroup(
984 "max_2 concurrent_prefetch", kProbabilityPerGroup);
985 int max_4_concurrent_prefetch = trial->AppendGroup(
986 "max_4 concurrent_prefetch", kProbabilityPerGroup);
987 int max_6_concurrent_prefetch = trial->AppendGroup(
988 "max_6 concurrent_prefetch", kProbabilityPerGroup);
989
990 if (trial->group() != disabled_prefetch) {
991 // Initialize the DNS prefetch system.
992 size_t max_parallel_resolves =
993 chrome_browser_net::Predictor::kMaxSpeculativeParallelResolves;
994 int max_queueing_delay_ms =
995 chrome_browser_net::Predictor::kMaxSpeculativeResolveQueueDelayMs;
996
997 if (trial->group() == max_2_concurrent_prefetch)
998 max_parallel_resolves = 2;
999 else if (trial->group() == max_4_concurrent_prefetch)
1000 max_parallel_resolves = 4;
1001 else if (trial->group() == max_6_concurrent_prefetch)
1002 max_parallel_resolves = 6;
1003 chrome_browser_net::Predictor::set_max_parallel_resolves(
1004 max_parallel_resolves);
1005
1006 if (trial->group() == max_250ms_prefetch) {
1007 max_queueing_delay_ms =
1008 (250 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) /
1009 max_parallel_resolves;
1010 } else if (trial->group() == max_500ms_prefetch) {
1011 max_queueing_delay_ms =
1012 (500 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) /
1013 max_parallel_resolves;
1014 } else if (trial->group() == max_750ms_prefetch) {
1015 max_queueing_delay_ms =
1016 (750 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) /
1017 max_parallel_resolves;
1018 } else if (trial->group() == max_2s_prefetch) {
1019 max_queueing_delay_ms =
1020 (2000 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) /
1021 max_parallel_resolves;
1022 }
1023 chrome_browser_net::Predictor::set_max_queueing_delay(
1024 max_queueing_delay_ms);
1025 }
1026 }
1027
1028 void ChromeBrowserMainParts::DefaultAppsFieldTrial() {
1029 std::string brand;
1030 google_util::GetBrand(&brand);
1031
1032 // Create a 100% field trial based on the brand code.
1033 if (LowerCaseEqualsASCII(brand, "ecdb")) {
1034 base::FieldTrialList::CreateFieldTrial(kDefaultAppsTrialName,
1035 kDefaultAppsTrialNoAppsGroup);
1036 } else if (LowerCaseEqualsASCII(brand, "ecda")) {
1037 base::FieldTrialList::CreateFieldTrial(kDefaultAppsTrialName,
1038 kDefaultAppsTrialWithAppsGroup);
1039 }
1040 }
1041
1042 void ChromeBrowserMainParts::AutoLaunchChromeFieldTrial() {
1043 std::string brand;
1044 google_util::GetBrand(&brand);
1045
1046 // Create a 100% field trial based on the brand code.
1047 if (auto_launch_trial::IsInExperimentGroup(brand)) {
1048 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
1049 kAutoLaunchTrialAutoLaunchGroup);
1050 } else if (auto_launch_trial::IsInControlGroup(brand)) {
1051 base::FieldTrialList::CreateFieldTrial(kAutoLaunchTrialName,
1052 kAutoLaunchTrialControlGroup);
1053 }
1054 }
1055
1056 void ChromeBrowserMainParts::SetupUniformityFieldTrials() {
1057 // One field trial will be created for each entry in this array. The i'th
1058 // field trial will have |trial_sizes[i]| groups in it, including the default
1059 // group. Each group will have a probability of 1/|trial_sizes[i]|.
1060 const int num_trial_groups[] = { 100, 20, 10, 5, 2 };
1061
1062 // Declare our variation ID bases along side this array so we can loop over it
1063 // and assign the IDs appropriately. So for example, the 1 percent experiments
1064 // should have a size of 100 (100/100 = 1).
1065 const chrome_variations::VariationID trial_base_ids[] = {
1066 chrome_variations::kUniformity1PercentBase,
1067 chrome_variations::kUniformity5PercentBase,
1068 chrome_variations::kUniformity10PercentBase,
1069 chrome_variations::kUniformity20PercentBase,
1070 chrome_variations::kUniformity50PercentBase
1071 };
1072
1073 const std::string kOneTimeRandomizedTrialName =
1074 "UMA-Uniformity-Trial-%d-Percent";
1075 for (size_t i = 0; i < arraysize(num_trial_groups); ++i) {
1076 SetupSingleUniformityFieldTrial(true, kOneTimeRandomizedTrialName,
1077 trial_base_ids[i], num_trial_groups[i]);
1078 }
1079
1080 // Setup a 5% session-randomized uniformity trial.
1081 const std::string kSessionRandomizedTrialName =
1082 "UMA-Session-Randomized-Uniformity-Trial-%d-Percent";
1083 SetupSingleUniformityFieldTrial(false, kSessionRandomizedTrialName,
1084 chrome_variations::kUniformitySessionRandomized5PercentBase, 20);
1085 }
1086
1087 void ChromeBrowserMainParts::DisableNewTabFieldTrialIfNecesssary() {
1088 // The new tab button field trial will get created in variations_service.cc
1089 // through the variations server. However, since there are no HiDPI assets
1090 // for it, disable it for non-desktop layouts.
1091 base::FieldTrial* trial = base::FieldTrialList::Find("NewTabButton");
1092 if (trial) {
1093 bool using_hidpi_assets = false;
1094 #if defined(ENABLE_HIDPI) && defined(OS_WIN)
1095 // Mirrors logic in resource_bundle_win.cc.
1096 using_hidpi_assets = ui::GetDPIScale() > 1.5;
1097 #endif
1098 if (ui::GetDisplayLayout() != ui::LAYOUT_DESKTOP || using_hidpi_assets)
1099 trial->Disable();
1100 }
1101 }
1102
1103 void ChromeBrowserMainParts::ChannelIDFieldTrial() {
1104 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
1105 if (channel == chrome::VersionInfo::CHANNEL_CANARY) {
1106 net::SSLConfigService::EnableChannelIDTrial();
1107 } else if (channel == chrome::VersionInfo::CHANNEL_DEV &&
1108 base::FieldTrialList::IsOneTimeRandomizationEnabled()) {
1109 const base::FieldTrial::Probability kDivisor = 100;
1110 // 10% probability of being in the enabled group.
1111 const base::FieldTrial::Probability kEnableProbability = 10;
1112 scoped_refptr<base::FieldTrial> trial =
1113 base::FieldTrialList::FactoryGetFieldTrial(
1114 "ChannelID", kDivisor, "disable", 2012, 8, 23, NULL);
1115 trial->UseOneTimeRandomization();
1116 int enable_group = trial->AppendGroup("enable", kEnableProbability);
1117 if (trial->group() == enable_group)
1118 net::SSLConfigService::EnableChannelIDTrial();
1119 }
1120 }
1121
1122 // ChromeBrowserMainParts: |SetupMetricsAndFieldTrials()| related -------------- 576 // ChromeBrowserMainParts: |SetupMetricsAndFieldTrials()| related --------------
1123 577
1124 void ChromeBrowserMainParts::SetupFieldTrials(bool proxy_policy_is_set) {
1125 // Note: make sure to call ConnectionFieldTrial() before
1126 // ProxyConnectionsFieldTrial().
1127 ConnectionFieldTrial();
1128 SocketTimeoutFieldTrial();
1129 // If a policy is defining the number of active connections this field test
1130 // shoud not be performed.
1131 if (!proxy_policy_is_set)
1132 ProxyConnectionsFieldTrial();
1133 prerender::ConfigurePrefetchAndPrerender(parsed_command_line());
1134 SpdyFieldTrial();
1135 ConnectBackupJobsFieldTrial();
1136 WarmConnectionFieldTrial();
1137 PredictorFieldTrial();
1138 DefaultAppsFieldTrial();
1139 AutoLaunchChromeFieldTrial();
1140 gpu_util::InitializeForceCompositingModeFieldTrial();
1141 SetupUniformityFieldTrials();
1142 AutocompleteFieldTrial::Activate();
1143 DisableNewTabFieldTrialIfNecesssary();
1144 ChannelIDFieldTrial();
1145 }
1146
1147 void ChromeBrowserMainParts::StartMetricsRecording() { 578 void ChromeBrowserMainParts::StartMetricsRecording() {
1148 MetricsService* metrics = g_browser_process->metrics_service(); 579 MetricsService* metrics = g_browser_process->metrics_service();
1149 if (parsed_command_line_.HasSwitch(switches::kMetricsRecordingOnly) || 580 if (parsed_command_line_.HasSwitch(switches::kMetricsRecordingOnly) ||
1150 parsed_command_line_.HasSwitch(switches::kEnableBenchmarking)) { 581 parsed_command_line_.HasSwitch(switches::kEnableBenchmarking)) {
1151 // If we're testing then we don't care what the user preference is, we turn 582 // If we're testing then we don't care what the user preference is, we turn
1152 // on recording, but not reporting, otherwise tests fail. 583 // on recording, but not reporting, otherwise tests fail.
1153 metrics->StartRecordingOnly(); 584 metrics->StartRecordingOnly();
1154 return; 585 return;
1155 } 586 }
1156 587
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 if (base::win::GetVersion() <= base::win::VERSION_XP) 1511 if (base::win::GetVersion() <= base::win::VERSION_XP)
2081 uma_name += "_XP"; 1512 uma_name += "_XP";
2082 1513
2083 uma_name += "_PreRead_"; 1514 uma_name += "_PreRead_";
2084 uma_name += pre_read_percentage; 1515 uma_name += pre_read_percentage;
2085 AddPreReadHistogramTime(uma_name.c_str(), time); 1516 AddPreReadHistogramTime(uma_name.c_str(), time);
2086 } 1517 }
2087 #endif 1518 #endif
2088 #endif 1519 #endif
2089 } 1520 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.h ('k') | chrome/browser/chrome_browser_main_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698