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/browser_main.h" | 5 #include "chrome/browser/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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "chrome/browser/jankometer.h" | 48 #include "chrome/browser/jankometer.h" |
49 #include "chrome/browser/language_usage_metrics.h" | 49 #include "chrome/browser/language_usage_metrics.h" |
50 #include "chrome/browser/metrics/field_trial_synchronizer.h" | 50 #include "chrome/browser/metrics/field_trial_synchronizer.h" |
51 #include "chrome/browser/metrics/histogram_synchronizer.h" | 51 #include "chrome/browser/metrics/histogram_synchronizer.h" |
52 #include "chrome/browser/metrics/metrics_log.h" | 52 #include "chrome/browser/metrics/metrics_log.h" |
53 #include "chrome/browser/metrics/metrics_service.h" | 53 #include "chrome/browser/metrics/metrics_service.h" |
54 #include "chrome/browser/metrics/thread_watcher.h" | 54 #include "chrome/browser/metrics/thread_watcher.h" |
55 #include "chrome/browser/net/chrome_dns_cert_provenance_checker.h" | 55 #include "chrome/browser/net/chrome_dns_cert_provenance_checker.h" |
56 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" | 56 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" |
57 #include "chrome/browser/net/chrome_net_log.h" | 57 #include "chrome/browser/net/chrome_net_log.h" |
58 #include "chrome/browser/net/predictor_api.h" | 58 #include "chrome/browser/net/predictor.h" |
59 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 59 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
60 #include "chrome/browser/plugin_updater.h" | 60 #include "chrome/browser/plugin_updater.h" |
61 #include "chrome/browser/policy/browser_policy_connector.h" | 61 #include "chrome/browser/policy/browser_policy_connector.h" |
62 #include "chrome/browser/prefs/pref_service.h" | 62 #include "chrome/browser/prefs/pref_service.h" |
63 #include "chrome/browser/prefs/pref_value_store.h" | 63 #include "chrome/browser/prefs/pref_value_store.h" |
64 #include "chrome/browser/prerender/prerender_field_trial.h" | 64 #include "chrome/browser/prerender/prerender_field_trial.h" |
65 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 65 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
66 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 66 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
67 #include "chrome/browser/process_singleton.h" | 67 #include "chrome/browser/process_singleton.h" |
68 #include "chrome/browser/profiles/profile.h" | 68 #include "chrome/browser/profiles/profile.h" |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 30)); | 1165 30)); |
1166 const int connect_backup_jobs_enabled = trial->kDefaultGroupNumber; | 1166 const int connect_backup_jobs_enabled = trial->kDefaultGroupNumber; |
1167 trial->AppendGroup("ConnectBackupJobsDisabled", | 1167 trial->AppendGroup("ConnectBackupJobsDisabled", |
1168 kConnectBackupJobsProbability); | 1168 kConnectBackupJobsProbability); |
1169 const int trial_group = trial->group(); | 1169 const int trial_group = trial->group(); |
1170 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( | 1170 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( |
1171 trial_group == connect_backup_jobs_enabled); | 1171 trial_group == connect_backup_jobs_enabled); |
1172 } | 1172 } |
1173 } | 1173 } |
1174 | 1174 |
| 1175 void BrowserMainParts::PredictorFieldTrial() { |
| 1176 const base::FieldTrial::Probability kDivisor = 1000; |
| 1177 // For each option (i.e., non-default), we have a fixed probability. |
| 1178 // 0.1% probability. |
| 1179 const base::FieldTrial::Probability kProbabilityPerGroup = 1; |
| 1180 |
| 1181 // After June 30, 2011 builds, it will always be in default group |
| 1182 // (default_enabled_prefetch). |
| 1183 scoped_refptr<base::FieldTrial> trial( |
| 1184 new base::FieldTrial("DnsImpact", kDivisor, |
| 1185 "default_enabled_prefetch", 2011, 10, 30)); |
| 1186 |
| 1187 // First option is to disable prefetching completely. |
| 1188 int disabled_prefetch = trial->AppendGroup("disabled_prefetch", |
| 1189 kProbabilityPerGroup); |
| 1190 |
| 1191 // We're running two experiments at the same time. The first set of trials |
| 1192 // modulates the delay-time until we declare a congestion event (and purge |
| 1193 // our queue). The second modulates the number of concurrent resolutions |
| 1194 // we do at any time. Users are in exactly one trial (or the default) during |
| 1195 // any one run, and hence only one experiment at a time. |
| 1196 // Experiment 1: |
| 1197 // Set congestion detection at 250, 500, or 750ms, rather than the 1 second |
| 1198 // default. |
| 1199 int max_250ms_prefetch = trial->AppendGroup("max_250ms_queue_prefetch", |
| 1200 kProbabilityPerGroup); |
| 1201 int max_500ms_prefetch = trial->AppendGroup("max_500ms_queue_prefetch", |
| 1202 kProbabilityPerGroup); |
| 1203 int max_750ms_prefetch = trial->AppendGroup("max_750ms_queue_prefetch", |
| 1204 kProbabilityPerGroup); |
| 1205 // Set congestion detection at 2 seconds instead of the 1 second default. |
| 1206 int max_2s_prefetch = trial->AppendGroup("max_2s_queue_prefetch", |
| 1207 kProbabilityPerGroup); |
| 1208 // Experiment 2: |
| 1209 // Set max simultaneous resoultions to 2, 4, or 6, and scale the congestion |
| 1210 // limit proportionally (so we don't impact average probability of asserting |
| 1211 // congesion very much). |
| 1212 int max_2_concurrent_prefetch = trial->AppendGroup( |
| 1213 "max_2 concurrent_prefetch", kProbabilityPerGroup); |
| 1214 int max_4_concurrent_prefetch = trial->AppendGroup( |
| 1215 "max_4 concurrent_prefetch", kProbabilityPerGroup); |
| 1216 int max_6_concurrent_prefetch = trial->AppendGroup( |
| 1217 "max_6 concurrent_prefetch", kProbabilityPerGroup); |
| 1218 |
| 1219 if (trial->group() != disabled_prefetch) { |
| 1220 // Initialize the DNS prefetch system. |
| 1221 size_t max_parallel_resolves = |
| 1222 chrome_browser_net::Predictor::kMaxSpeculativeParallelResolves; |
| 1223 int max_queueing_delay_ms = |
| 1224 chrome_browser_net::Predictor::kMaxSpeculativeResolveQueueDelayMs; |
| 1225 |
| 1226 if (trial->group() == max_2_concurrent_prefetch) |
| 1227 max_parallel_resolves = 2; |
| 1228 else if (trial->group() == max_4_concurrent_prefetch) |
| 1229 max_parallel_resolves = 4; |
| 1230 else if (trial->group() == max_6_concurrent_prefetch) |
| 1231 max_parallel_resolves = 6; |
| 1232 chrome_browser_net::Predictor::set_max_parallel_resolves( |
| 1233 max_parallel_resolves); |
| 1234 |
| 1235 if (trial->group() == max_250ms_prefetch) { |
| 1236 max_queueing_delay_ms = |
| 1237 (250 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1238 max_parallel_resolves; |
| 1239 } else if (trial->group() == max_500ms_prefetch) { |
| 1240 max_queueing_delay_ms = |
| 1241 (500 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1242 max_parallel_resolves; |
| 1243 } else if (trial->group() == max_750ms_prefetch) { |
| 1244 max_queueing_delay_ms = |
| 1245 (750 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1246 max_parallel_resolves; |
| 1247 } else if (trial->group() == max_2s_prefetch) { |
| 1248 max_queueing_delay_ms = |
| 1249 (2000 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1250 max_parallel_resolves; |
| 1251 } |
| 1252 chrome_browser_net::Predictor::set_max_queueing_delay( |
| 1253 max_queueing_delay_ms); |
| 1254 } |
| 1255 } |
| 1256 |
1175 // Test the impact on subsequent Google searches of getting suggestions from | 1257 // Test the impact on subsequent Google searches of getting suggestions from |
1176 // www.google.TLD instead of clients1.google.TLD. | 1258 // www.google.TLD instead of clients1.google.TLD. |
1177 void BrowserMainParts::SuggestPrefixFieldTrial() { | 1259 void BrowserMainParts::SuggestPrefixFieldTrial() { |
1178 const base::FieldTrial::Probability kSuggestPrefixDivisor = 100; | 1260 const base::FieldTrial::Probability kSuggestPrefixDivisor = 100; |
1179 // 50% probability. | 1261 // 50% probability. |
1180 const base::FieldTrial::Probability kSuggestPrefixProbability = 50; | 1262 const base::FieldTrial::Probability kSuggestPrefixProbability = 50; |
1181 // After Jan 1, 2012, it will always be in default group. | 1263 // After Jan 1, 2012, it will always be in default group. |
1182 scoped_refptr<base::FieldTrial> trial( | 1264 scoped_refptr<base::FieldTrial> trial( |
1183 new base::FieldTrial("SuggestHostPrefix", | 1265 new base::FieldTrial("SuggestHostPrefix", |
1184 kSuggestPrefixDivisor, "Default_Prefix", 2012, 1, 1)); | 1266 kSuggestPrefixDivisor, "Default_Prefix", 2012, 1, 1)); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 // If a policy is defining the number of active connections this field test | 1347 // If a policy is defining the number of active connections this field test |
1266 // shoud not be performed. | 1348 // shoud not be performed. |
1267 if (!proxy_policy_is_set) | 1349 if (!proxy_policy_is_set) |
1268 ProxyConnectionsFieldTrial(); | 1350 ProxyConnectionsFieldTrial(); |
1269 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); | 1351 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); |
1270 InstantFieldTrial::Activate(); | 1352 InstantFieldTrial::Activate(); |
1271 SpdyFieldTrial(); | 1353 SpdyFieldTrial(); |
1272 ConnectBackupJobsFieldTrial(); | 1354 ConnectBackupJobsFieldTrial(); |
1273 SuggestPrefixFieldTrial(); | 1355 SuggestPrefixFieldTrial(); |
1274 WarmConnectionFieldTrial(); | 1356 WarmConnectionFieldTrial(); |
| 1357 PredictorFieldTrial(); |
1275 } | 1358 } |
1276 | 1359 |
1277 // ----------------------------------------------------------------------------- | 1360 // ----------------------------------------------------------------------------- |
1278 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. | 1361 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. |
1279 | 1362 |
1280 #if defined(OS_CHROMEOS) | 1363 #if defined(OS_CHROMEOS) |
1281 // Allows authenticator to be invoked without adding refcounting. The instances | 1364 // Allows authenticator to be invoked without adding refcounting. The instances |
1282 // will delete themselves upon completion. | 1365 // will delete themselves upon completion. |
1283 DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin); | 1366 DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin); |
1284 #endif | 1367 #endif |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 #if defined(OS_WIN) | 1909 #if defined(OS_WIN) |
1827 // Registers Chrome with the Windows Restart Manager, which will restore the | 1910 // Registers Chrome with the Windows Restart Manager, which will restore the |
1828 // Chrome session when the computer is restarted after a system update. | 1911 // Chrome session when the computer is restarted after a system update. |
1829 // This could be run as late as WM_QUERYENDSESSION for system update reboots, | 1912 // This could be run as late as WM_QUERYENDSESSION for system update reboots, |
1830 // but should run on startup if extended to handle crashes/hangs/patches. | 1913 // but should run on startup if extended to handle crashes/hangs/patches. |
1831 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. | 1914 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. |
1832 if (base::win::GetVersion() >= base::win::VERSION_VISTA) | 1915 if (base::win::GetVersion() >= base::win::VERSION_VISTA) |
1833 RegisterApplicationRestart(parsed_command_line); | 1916 RegisterApplicationRestart(parsed_command_line); |
1834 #endif // OS_WIN | 1917 #endif // OS_WIN |
1835 | 1918 |
1836 // Initialize and maintain network predictor module, which handles DNS | |
1837 // pre-resolution, as well as TCP/IP connection pre-warming. | |
1838 // This also registers an observer to discard data when closing incognito | |
1839 // mode. | |
1840 bool preconnect_enabled = true; // Default status (easy to change!). | |
1841 if (parsed_command_line.HasSwitch(switches::kDisablePreconnect)) | |
1842 preconnect_enabled = false; | |
1843 else if (parsed_command_line.HasSwitch(switches::kEnablePreconnect)) | |
1844 preconnect_enabled = true; | |
1845 chrome_browser_net::PredictorInit dns_prefetch( | |
1846 user_prefs, | |
1847 local_state, | |
1848 preconnect_enabled); | |
1849 | |
1850 #if defined(OS_WIN) | 1919 #if defined(OS_WIN) |
1851 base::win::ScopedCOMInitializer com_initializer; | 1920 base::win::ScopedCOMInitializer com_initializer; |
1852 | 1921 |
1853 #if defined(GOOGLE_CHROME_BUILD) | 1922 #if defined(GOOGLE_CHROME_BUILD) |
1854 // Init the RLZ library. This just binds the dll and schedules a task on the | 1923 // Init the RLZ library. This just binds the dll and schedules a task on the |
1855 // file thread to be run sometime later. If this is the first run we record | 1924 // file thread to be run sometime later. If this is the first run we record |
1856 // the installation event. | 1925 // the installation event. |
1857 bool google_search_default = false; | 1926 bool google_search_default = false; |
1858 TemplateURLService* template_url_service = | 1927 TemplateURLService* template_url_service = |
1859 TemplateURLServiceFactory::GetForProfile(profile); | 1928 TemplateURLServiceFactory::GetForProfile(profile); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2170 // (environment variable is set, and valid). | 2239 // (environment variable is set, and valid). |
2171 std::string pre_read; | 2240 std::string pre_read; |
2172 if (env->GetVar(kEnvVar, &pre_read) && (pre_read == "0" || pre_read == "1")) { | 2241 if (env->GetVar(kEnvVar, &pre_read) && (pre_read == "0" || pre_read == "1")) { |
2173 std::string uma_name(name); | 2242 std::string uma_name(name); |
2174 uma_name += "_PreRead"; | 2243 uma_name += "_PreRead"; |
2175 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 2244 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
2176 AddPreReadHistogramTime(uma_name.c_str(), time); | 2245 AddPreReadHistogramTime(uma_name.c_str(), time); |
2177 } | 2246 } |
2178 #endif | 2247 #endif |
2179 } | 2248 } |
OLD | NEW |