| 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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 "Unable to find locale data files. Please reinstall."; | 650 "Unable to find locale data files. Please reinstall."; |
| 651 } // namespace chrome_browser | 651 } // namespace chrome_browser |
| 652 | 652 |
| 653 // BrowserMainParts ------------------------------------------------------------ | 653 // BrowserMainParts ------------------------------------------------------------ |
| 654 | 654 |
| 655 ChromeBrowserMainParts::ChromeBrowserMainParts( | 655 ChromeBrowserMainParts::ChromeBrowserMainParts( |
| 656 const content::MainFunctionParams& parameters) | 656 const content::MainFunctionParams& parameters) |
| 657 : parameters_(parameters), | 657 : parameters_(parameters), |
| 658 parsed_command_line_(parameters.command_line), | 658 parsed_command_line_(parameters.command_line), |
| 659 result_code_(content::RESULT_CODE_NORMAL_EXIT), | 659 result_code_(content::RESULT_CODE_NORMAL_EXIT), |
| 660 startup_watcher_(new StartupTimeBomb()), |
| 660 shutdown_watcher_(new ShutdownWatcherHelper()), | 661 shutdown_watcher_(new ShutdownWatcherHelper()), |
| 661 record_search_engine_(false), | 662 record_search_engine_(false), |
| 662 translate_manager_(NULL), | 663 translate_manager_(NULL), |
| 663 profile_(NULL), | 664 profile_(NULL), |
| 664 run_message_loop_(true), | 665 run_message_loop_(true), |
| 665 notify_result_(ProcessSingleton::PROCESS_NONE), | 666 notify_result_(ProcessSingleton::PROCESS_NONE), |
| 666 is_first_run_(false), | 667 is_first_run_(false), |
| 667 first_run_ui_bypass_(false), | 668 first_run_ui_bypass_(false), |
| 668 metrics_(NULL), | 669 metrics_(NULL), |
| 669 local_state_(NULL), | 670 local_state_(NULL), |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 RLZTracker::InitRlzDelayed(is_first_run_, master_prefs_->ping_delay, | 1745 RLZTracker::InitRlzDelayed(is_first_run_, master_prefs_->ping_delay, |
| 1745 google_search_default, google_search_homepage); | 1746 google_search_default, google_search_homepage); |
| 1746 | 1747 |
| 1747 // Prime the RLZ cache for the home page access point so that its avaiable | 1748 // Prime the RLZ cache for the home page access point so that its avaiable |
| 1748 // for the startup page if needed (i.e., when the startup page is set to | 1749 // for the startup page if needed (i.e., when the startup page is set to |
| 1749 // the home page). | 1750 // the home page). |
| 1750 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, NULL); | 1751 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, NULL); |
| 1751 #endif // GOOGLE_CHROME_BUILD | 1752 #endif // GOOGLE_CHROME_BUILD |
| 1752 #endif // OS_WIN | 1753 #endif // OS_WIN |
| 1753 | 1754 |
| 1754 // Start watching for hangs during startup. We disarm this hang detector when | |
| 1755 // ThreadWatcher takes over or when browser is shutdown. | |
| 1756 StartupTimeBomb::Arm(base::TimeDelta::FromSeconds(300)); | |
| 1757 | |
| 1758 // Configure modules that need access to resources. | 1755 // Configure modules that need access to resources. |
| 1759 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); | 1756 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); |
| 1760 | 1757 |
| 1761 // In unittest mode, this will do nothing. In normal mode, this will create | 1758 // In unittest mode, this will do nothing. In normal mode, this will create |
| 1762 // the global GoogleURLTracker and IntranetRedirectDetector instances, which | 1759 // the global GoogleURLTracker and IntranetRedirectDetector instances, which |
| 1763 // will promptly go to sleep for five and seven seconds, respectively (to | 1760 // will promptly go to sleep for five and seven seconds, respectively (to |
| 1764 // avoid slowing startup), and wake up afterwards to see if they should do | 1761 // avoid slowing startup), and wake up afterwards to see if they should do |
| 1765 // anything else. | 1762 // anything else. |
| 1766 // | 1763 // |
| 1767 // A simpler way of doing all this would be to have some function which could | 1764 // A simpler way of doing all this would be to have some function which could |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1843 // The extension service may be available at this point. If the command line | 1840 // The extension service may be available at this point. If the command line |
| 1844 // specifies --uninstall-extension, attempt the uninstall extension startup | 1841 // specifies --uninstall-extension, attempt the uninstall extension startup |
| 1845 // action. | 1842 // action. |
| 1846 if (parsed_command_line().HasSwitch(switches::kUninstallExtension)) { | 1843 if (parsed_command_line().HasSwitch(switches::kUninstallExtension)) { |
| 1847 ExtensionsStartupUtil ext_startup_util; | 1844 ExtensionsStartupUtil ext_startup_util; |
| 1848 if (ext_startup_util.UninstallExtension(parsed_command_line(), profile_)) | 1845 if (ext_startup_util.UninstallExtension(parsed_command_line(), profile_)) |
| 1849 return content::RESULT_CODE_NORMAL_EXIT; | 1846 return content::RESULT_CODE_NORMAL_EXIT; |
| 1850 return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR; | 1847 return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR; |
| 1851 } | 1848 } |
| 1852 | 1849 |
| 1850 // Start watching for hangs during startup. We disarm this hang detector when |
| 1851 // ThreadWatcher takes over or when browser is shutdown or when |
| 1852 // startup_watcher_ is deleted. |
| 1853 startup_watcher_->Arm(base::TimeDelta::FromSeconds(300)); |
| 1854 |
| 1853 // Start watching for a hang. | 1855 // Start watching for a hang. |
| 1854 MetricsService::LogNeedForCleanShutdown(); | 1856 MetricsService::LogNeedForCleanShutdown(); |
| 1855 | 1857 |
| 1856 #if defined(OS_WIN) | 1858 #if defined(OS_WIN) |
| 1857 // We check this here because if the profile is OTR (chromeos possibility) | 1859 // We check this here because if the profile is OTR (chromeos possibility) |
| 1858 // it won't still be accessible after browser is destroyed. | 1860 // it won't still be accessible after browser is destroyed. |
| 1859 record_search_engine_ = is_first_run_ && !profile_->IsOffTheRecord(); | 1861 record_search_engine_ = is_first_run_ && !profile_->IsOffTheRecord(); |
| 1860 #endif | 1862 #endif |
| 1861 | 1863 |
| 1862 // ChildProcess:: is a misnomer unless you consider context. Use | 1864 // ChildProcess:: is a misnomer unless you consider context. Use |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1998 | 2000 |
| 1999 return true; | 2001 return true; |
| 2000 } | 2002 } |
| 2001 | 2003 |
| 2002 void ChromeBrowserMainParts::PostMainMessageLoopRun() { | 2004 void ChromeBrowserMainParts::PostMainMessageLoopRun() { |
| 2003 // Start watching for jank during shutdown. It gets disarmed when | 2005 // Start watching for jank during shutdown. It gets disarmed when |
| 2004 // |shutdown_watcher_| object is destructed. | 2006 // |shutdown_watcher_| object is destructed. |
| 2005 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(90)); | 2007 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(90)); |
| 2006 | 2008 |
| 2007 // Disarm the startup hang detector time bomb if it is still Arm'ed. | 2009 // Disarm the startup hang detector time bomb if it is still Arm'ed. |
| 2008 StartupTimeBomb::Disarm(); | 2010 startup_watcher_->Disarm(); |
| 2009 | 2011 |
| 2010 #if defined(OS_WIN) | 2012 #if defined(OS_WIN) |
| 2011 // If it's the first run, log the search engine chosen. We wait until | 2013 // If it's the first run, log the search engine chosen. We wait until |
| 2012 // shutdown because otherwise we can't be sure the user has finished | 2014 // shutdown because otherwise we can't be sure the user has finished |
| 2013 // selecting a search engine through the dialog reached from the first run | 2015 // selecting a search engine through the dialog reached from the first run |
| 2014 // bubble link. | 2016 // bubble link. |
| 2015 if (record_search_engine_) { | 2017 if (record_search_engine_) { |
| 2016 TemplateURLService* url_service = | 2018 TemplateURLService* url_service = |
| 2017 TemplateURLServiceFactory::GetForProfile(profile_); | 2019 TemplateURLServiceFactory::GetForProfile(profile_); |
| 2018 const TemplateURL* default_search_engine = | 2020 const TemplateURL* default_search_engine = |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2140 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && | 2142 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && |
| 2141 (pre_read == "0" || pre_read == "1")) { | 2143 (pre_read == "0" || pre_read == "1")) { |
| 2142 std::string uma_name(name); | 2144 std::string uma_name(name); |
| 2143 uma_name += "_PreRead"; | 2145 uma_name += "_PreRead"; |
| 2144 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 2146 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
| 2145 AddPreReadHistogramTime(uma_name.c_str(), time); | 2147 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 2146 } | 2148 } |
| 2147 #endif | 2149 #endif |
| 2148 #endif | 2150 #endif |
| 2149 } | 2151 } |
| OLD | NEW |