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.h" | 58 #include "chrome/browser/net/predictor_api.h" |
59 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 59 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
60 #include "chrome/browser/plugin_prefs.h" | 60 #include "chrome/browser/plugin_prefs.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 | |
1257 // Test the impact on subsequent Google searches of getting suggestions from | 1175 // Test the impact on subsequent Google searches of getting suggestions from |
1258 // www.google.TLD instead of clients1.google.TLD. | 1176 // www.google.TLD instead of clients1.google.TLD. |
1259 void BrowserMainParts::SuggestPrefixFieldTrial() { | 1177 void BrowserMainParts::SuggestPrefixFieldTrial() { |
1260 const base::FieldTrial::Probability kSuggestPrefixDivisor = 100; | 1178 const base::FieldTrial::Probability kSuggestPrefixDivisor = 100; |
1261 // 50% probability. | 1179 // 50% probability. |
1262 const base::FieldTrial::Probability kSuggestPrefixProbability = 50; | 1180 const base::FieldTrial::Probability kSuggestPrefixProbability = 50; |
1263 // After Jan 1, 2012, it will always be in default group. | 1181 // After Jan 1, 2012, it will always be in default group. |
1264 scoped_refptr<base::FieldTrial> trial( | 1182 scoped_refptr<base::FieldTrial> trial( |
1265 new base::FieldTrial("SuggestHostPrefix", | 1183 new base::FieldTrial("SuggestHostPrefix", |
1266 kSuggestPrefixDivisor, "Default_Prefix", 2012, 1, 1)); | 1184 kSuggestPrefixDivisor, "Default_Prefix", 2012, 1, 1)); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 // If a policy is defining the number of active connections this field test | 1265 // If a policy is defining the number of active connections this field test |
1348 // shoud not be performed. | 1266 // shoud not be performed. |
1349 if (!proxy_policy_is_set) | 1267 if (!proxy_policy_is_set) |
1350 ProxyConnectionsFieldTrial(); | 1268 ProxyConnectionsFieldTrial(); |
1351 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); | 1269 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); |
1352 InstantFieldTrial::Activate(); | 1270 InstantFieldTrial::Activate(); |
1353 SpdyFieldTrial(); | 1271 SpdyFieldTrial(); |
1354 ConnectBackupJobsFieldTrial(); | 1272 ConnectBackupJobsFieldTrial(); |
1355 SuggestPrefixFieldTrial(); | 1273 SuggestPrefixFieldTrial(); |
1356 WarmConnectionFieldTrial(); | 1274 WarmConnectionFieldTrial(); |
1357 PredictorFieldTrial(); | |
1358 } | 1275 } |
1359 | 1276 |
1360 // ----------------------------------------------------------------------------- | 1277 // ----------------------------------------------------------------------------- |
1361 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. | 1278 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. |
1362 | 1279 |
1363 #if defined(OS_CHROMEOS) | 1280 #if defined(OS_CHROMEOS) |
1364 // Allows authenticator to be invoked without adding refcounting. The instances | 1281 // Allows authenticator to be invoked without adding refcounting. The instances |
1365 // will delete themselves upon completion. | 1282 // will delete themselves upon completion. |
1366 DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin); | 1283 DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin); |
1367 #endif | 1284 #endif |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 #if defined(OS_WIN) | 1837 #if defined(OS_WIN) |
1921 // Registers Chrome with the Windows Restart Manager, which will restore the | 1838 // Registers Chrome with the Windows Restart Manager, which will restore the |
1922 // Chrome session when the computer is restarted after a system update. | 1839 // Chrome session when the computer is restarted after a system update. |
1923 // This could be run as late as WM_QUERYENDSESSION for system update reboots, | 1840 // This could be run as late as WM_QUERYENDSESSION for system update reboots, |
1924 // but should run on startup if extended to handle crashes/hangs/patches. | 1841 // but should run on startup if extended to handle crashes/hangs/patches. |
1925 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. | 1842 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. |
1926 if (base::win::GetVersion() >= base::win::VERSION_VISTA) | 1843 if (base::win::GetVersion() >= base::win::VERSION_VISTA) |
1927 RegisterApplicationRestart(parsed_command_line); | 1844 RegisterApplicationRestart(parsed_command_line); |
1928 #endif // OS_WIN | 1845 #endif // OS_WIN |
1929 | 1846 |
| 1847 // Initialize and maintain network predictor module, which handles DNS |
| 1848 // pre-resolution, as well as TCP/IP connection pre-warming. |
| 1849 // This also registers an observer to discard data when closing incognito |
| 1850 // mode. |
| 1851 bool preconnect_enabled = true; // Default status (easy to change!). |
| 1852 if (parsed_command_line.HasSwitch(switches::kDisablePreconnect)) |
| 1853 preconnect_enabled = false; |
| 1854 else if (parsed_command_line.HasSwitch(switches::kEnablePreconnect)) |
| 1855 preconnect_enabled = true; |
| 1856 chrome_browser_net::PredictorInit dns_prefetch( |
| 1857 user_prefs, |
| 1858 local_state, |
| 1859 preconnect_enabled); |
| 1860 |
1930 #if defined(OS_WIN) | 1861 #if defined(OS_WIN) |
1931 base::win::ScopedCOMInitializer com_initializer; | 1862 base::win::ScopedCOMInitializer com_initializer; |
1932 | 1863 |
1933 #if defined(GOOGLE_CHROME_BUILD) | 1864 #if defined(GOOGLE_CHROME_BUILD) |
1934 // Init the RLZ library. This just binds the dll and schedules a task on the | 1865 // Init the RLZ library. This just binds the dll and schedules a task on the |
1935 // file thread to be run sometime later. If this is the first run we record | 1866 // file thread to be run sometime later. If this is the first run we record |
1936 // the installation event. | 1867 // the installation event. |
1937 bool google_search_default = false; | 1868 bool google_search_default = false; |
1938 TemplateURLService* template_url_service = | 1869 TemplateURLService* template_url_service = |
1939 TemplateURLServiceFactory::GetForProfile(profile); | 1870 TemplateURLServiceFactory::GetForProfile(profile); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2247 // (environment variable is set, and valid). | 2178 // (environment variable is set, and valid). |
2248 std::string pre_read; | 2179 std::string pre_read; |
2249 if (env->GetVar(kEnvVar, &pre_read) && (pre_read == "0" || pre_read == "1")) { | 2180 if (env->GetVar(kEnvVar, &pre_read) && (pre_read == "0" || pre_read == "1")) { |
2250 std::string uma_name(name); | 2181 std::string uma_name(name); |
2251 uma_name += "_PreRead"; | 2182 uma_name += "_PreRead"; |
2252 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 2183 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
2253 AddPreReadHistogramTime(uma_name.c_str(), time); | 2184 AddPreReadHistogramTime(uma_name.c_str(), time); |
2254 } | 2185 } |
2255 #endif | 2186 #endif |
2256 } | 2187 } |
OLD | NEW |