OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "chrome/browser/jankometer.h" | 44 #include "chrome/browser/jankometer.h" |
45 #include "chrome/browser/language_usage_metrics.h" | 45 #include "chrome/browser/language_usage_metrics.h" |
46 #include "chrome/browser/metrics/field_trial_synchronizer.h" | 46 #include "chrome/browser/metrics/field_trial_synchronizer.h" |
47 #include "chrome/browser/metrics/histogram_synchronizer.h" | 47 #include "chrome/browser/metrics/histogram_synchronizer.h" |
48 #include "chrome/browser/metrics/metrics_log.h" | 48 #include "chrome/browser/metrics/metrics_log.h" |
49 #include "chrome/browser/metrics/metrics_service.h" | 49 #include "chrome/browser/metrics/metrics_service.h" |
50 #include "chrome/browser/metrics/thread_watcher.h" | 50 #include "chrome/browser/metrics/thread_watcher.h" |
51 #include "chrome/browser/net/chrome_dns_cert_provenance_checker.h" | 51 #include "chrome/browser/net/chrome_dns_cert_provenance_checker.h" |
52 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" | 52 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" |
53 #include "chrome/browser/net/chrome_net_log.h" | 53 #include "chrome/browser/net/chrome_net_log.h" |
54 #include "chrome/browser/net/predictor_api.h" | 54 #include "chrome/browser/net/predictor.h" |
55 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 55 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
56 #include "chrome/browser/plugin_prefs.h" | 56 #include "chrome/browser/plugin_prefs.h" |
57 #include "chrome/browser/policy/browser_policy_connector.h" | 57 #include "chrome/browser/policy/browser_policy_connector.h" |
58 #include "chrome/browser/prefs/pref_service.h" | 58 #include "chrome/browser/prefs/pref_service.h" |
59 #include "chrome/browser/prefs/pref_value_store.h" | 59 #include "chrome/browser/prefs/pref_value_store.h" |
60 #include "chrome/browser/prerender/prerender_field_trial.h" | 60 #include "chrome/browser/prerender/prerender_field_trial.h" |
61 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 61 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
62 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 62 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
63 #include "chrome/browser/process_singleton.h" | 63 #include "chrome/browser/process_singleton.h" |
64 #include "chrome/browser/profiles/profile.h" | 64 #include "chrome/browser/profiles/profile.h" |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 30)); | 967 30)); |
968 const int connect_backup_jobs_enabled = trial->kDefaultGroupNumber; | 968 const int connect_backup_jobs_enabled = trial->kDefaultGroupNumber; |
969 trial->AppendGroup("ConnectBackupJobsDisabled", | 969 trial->AppendGroup("ConnectBackupJobsDisabled", |
970 kConnectBackupJobsProbability); | 970 kConnectBackupJobsProbability); |
971 const int trial_group = trial->group(); | 971 const int trial_group = trial->group(); |
972 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( | 972 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( |
973 trial_group == connect_backup_jobs_enabled); | 973 trial_group == connect_backup_jobs_enabled); |
974 } | 974 } |
975 } | 975 } |
976 | 976 |
| 977 void ChromeBrowserMainParts::PredictorFieldTrial() { |
| 978 const base::FieldTrial::Probability kDivisor = 1000; |
| 979 // For each option (i.e., non-default), we have a fixed probability. |
| 980 // 0.1% probability. |
| 981 const base::FieldTrial::Probability kProbabilityPerGroup = 1; |
| 982 |
| 983 // After June 30, 2011 builds, it will always be in default group |
| 984 // (default_enabled_prefetch). |
| 985 scoped_refptr<base::FieldTrial> trial( |
| 986 new base::FieldTrial("DnsImpact", kDivisor, |
| 987 "default_enabled_prefetch", 2011, 10, 30)); |
| 988 |
| 989 // First option is to disable prefetching completely. |
| 990 int disabled_prefetch = trial->AppendGroup("disabled_prefetch", |
| 991 kProbabilityPerGroup); |
| 992 |
| 993 // We're running two experiments at the same time. The first set of trials |
| 994 // modulates the delay-time until we declare a congestion event (and purge |
| 995 // our queue). The second modulates the number of concurrent resolutions |
| 996 // we do at any time. Users are in exactly one trial (or the default) during |
| 997 // any one run, and hence only one experiment at a time. |
| 998 // Experiment 1: |
| 999 // Set congestion detection at 250, 500, or 750ms, rather than the 1 second |
| 1000 // default. |
| 1001 int max_250ms_prefetch = trial->AppendGroup("max_250ms_queue_prefetch", |
| 1002 kProbabilityPerGroup); |
| 1003 int max_500ms_prefetch = trial->AppendGroup("max_500ms_queue_prefetch", |
| 1004 kProbabilityPerGroup); |
| 1005 int max_750ms_prefetch = trial->AppendGroup("max_750ms_queue_prefetch", |
| 1006 kProbabilityPerGroup); |
| 1007 // Set congestion detection at 2 seconds instead of the 1 second default. |
| 1008 int max_2s_prefetch = trial->AppendGroup("max_2s_queue_prefetch", |
| 1009 kProbabilityPerGroup); |
| 1010 // Experiment 2: |
| 1011 // Set max simultaneous resoultions to 2, 4, or 6, and scale the congestion |
| 1012 // limit proportionally (so we don't impact average probability of asserting |
| 1013 // congesion very much). |
| 1014 int max_2_concurrent_prefetch = trial->AppendGroup( |
| 1015 "max_2 concurrent_prefetch", kProbabilityPerGroup); |
| 1016 int max_4_concurrent_prefetch = trial->AppendGroup( |
| 1017 "max_4 concurrent_prefetch", kProbabilityPerGroup); |
| 1018 int max_6_concurrent_prefetch = trial->AppendGroup( |
| 1019 "max_6 concurrent_prefetch", kProbabilityPerGroup); |
| 1020 |
| 1021 if (trial->group() != disabled_prefetch) { |
| 1022 // Initialize the DNS prefetch system. |
| 1023 size_t max_parallel_resolves = |
| 1024 chrome_browser_net::Predictor::kMaxSpeculativeParallelResolves; |
| 1025 int max_queueing_delay_ms = |
| 1026 chrome_browser_net::Predictor::kMaxSpeculativeResolveQueueDelayMs; |
| 1027 |
| 1028 if (trial->group() == max_2_concurrent_prefetch) |
| 1029 max_parallel_resolves = 2; |
| 1030 else if (trial->group() == max_4_concurrent_prefetch) |
| 1031 max_parallel_resolves = 4; |
| 1032 else if (trial->group() == max_6_concurrent_prefetch) |
| 1033 max_parallel_resolves = 6; |
| 1034 chrome_browser_net::Predictor::set_max_parallel_resolves( |
| 1035 max_parallel_resolves); |
| 1036 |
| 1037 if (trial->group() == max_250ms_prefetch) { |
| 1038 max_queueing_delay_ms = |
| 1039 (250 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1040 max_parallel_resolves; |
| 1041 } else if (trial->group() == max_500ms_prefetch) { |
| 1042 max_queueing_delay_ms = |
| 1043 (500 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1044 max_parallel_resolves; |
| 1045 } else if (trial->group() == max_750ms_prefetch) { |
| 1046 max_queueing_delay_ms = |
| 1047 (750 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1048 max_parallel_resolves; |
| 1049 } else if (trial->group() == max_2s_prefetch) { |
| 1050 max_queueing_delay_ms = |
| 1051 (2000 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1052 max_parallel_resolves; |
| 1053 } |
| 1054 chrome_browser_net::Predictor::set_max_queueing_delay( |
| 1055 max_queueing_delay_ms); |
| 1056 } |
| 1057 } |
| 1058 |
977 // Test the impact on subsequent Google searches of getting suggestions from | 1059 // Test the impact on subsequent Google searches of getting suggestions from |
978 // www.google.TLD instead of clients1.google.TLD. | 1060 // www.google.TLD instead of clients1.google.TLD. |
979 void ChromeBrowserMainParts::SuggestPrefixFieldTrial() { | 1061 void ChromeBrowserMainParts::SuggestPrefixFieldTrial() { |
980 const base::FieldTrial::Probability kSuggestPrefixDivisor = 100; | 1062 const base::FieldTrial::Probability kSuggestPrefixDivisor = 100; |
981 // 50% probability. | 1063 // 50% probability. |
982 const base::FieldTrial::Probability kSuggestPrefixProbability = 50; | 1064 const base::FieldTrial::Probability kSuggestPrefixProbability = 50; |
983 // After Jan 1, 2012, it will always be in default group. | 1065 // After Jan 1, 2012, it will always be in default group. |
984 scoped_refptr<base::FieldTrial> trial( | 1066 scoped_refptr<base::FieldTrial> trial( |
985 new base::FieldTrial("SuggestHostPrefix", | 1067 new base::FieldTrial("SuggestHostPrefix", |
986 kSuggestPrefixDivisor, "Default_Prefix", 2012, 1, 1)); | 1068 kSuggestPrefixDivisor, "Default_Prefix", 2012, 1, 1)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 // If a policy is defining the number of active connections this field test | 1120 // If a policy is defining the number of active connections this field test |
1039 // shoud not be performed. | 1121 // shoud not be performed. |
1040 if (!proxy_policy_is_set) | 1122 if (!proxy_policy_is_set) |
1041 ProxyConnectionsFieldTrial(); | 1123 ProxyConnectionsFieldTrial(); |
1042 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); | 1124 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); |
1043 InstantFieldTrial::Activate(); | 1125 InstantFieldTrial::Activate(); |
1044 SpdyFieldTrial(); | 1126 SpdyFieldTrial(); |
1045 ConnectBackupJobsFieldTrial(); | 1127 ConnectBackupJobsFieldTrial(); |
1046 SuggestPrefixFieldTrial(); | 1128 SuggestPrefixFieldTrial(); |
1047 WarmConnectionFieldTrial(); | 1129 WarmConnectionFieldTrial(); |
| 1130 PredictorFieldTrial(); |
1048 } | 1131 } |
1049 | 1132 |
1050 // ----------------------------------------------------------------------------- | 1133 // ----------------------------------------------------------------------------- |
1051 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. | 1134 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. |
1052 | 1135 |
1053 #if defined(OS_CHROMEOS) | 1136 #if defined(OS_CHROMEOS) |
1054 // Allows authenticator to be invoked without adding refcounting. The instances | 1137 // Allows authenticator to be invoked without adding refcounting. The instances |
1055 // will delete themselves upon completion. | 1138 // will delete themselves upon completion. |
1056 DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin); | 1139 DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin); |
1057 #endif | 1140 #endif |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 #if defined(OS_WIN) | 1625 #if defined(OS_WIN) |
1543 // Registers Chrome with the Windows Restart Manager, which will restore the | 1626 // Registers Chrome with the Windows Restart Manager, which will restore the |
1544 // Chrome session when the computer is restarted after a system update. | 1627 // Chrome session when the computer is restarted after a system update. |
1545 // This could be run as late as WM_QUERYENDSESSION for system update reboots, | 1628 // This could be run as late as WM_QUERYENDSESSION for system update reboots, |
1546 // but should run on startup if extended to handle crashes/hangs/patches. | 1629 // but should run on startup if extended to handle crashes/hangs/patches. |
1547 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. | 1630 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. |
1548 if (base::win::GetVersion() >= base::win::VERSION_VISTA) | 1631 if (base::win::GetVersion() >= base::win::VERSION_VISTA) |
1549 RegisterApplicationRestart(parsed_command_line()); | 1632 RegisterApplicationRestart(parsed_command_line()); |
1550 #endif // OS_WIN | 1633 #endif // OS_WIN |
1551 | 1634 |
1552 // Initialize and maintain network predictor module, which handles DNS | |
1553 // pre-resolution, as well as TCP/IP connection pre-warming. | |
1554 // This also registers an observer to discard data when closing incognito | |
1555 // mode. | |
1556 bool preconnect_enabled = true; // Default status (easy to change!). | |
1557 if (parsed_command_line().HasSwitch(switches::kDisablePreconnect)) | |
1558 preconnect_enabled = false; | |
1559 else if (parsed_command_line().HasSwitch(switches::kEnablePreconnect)) | |
1560 preconnect_enabled = true; | |
1561 chrome_browser_net::PredictorInit dns_prefetch( | |
1562 user_prefs, | |
1563 local_state, | |
1564 preconnect_enabled); | |
1565 | |
1566 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 1635 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
1567 // Init the RLZ library. This just binds the dll and schedules a task on the | 1636 // Init the RLZ library. This just binds the dll and schedules a task on the |
1568 // file thread to be run sometime later. If this is the first run we record | 1637 // file thread to be run sometime later. If this is the first run we record |
1569 // the installation event. | 1638 // the installation event. |
1570 bool google_search_default = false; | 1639 bool google_search_default = false; |
1571 TemplateURLService* template_url_service = | 1640 TemplateURLService* template_url_service = |
1572 TemplateURLServiceFactory::GetForProfile(profile_); | 1641 TemplateURLServiceFactory::GetForProfile(profile_); |
1573 if (template_url_service) { | 1642 if (template_url_service) { |
1574 const TemplateURL* url_template = | 1643 const TemplateURL* url_template = |
1575 template_url_service->GetDefaultSearchProvider(); | 1644 template_url_service->GetDefaultSearchProvider(); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1933 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && | 2002 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && |
1934 (pre_read == "0" || pre_read == "1")) { | 2003 (pre_read == "0" || pre_read == "1")) { |
1935 std::string uma_name(name); | 2004 std::string uma_name(name); |
1936 uma_name += "_PreRead"; | 2005 uma_name += "_PreRead"; |
1937 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 2006 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
1938 AddPreReadHistogramTime(uma_name.c_str(), time); | 2007 AddPreReadHistogramTime(uma_name.c_str(), time); |
1939 } | 2008 } |
1940 #endif | 2009 #endif |
1941 #endif | 2010 #endif |
1942 } | 2011 } |
OLD | NEW |