| 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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 30)); | 1157 30)); |
| 1158 const int connect_backup_jobs_enabled = trial->kDefaultGroupNumber; | 1158 const int connect_backup_jobs_enabled = trial->kDefaultGroupNumber; |
| 1159 trial->AppendGroup("ConnectBackupJobsDisabled", | 1159 trial->AppendGroup("ConnectBackupJobsDisabled", |
| 1160 kConnectBackupJobsProbability); | 1160 kConnectBackupJobsProbability); |
| 1161 const int trial_group = trial->group(); | 1161 const int trial_group = trial->group(); |
| 1162 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( | 1162 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( |
| 1163 trial_group == connect_backup_jobs_enabled); | 1163 trial_group == connect_backup_jobs_enabled); |
| 1164 } | 1164 } |
| 1165 } | 1165 } |
| 1166 | 1166 |
| 1167 void BrowserMainParts::PredictorFieldTrial() { |
| 1168 const base::FieldTrial::Probability kDivisor = 1000; |
| 1169 // For each option (i.e., non-default), we have a fixed probability. |
| 1170 // 0.1% probability. |
| 1171 const base::FieldTrial::Probability kProbabilityPerGroup = 1; |
| 1172 |
| 1173 // After June 30, 2011 builds, it will always be in default group |
| 1174 // (default_enabled_prefetch). |
| 1175 scoped_refptr<base::FieldTrial> trial( |
| 1176 new base::FieldTrial("DnsImpact", kDivisor, |
| 1177 "default_enabled_prefetch", 2011, 10, 30)); |
| 1178 |
| 1179 // First option is to disable prefetching completely. |
| 1180 int disabled_prefetch = trial->AppendGroup("disabled_prefetch", |
| 1181 kProbabilityPerGroup); |
| 1182 |
| 1183 // We're running two experiments at the same time. The first set of trials |
| 1184 // modulates the delay-time until we declare a congestion event (and purge |
| 1185 // our queue). The second modulates the number of concurrent resolutions |
| 1186 // we do at any time. Users are in exactly one trial (or the default) during |
| 1187 // any one run, and hence only one experiment at a time. |
| 1188 // Experiment 1: |
| 1189 // Set congestion detection at 250, 500, or 750ms, rather than the 1 second |
| 1190 // default. |
| 1191 int max_250ms_prefetch = trial->AppendGroup("max_250ms_queue_prefetch", |
| 1192 kProbabilityPerGroup); |
| 1193 int max_500ms_prefetch = trial->AppendGroup("max_500ms_queue_prefetch", |
| 1194 kProbabilityPerGroup); |
| 1195 int max_750ms_prefetch = trial->AppendGroup("max_750ms_queue_prefetch", |
| 1196 kProbabilityPerGroup); |
| 1197 // Set congestion detection at 2 seconds instead of the 1 second default. |
| 1198 int max_2s_prefetch = trial->AppendGroup("max_2s_queue_prefetch", |
| 1199 kProbabilityPerGroup); |
| 1200 // Experiment 2: |
| 1201 // Set max simultaneous resoultions to 2, 4, or 6, and scale the congestion |
| 1202 // limit proportionally (so we don't impact average probability of asserting |
| 1203 // congesion very much). |
| 1204 int max_2_concurrent_prefetch = trial->AppendGroup( |
| 1205 "max_2 concurrent_prefetch", kProbabilityPerGroup); |
| 1206 int max_4_concurrent_prefetch = trial->AppendGroup( |
| 1207 "max_4 concurrent_prefetch", kProbabilityPerGroup); |
| 1208 int max_6_concurrent_prefetch = trial->AppendGroup( |
| 1209 "max_6 concurrent_prefetch", kProbabilityPerGroup); |
| 1210 |
| 1211 if (trial->group() != disabled_prefetch) { |
| 1212 // Initialize the DNS prefetch system. |
| 1213 size_t max_parallel_resolves = |
| 1214 chrome_browser_net::Predictor::kMaxSpeculativeParallelResolves; |
| 1215 int max_queueing_delay_ms = |
| 1216 chrome_browser_net::Predictor::kMaxSpeculativeResolveQueueDelayMs; |
| 1217 |
| 1218 if (trial->group() == max_2_concurrent_prefetch) |
| 1219 max_parallel_resolves = 2; |
| 1220 else if (trial->group() == max_4_concurrent_prefetch) |
| 1221 max_parallel_resolves = 4; |
| 1222 else if (trial->group() == max_6_concurrent_prefetch) |
| 1223 max_parallel_resolves = 6; |
| 1224 chrome_browser_net::Predictor::set_max_parallel_resolves( |
| 1225 max_parallel_resolves); |
| 1226 |
| 1227 if (trial->group() == max_250ms_prefetch) { |
| 1228 max_queueing_delay_ms = |
| 1229 (250 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1230 max_parallel_resolves; |
| 1231 } else if (trial->group() == max_500ms_prefetch) { |
| 1232 max_queueing_delay_ms = |
| 1233 (500 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1234 max_parallel_resolves; |
| 1235 } else if (trial->group() == max_750ms_prefetch) { |
| 1236 max_queueing_delay_ms = |
| 1237 (750 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1238 max_parallel_resolves; |
| 1239 } else if (trial->group() == max_2s_prefetch) { |
| 1240 max_queueing_delay_ms = |
| 1241 (2000 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / |
| 1242 max_parallel_resolves; |
| 1243 } |
| 1244 chrome_browser_net::Predictor::set_max_queueing_delay( |
| 1245 max_queueing_delay_ms); |
| 1246 } |
| 1247 } |
| 1248 |
| 1167 // Test the impact on subsequent Google searches of getting suggestions from | 1249 // Test the impact on subsequent Google searches of getting suggestions from |
| 1168 // www.google.TLD instead of clients1.google.TLD. | 1250 // www.google.TLD instead of clients1.google.TLD. |
| 1169 void BrowserMainParts::SuggestPrefixFieldTrial() { | 1251 void BrowserMainParts::SuggestPrefixFieldTrial() { |
| 1170 const base::FieldTrial::Probability kSuggestPrefixDivisor = 100; | 1252 const base::FieldTrial::Probability kSuggestPrefixDivisor = 100; |
| 1171 // 50% probability. | 1253 // 50% probability. |
| 1172 const base::FieldTrial::Probability kSuggestPrefixProbability = 50; | 1254 const base::FieldTrial::Probability kSuggestPrefixProbability = 50; |
| 1173 // After Jan 1, 2012, it will always be in default group. | 1255 // After Jan 1, 2012, it will always be in default group. |
| 1174 scoped_refptr<base::FieldTrial> trial( | 1256 scoped_refptr<base::FieldTrial> trial( |
| 1175 new base::FieldTrial("SuggestHostPrefix", | 1257 new base::FieldTrial("SuggestHostPrefix", |
| 1176 kSuggestPrefixDivisor, "Default_Prefix", 2012, 1, 1)); | 1258 kSuggestPrefixDivisor, "Default_Prefix", 2012, 1, 1)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 // If a policy is defining the number of active connections this field test | 1339 // If a policy is defining the number of active connections this field test |
| 1258 // shoud not be performed. | 1340 // shoud not be performed. |
| 1259 if (!proxy_policy_is_set) | 1341 if (!proxy_policy_is_set) |
| 1260 ProxyConnectionsFieldTrial(); | 1342 ProxyConnectionsFieldTrial(); |
| 1261 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); | 1343 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); |
| 1262 InstantFieldTrial::Activate(); | 1344 InstantFieldTrial::Activate(); |
| 1263 SpdyFieldTrial(); | 1345 SpdyFieldTrial(); |
| 1264 ConnectBackupJobsFieldTrial(); | 1346 ConnectBackupJobsFieldTrial(); |
| 1265 SuggestPrefixFieldTrial(); | 1347 SuggestPrefixFieldTrial(); |
| 1266 WarmConnectionFieldTrial(); | 1348 WarmConnectionFieldTrial(); |
| 1349 PredictorFieldTrial(); |
| 1267 } | 1350 } |
| 1268 | 1351 |
| 1269 // ----------------------------------------------------------------------------- | 1352 // ----------------------------------------------------------------------------- |
| 1270 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. | 1353 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. |
| 1271 | 1354 |
| 1272 #if defined(OS_CHROMEOS) | 1355 #if defined(OS_CHROMEOS) |
| 1273 // Allows authenticator to be invoked without adding refcounting. The instances | 1356 // Allows authenticator to be invoked without adding refcounting. The instances |
| 1274 // will delete themselves upon completion. | 1357 // will delete themselves upon completion. |
| 1275 DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin); | 1358 DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin); |
| 1276 #endif | 1359 #endif |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1813 #if defined(OS_WIN) | 1896 #if defined(OS_WIN) |
| 1814 // Registers Chrome with the Windows Restart Manager, which will restore the | 1897 // Registers Chrome with the Windows Restart Manager, which will restore the |
| 1815 // Chrome session when the computer is restarted after a system update. | 1898 // Chrome session when the computer is restarted after a system update. |
| 1816 // This could be run as late as WM_QUERYENDSESSION for system update reboots, | 1899 // This could be run as late as WM_QUERYENDSESSION for system update reboots, |
| 1817 // but should run on startup if extended to handle crashes/hangs/patches. | 1900 // but should run on startup if extended to handle crashes/hangs/patches. |
| 1818 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. | 1901 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. |
| 1819 if (base::win::GetVersion() >= base::win::VERSION_VISTA) | 1902 if (base::win::GetVersion() >= base::win::VERSION_VISTA) |
| 1820 RegisterApplicationRestart(parsed_command_line); | 1903 RegisterApplicationRestart(parsed_command_line); |
| 1821 #endif // OS_WIN | 1904 #endif // OS_WIN |
| 1822 | 1905 |
| 1823 // Initialize and maintain network predictor module, which handles DNS | |
| 1824 // pre-resolution, as well as TCP/IP connection pre-warming. | |
| 1825 // This also registers an observer to discard data when closing incognito | |
| 1826 // mode. | |
| 1827 bool preconnect_enabled = true; // Default status (easy to change!). | |
| 1828 if (parsed_command_line.HasSwitch(switches::kDisablePreconnect)) | |
| 1829 preconnect_enabled = false; | |
| 1830 else if (parsed_command_line.HasSwitch(switches::kEnablePreconnect)) | |
| 1831 preconnect_enabled = true; | |
| 1832 chrome_browser_net::PredictorInit dns_prefetch( | |
| 1833 user_prefs, | |
| 1834 local_state, | |
| 1835 preconnect_enabled); | |
| 1836 | |
| 1837 #if defined(OS_WIN) | 1906 #if defined(OS_WIN) |
| 1838 base::win::ScopedCOMInitializer com_initializer; | 1907 base::win::ScopedCOMInitializer com_initializer; |
| 1839 | 1908 |
| 1840 #if defined(GOOGLE_CHROME_BUILD) | 1909 #if defined(GOOGLE_CHROME_BUILD) |
| 1841 // Init the RLZ library. This just binds the dll and schedules a task on the | 1910 // Init the RLZ library. This just binds the dll and schedules a task on the |
| 1842 // file thread to be run sometime later. If this is the first run we record | 1911 // file thread to be run sometime later. If this is the first run we record |
| 1843 // the installation event. | 1912 // the installation event. |
| 1844 bool google_search_default = false; | 1913 bool google_search_default = false; |
| 1845 TemplateURLService* template_url_service = | 1914 TemplateURLService* template_url_service = |
| 1846 TemplateURLServiceFactory::GetForProfile(profile); | 1915 TemplateURLServiceFactory::GetForProfile(profile); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2157 // (environment variable is set, and valid). | 2226 // (environment variable is set, and valid). |
| 2158 std::string pre_read; | 2227 std::string pre_read; |
| 2159 if (env->GetVar(kEnvVar, &pre_read) && (pre_read == "0" || pre_read == "1")) { | 2228 if (env->GetVar(kEnvVar, &pre_read) && (pre_read == "0" || pre_read == "1")) { |
| 2160 std::string uma_name(name); | 2229 std::string uma_name(name); |
| 2161 uma_name += "_PreRead"; | 2230 uma_name += "_PreRead"; |
| 2162 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 2231 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
| 2163 AddPreReadHistogramTime(uma_name.c_str(), time); | 2232 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 2164 } | 2233 } |
| 2165 #endif | 2234 #endif |
| 2166 } | 2235 } |
| OLD | NEW |