Chromium Code Reviews| 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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 30)); | 596 30)); |
| 597 const int connect_backup_jobs_enabled = trial->kDefaultGroupNumber; | 597 const int connect_backup_jobs_enabled = trial->kDefaultGroupNumber; |
| 598 trial->AppendGroup("ConnectBackupJobsDisabled", | 598 trial->AppendGroup("ConnectBackupJobsDisabled", |
| 599 kConnectBackupJobsProbability); | 599 kConnectBackupJobsProbability); |
| 600 const int trial_group = trial->group(); | 600 const int trial_group = trial->group(); |
| 601 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( | 601 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( |
| 602 trial_group == connect_backup_jobs_enabled); | 602 trial_group == connect_backup_jobs_enabled); |
| 603 } | 603 } |
| 604 } | 604 } |
| 605 | 605 |
| 606 void BrowserMainParts::PredictorFieldTrial() { | |
| 607 const base::FieldTrial::Probability kDivisor = 1000; | |
| 608 // For each option (i.e., non-default), we have a fixed probability. | |
| 609 // 0.1% probability. | |
| 610 const base::FieldTrial::Probability kProbabilityPerGroup = 1; | |
| 611 | |
| 612 // After June 30, 2011 builds, it will always be in default group | |
| 613 // (default_enabled_prefetch). | |
| 614 scoped_refptr<base::FieldTrial> trial( | |
| 615 new base::FieldTrial("DnsImpact", kDivisor, | |
| 616 "default_enabled_prefetch", 2011, 10, 30)); | |
| 617 | |
| 618 // First option is to disable prefetching completely. | |
| 619 int disabled_prefetch = trial->AppendGroup("disabled_prefetch", | |
| 620 kProbabilityPerGroup); | |
| 621 | |
| 622 // We're running two experiments at the same time. The first set of trials | |
| 623 // modulates the delay-time until we declare a congestion event (and purge | |
| 624 // our queue). The second modulates the number of concurrent resolutions | |
| 625 // we do at any time. Users are in exactly one trial (or the default) during | |
| 626 // any one run, and hence only one experiment at a time. | |
| 627 // Experiment 1: | |
| 628 // Set congestion detection at 250, 500, or 750ms, rather than the 1 second | |
| 629 // default. | |
| 630 int max_250ms_prefetch = trial->AppendGroup("max_250ms_queue_prefetch", | |
| 631 kProbabilityPerGroup); | |
| 632 int max_500ms_prefetch = trial->AppendGroup("max_500ms_queue_prefetch", | |
| 633 kProbabilityPerGroup); | |
| 634 int max_750ms_prefetch = trial->AppendGroup("max_750ms_queue_prefetch", | |
| 635 kProbabilityPerGroup); | |
| 636 // Set congestion detection at 2 seconds instead of the 1 second default. | |
| 637 int max_2s_prefetch = trial->AppendGroup("max_2s_queue_prefetch", | |
| 638 kProbabilityPerGroup); | |
| 639 // Experiment 2: | |
| 640 // Set max simultaneous resoultions to 2, 4, or 6, and scale the congestion | |
| 641 // limit proportionally (so we don't impact average probability of asserting | |
| 642 // congesion very much). | |
| 643 int max_2_concurrent_prefetch = trial->AppendGroup( | |
| 644 "max_2 concurrent_prefetch", kProbabilityPerGroup); | |
| 645 int max_4_concurrent_prefetch = trial->AppendGroup( | |
| 646 "max_4 concurrent_prefetch", kProbabilityPerGroup); | |
| 647 int max_6_concurrent_prefetch = trial->AppendGroup( | |
| 648 "max_6 concurrent_prefetch", kProbabilityPerGroup); | |
| 649 | |
| 650 if (trial->group() != disabled_prefetch) { | |
| 651 // Initialize the DNS prefetch system. | |
| 652 size_t max_parallel_resolves = | |
| 653 chrome_browser_net::Predictor::kMaxSpeculativeParallelResolves; | |
| 654 int max_queueing_delay_ms = | |
| 655 chrome_browser_net::Predictor::kMaxSpeculativeResolveQueueDelayMs; | |
| 656 | |
| 657 if (trial->group() == max_2_concurrent_prefetch) | |
| 658 max_parallel_resolves = 2; | |
| 659 else if (trial->group() == max_4_concurrent_prefetch) | |
| 660 max_parallel_resolves = 4; | |
| 661 else if (trial->group() == max_6_concurrent_prefetch) | |
| 662 max_parallel_resolves = 6; | |
| 663 chrome_browser_net::Predictor::set_max_parallel_resolves( | |
| 664 max_parallel_resolves); | |
| 665 | |
| 666 if (trial->group() == max_250ms_prefetch) { | |
| 667 max_queueing_delay_ms = | |
| 668 (250 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / | |
| 669 max_parallel_resolves; | |
| 670 } else if (trial->group() == max_500ms_prefetch) { | |
| 671 max_queueing_delay_ms = | |
| 672 (500 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / | |
| 673 max_parallel_resolves; | |
| 674 } else if (trial->group() == max_750ms_prefetch) { | |
| 675 max_queueing_delay_ms = | |
| 676 (750 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / | |
| 677 max_parallel_resolves; | |
| 678 } else if (trial->group() == max_2s_prefetch) { | |
| 679 max_queueing_delay_ms = | |
| 680 (2000 * chrome_browser_net::Predictor::kTypicalSpeculativeGroupSize) / | |
| 681 max_parallel_resolves; | |
| 682 } | |
| 683 chrome_browser_net::Predictor::set_max_queueing_delay( | |
| 684 max_queueing_delay_ms); | |
| 685 } | |
| 686 } | |
| 687 | |
| 606 // Test the impact on subsequent Google searches of getting suggestions from | 688 // Test the impact on subsequent Google searches of getting suggestions from |
| 607 // www.google.TLD instead of clients1.google.TLD. | 689 // www.google.TLD instead of clients1.google.TLD. |
| 608 void BrowserMainParts::SuggestPrefixFieldTrial() { | 690 void BrowserMainParts::SuggestPrefixFieldTrial() { |
| 609 const base::FieldTrial::Probability kSuggestPrefixDivisor = 100; | 691 const base::FieldTrial::Probability kSuggestPrefixDivisor = 100; |
| 610 // 50% probability. | 692 // 50% probability. |
| 611 const base::FieldTrial::Probability kSuggestPrefixProbability = 50; | 693 const base::FieldTrial::Probability kSuggestPrefixProbability = 50; |
| 612 // After Jan 1, 2012, it will always be in default group. | 694 // After Jan 1, 2012, it will always be in default group. |
| 613 scoped_refptr<base::FieldTrial> trial( | 695 scoped_refptr<base::FieldTrial> trial( |
| 614 new base::FieldTrial("SuggestHostPrefix", | 696 new base::FieldTrial("SuggestHostPrefix", |
| 615 kSuggestPrefixDivisor, "Default_Prefix", 2012, 1, 1)); | 697 kSuggestPrefixDivisor, "Default_Prefix", 2012, 1, 1)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 // If a policy is defining the number of active connections this field test | 778 // If a policy is defining the number of active connections this field test |
| 697 // shoud not be performed. | 779 // shoud not be performed. |
| 698 if (!proxy_policy_is_set) | 780 if (!proxy_policy_is_set) |
| 699 ProxyConnectionsFieldTrial(); | 781 ProxyConnectionsFieldTrial(); |
| 700 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); | 782 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); |
| 701 InstantFieldTrial::Activate(); | 783 InstantFieldTrial::Activate(); |
| 702 SpdyFieldTrial(); | 784 SpdyFieldTrial(); |
| 703 ConnectBackupJobsFieldTrial(); | 785 ConnectBackupJobsFieldTrial(); |
| 704 SuggestPrefixFieldTrial(); | 786 SuggestPrefixFieldTrial(); |
| 705 WarmConnectionFieldTrial(); | 787 WarmConnectionFieldTrial(); |
| 788 PredictorFieldTrial(); | |
| 706 } | 789 } |
| 707 | 790 |
| 708 // ----------------------------------------------------------------------------- | 791 // ----------------------------------------------------------------------------- |
| 709 // TODO(viettrungluu): move more/rest of BrowserMain() into above structure | 792 // TODO(viettrungluu): move more/rest of BrowserMain() into above structure |
| 710 | 793 |
| 711 namespace { | 794 namespace { |
| 712 | 795 |
| 713 // This function provides some ways to test crash and assertion handling | 796 // This function provides some ways to test crash and assertion handling |
| 714 // behavior of the program. | 797 // behavior of the program. |
| 715 void HandleTestParameters(const CommandLine& command_line) { | 798 void HandleTestParameters(const CommandLine& command_line) { |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1842 #if defined(OS_WIN) | 1925 #if defined(OS_WIN) |
| 1843 // Registers Chrome with the Windows Restart Manager, which will restore the | 1926 // Registers Chrome with the Windows Restart Manager, which will restore the |
| 1844 // Chrome session when the computer is restarted after a system update. | 1927 // Chrome session when the computer is restarted after a system update. |
| 1845 // This could be run as late as WM_QUERYENDSESSION for system update reboots, | 1928 // This could be run as late as WM_QUERYENDSESSION for system update reboots, |
| 1846 // but should run on startup if extended to handle crashes/hangs/patches. | 1929 // but should run on startup if extended to handle crashes/hangs/patches. |
| 1847 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. | 1930 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. |
| 1848 if (base::win::GetVersion() >= base::win::VERSION_VISTA) | 1931 if (base::win::GetVersion() >= base::win::VERSION_VISTA) |
| 1849 RegisterApplicationRestart(parsed_command_line); | 1932 RegisterApplicationRestart(parsed_command_line); |
| 1850 #endif // OS_WIN | 1933 #endif // OS_WIN |
| 1851 | 1934 |
| 1852 // Initialize and maintain network predictor module, which handles DNS | |
| 1853 // pre-resolution, as well as TCP/IP connection pre-warming. | |
| 1854 // This also registers an observer to discard data when closing incognito | |
| 1855 // mode. | |
| 1856 bool preconnect_enabled = true; // Default status (easy to change!). | |
| 1857 if (parsed_command_line.HasSwitch(switches::kDisablePreconnect)) | |
| 1858 preconnect_enabled = false; | |
| 1859 else if (parsed_command_line.HasSwitch(switches::kEnablePreconnect)) | |
| 1860 preconnect_enabled = true; | |
| 1861 chrome_browser_net::PredictorInit dns_prefetch( | |
|
jar (doing other things)
2011/08/16 01:19:09
This historically has a side effect of starting to
willchan no longer on Chromium
2011/08/16 01:42:57
I think that the new code will actually invoke thi
| |
| 1862 user_prefs, | |
| 1863 local_state, | |
| 1864 preconnect_enabled); | |
| 1865 | |
| 1866 #if defined(OS_WIN) | 1935 #if defined(OS_WIN) |
| 1867 base::win::ScopedCOMInitializer com_initializer; | 1936 base::win::ScopedCOMInitializer com_initializer; |
| 1868 | 1937 |
| 1869 #if defined(GOOGLE_CHROME_BUILD) | 1938 #if defined(GOOGLE_CHROME_BUILD) |
| 1870 // Init the RLZ library. This just binds the dll and schedules a task on the | 1939 // Init the RLZ library. This just binds the dll and schedules a task on the |
| 1871 // file thread to be run sometime later. If this is the first run we record | 1940 // file thread to be run sometime later. If this is the first run we record |
| 1872 // the installation event. | 1941 // the installation event. |
| 1873 bool google_search_default = false; | 1942 bool google_search_default = false; |
| 1874 TemplateURLService* template_url_service = | 1943 TemplateURLService* template_url_service = |
| 1875 TemplateURLServiceFactory::GetForProfile(profile); | 1944 TemplateURLServiceFactory::GetForProfile(profile); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2158 #if defined(OS_CHROMEOS) | 2227 #if defined(OS_CHROMEOS) |
| 2159 // To be precise, logout (browser shutdown) is not yet done, but the | 2228 // To be precise, logout (browser shutdown) is not yet done, but the |
| 2160 // remaining work is negligible, hence we say LogoutDone here. | 2229 // remaining work is negligible, hence we say LogoutDone here. |
| 2161 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 2230 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
| 2162 false); | 2231 false); |
| 2163 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 2232 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
| 2164 #endif | 2233 #endif |
| 2165 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 2234 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
| 2166 return result_code; | 2235 return result_code; |
| 2167 } | 2236 } |
| OLD | NEW |