Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 #include "net/cookies/cookie_monster.h" | 144 #include "net/cookies/cookie_monster.h" |
| 145 #include "net/http/http_network_layer.h" | 145 #include "net/http/http_network_layer.h" |
| 146 #include "net/http/http_stream_factory.h" | 146 #include "net/http/http_stream_factory.h" |
| 147 #include "net/url_request/url_request.h" | 147 #include "net/url_request/url_request.h" |
| 148 #include "ui/base/l10n/l10n_util.h" | 148 #include "ui/base/l10n/l10n_util.h" |
| 149 #include "ui/base/layout.h" | 149 #include "ui/base/layout.h" |
| 150 #include "ui/base/resource/resource_bundle.h" | 150 #include "ui/base/resource/resource_bundle.h" |
| 151 #include "ui/strings/grit/app_locale_settings.h" | 151 #include "ui/strings/grit/app_locale_settings.h" |
| 152 | 152 |
| 153 #if defined(OS_ANDROID) | 153 #if defined(OS_ANDROID) |
| 154 #include "ui/base/resource/resource_bundle_android.h" | |
| 155 #endif // defined(OS_ANDROID) | |
| 156 | |
| 157 // TODO(bshe): Use defined(ANDROID_JAVA_UI) once | |
| 158 // codereview.chromium.org/1459793002 landed for | |
| 159 // dev_tools_discovery_provider_android.h. | |
| 160 #if defined(OS_ANDROID) && !defined(USE_AURA) | |
| 154 #include "chrome/browser/android/dev_tools_discovery_provider_android.h" | 161 #include "chrome/browser/android/dev_tools_discovery_provider_android.h" |
| 155 #include "chrome/browser/metrics/thread_watcher_android.h" | 162 #include "chrome/browser/metrics/thread_watcher_android.h" |
| 156 #include "ui/base/resource/resource_bundle_android.h" | |
| 157 #else | 163 #else |
| 158 #include "chrome/browser/devtools/chrome_devtools_discovery_provider.h" | 164 #include "chrome/browser/devtools/chrome_devtools_discovery_provider.h" |
| 159 #include "chrome/browser/feedback/feedback_profile_observer.h" | 165 #include "chrome/browser/feedback/feedback_profile_observer.h" |
| 160 #endif // defined(OS_ANDROID) | 166 #endif // defined(OS_ANDROID) && !defined(USE_AURA) |
| 161 | 167 |
| 162 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 168 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 163 #include "chrome/browser/first_run/upgrade_util_linux.h" | 169 #include "chrome/browser/first_run/upgrade_util_linux.h" |
| 164 #include "chrome/browser/sxs_linux.h" | 170 #include "chrome/browser/sxs_linux.h" |
| 165 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | 171 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 166 | 172 |
| 167 #if defined(OS_CHROMEOS) | 173 #if defined(OS_CHROMEOS) |
| 168 #include "chrome/browser/chromeos/settings/cros_settings.h" | 174 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 169 #include "chromeos/chromeos_switches.h" | 175 #include "chromeos/chromeos_switches.h" |
| 170 #include "chromeos/settings/cros_settings_names.h" | 176 #include "chromeos/settings/cros_settings_names.h" |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 // Don't record any metrics if UI was displayed before this point e.g. | 788 // Don't record any metrics if UI was displayed before this point e.g. |
| 783 // warning dialogs. | 789 // warning dialogs. |
| 784 if (startup_metric_utils::WasNonBrowserUIDisplayed()) | 790 if (startup_metric_utils::WasNonBrowserUIDisplayed()) |
| 785 return; | 791 return; |
| 786 | 792 |
| 787 bool is_first_run = false; | 793 bool is_first_run = false; |
| 788 #if !defined(OS_ANDROID) | 794 #if !defined(OS_ANDROID) |
| 789 // On Android, first run is handled in Java code, and the C++ side of Chrome | 795 // On Android, first run is handled in Java code, and the C++ side of Chrome |
| 790 // doesn't know if this is the first run. This will cause some inaccuracy in | 796 // doesn't know if this is the first run. This will cause some inaccuracy in |
| 791 // the UMA statistics, but this should be minor (first runs are rare). | 797 // the UMA statistics, but this should be minor (first runs are rare). |
| 798 // TODO(bshe): Figure out which first run code to use for Aura Android. See | |
| 799 // crbug.com/560498 | |
| 792 is_first_run = first_run::IsChromeFirstRun(); | 800 is_first_run = first_run::IsChromeFirstRun(); |
| 793 #endif // defined(OS_ANDROID) | 801 #endif // defined(OS_ANDROID) |
| 794 | 802 |
| 795 // Record collected startup metrics. | 803 // Record collected startup metrics. |
| 796 startup_metric_utils::RecordBrowserMainMessageLoopStart( | 804 startup_metric_utils::RecordBrowserMainMessageLoopStart( |
| 797 base::TimeTicks::Now(), is_first_run); | 805 base::TimeTicks::Now(), is_first_run); |
| 798 } | 806 } |
| 799 | 807 |
| 800 // ----------------------------------------------------------------------------- | 808 // ----------------------------------------------------------------------------- |
| 801 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. | 809 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 855 | 863 |
| 856 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 864 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 857 chrome_extra_parts_[i]->PostMainMessageLoopStart(); | 865 chrome_extra_parts_[i]->PostMainMessageLoopStart(); |
| 858 } | 866 } |
| 859 | 867 |
| 860 int ChromeBrowserMainParts::PreCreateThreads() { | 868 int ChromeBrowserMainParts::PreCreateThreads() { |
| 861 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); | 869 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); |
| 862 result_code_ = PreCreateThreadsImpl(); | 870 result_code_ = PreCreateThreadsImpl(); |
| 863 | 871 |
| 864 if (result_code_ == content::RESULT_CODE_NORMAL_EXIT) { | 872 if (result_code_ == content::RESULT_CODE_NORMAL_EXIT) { |
| 865 #if !defined(OS_ANDROID) | 873 // TODO(bshe): Use !defined(ANDROID_JAVA_UI) once |
| 874 // codereview.chromium.org/1459793002 landed. | |
| 875 #if !defined(OS_ANDROID) || defined(USE_AURA) | |
| 866 // These members must be initialized before exiting this function normally. | 876 // These members must be initialized before exiting this function normally. |
| 867 DCHECK(master_prefs_.get()); | 877 DCHECK(master_prefs_.get()); |
| 868 DCHECK(browser_creator_.get()); | 878 DCHECK(browser_creator_.get()); |
| 869 #endif // !defined(OS_ANDROID) | 879 #endif // !defined(OS_ANDROID) || defined(USE_AURA) |
| 870 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 880 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 871 chrome_extra_parts_[i]->PreCreateThreads(); | 881 chrome_extra_parts_[i]->PreCreateThreads(); |
| 872 } | 882 } |
| 873 | 883 |
| 874 return result_code_; | 884 return result_code_; |
| 875 } | 885 } |
| 876 | 886 |
| 877 int ChromeBrowserMainParts::PreCreateThreadsImpl() { | 887 int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
| 878 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreadsImpl") | 888 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreadsImpl") |
| 879 run_message_loop_ = false; | 889 run_message_loop_ = false; |
| 880 #if !defined(OS_ANDROID) | 890 #if !defined(OS_ANDROID) |
| 881 chrome::MaybeShowInvalidUserDataDirWarningDialog(); | 891 chrome::MaybeShowInvalidUserDataDirWarningDialog(); |
| 882 #endif // !defined(OS_ANDROID) | 892 #endif // !defined(OS_ANDROID) |
| 883 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)) | 893 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)) |
| 884 return chrome::RESULT_CODE_MISSING_DATA; | 894 return chrome::RESULT_CODE_MISSING_DATA; |
| 885 | 895 |
| 886 // Force MediaCaptureDevicesDispatcher to be created on UI thread. | 896 // Force MediaCaptureDevicesDispatcher to be created on UI thread. |
| 887 MediaCaptureDevicesDispatcher::GetInstance(); | 897 MediaCaptureDevicesDispatcher::GetInstance(); |
| 888 | 898 |
| 889 // Android's first run is done in Java instead of native. | 899 // Android's first run is done in Java instead of native. |
| 900 // TODO(bshe): Figure out which first run code to use for Aura Android. See | |
| 901 // crbug.com/560498 | |
| 890 #if !defined(OS_ANDROID) | 902 #if !defined(OS_ANDROID) |
| 891 process_singleton_.reset(new ChromeProcessSingleton( | 903 process_singleton_.reset(new ChromeProcessSingleton( |
| 892 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); | 904 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); |
| 893 | 905 |
| 894 // Cache first run state early. | 906 // Cache first run state early. |
| 895 first_run::IsChromeFirstRun(); | 907 first_run::IsChromeFirstRun(); |
| 896 #endif // !defined(OS_ANDROID) | 908 #endif // !defined(OS_ANDROID) |
| 897 | 909 |
| 898 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = | 910 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = |
| 899 JsonPrefStore::GetTaskRunnerForFile( | 911 JsonPrefStore::GetTaskRunnerForFile( |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 917 tracked_objects::ThreadData::Status status = | 929 tracked_objects::ThreadData::Status status = |
| 918 tracked_objects::ThreadData::PROFILING_ACTIVE; | 930 tracked_objects::ThreadData::PROFILING_ACTIVE; |
| 919 if (flag.compare("0") != 0) | 931 if (flag.compare("0") != 0) |
| 920 status = tracked_objects::ThreadData::DEACTIVATED; | 932 status = tracked_objects::ThreadData::DEACTIVATED; |
| 921 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); | 933 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); |
| 922 } | 934 } |
| 923 | 935 |
| 924 local_state_ = InitializeLocalState( | 936 local_state_ = InitializeLocalState( |
| 925 local_state_task_runner.get(), parsed_command_line()); | 937 local_state_task_runner.get(), parsed_command_line()); |
| 926 | 938 |
| 927 #if !defined(OS_ANDROID) | 939 // TODO(bshe): Use !defined(ANDROID_JAVA_UI) once |
| 940 // codereview.chromium.org/1459793002 landed. | |
| 941 #if !defined(OS_ANDROID) || defined(USE_AURA) | |
| 928 // These members must be initialized before returning from this function. | 942 // These members must be initialized before returning from this function. |
| 929 master_prefs_.reset(new first_run::MasterPrefs); | 943 master_prefs_.reset(new first_run::MasterPrefs); |
| 930 // Android doesn't use StartupBrowserCreator. | 944 // Android doesn't use StartupBrowserCreator. |
| 931 browser_creator_.reset(new StartupBrowserCreator); | 945 browser_creator_.reset(new StartupBrowserCreator); |
| 932 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver | 946 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver |
| 933 chrome::UMABrowsingActivityObserver::Init(); | 947 chrome::UMABrowsingActivityObserver::Init(); |
| 934 #endif // !defined(OS_ANDROID) | 948 #endif // !defined(OS_ANDROID) || defined(USE_AURA) |
| 935 | 949 |
| 936 #if !defined(OS_CHROMEOS) | 950 #if !defined(OS_CHROMEOS) |
| 937 // Convert active labs into switches. This needs to be done before | 951 // Convert active labs into switches. This needs to be done before |
| 938 // ResourceBundle::InitSharedInstanceWithLocale as some loaded resources are | 952 // ResourceBundle::InitSharedInstanceWithLocale as some loaded resources are |
| 939 // affected by experiment flags (--touch-optimized-ui in particular). | 953 // affected by experiment flags (--touch-optimized-ui in particular). |
| 940 // On ChromeOS system level flags are applied from the device settings from | 954 // On ChromeOS system level flags are applied from the device settings from |
| 941 // the session manager. | 955 // the session manager. |
| 942 { | 956 { |
| 943 TRACE_EVENT0("startup", | 957 TRACE_EVENT0("startup", |
| 944 "ChromeBrowserMainParts::PreCreateThreadsImpl:ConvertFlags"); | 958 "ChromeBrowserMainParts::PreCreateThreadsImpl:ConvertFlags"); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 999 } | 1013 } |
| 1000 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; | 1014 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; |
| 1001 browser_process_->SetApplicationLocale(loaded_locale); | 1015 browser_process_->SetApplicationLocale(loaded_locale); |
| 1002 | 1016 |
| 1003 { | 1017 { |
| 1004 TRACE_EVENT0("startup", | 1018 TRACE_EVENT0("startup", |
| 1005 "ChromeBrowserMainParts::PreCreateThreadsImpl:AddDataPack"); | 1019 "ChromeBrowserMainParts::PreCreateThreadsImpl:AddDataPack"); |
| 1006 base::FilePath resources_pack_path; | 1020 base::FilePath resources_pack_path; |
| 1007 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); | 1021 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
| 1008 #if defined(OS_ANDROID) | 1022 #if defined(OS_ANDROID) |
| 1023 // Uses Android resources even without ANDROID_JAVA_UI. | |
| 1009 ui::LoadMainAndroidPackFile("assets/resources.pak", resources_pack_path); | 1024 ui::LoadMainAndroidPackFile("assets/resources.pak", resources_pack_path); |
| 1010 #else | 1025 #else |
| 1011 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 1026 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 1012 resources_pack_path, ui::SCALE_FACTOR_NONE); | 1027 resources_pack_path, ui::SCALE_FACTOR_NONE); |
| 1013 #endif // defined(OS_ANDROID) | 1028 #endif // defined(OS_ANDROID) |
| 1014 } | 1029 } |
| 1015 #endif // defined(OS_MACOSX) | 1030 #endif // defined(OS_MACOSX) |
| 1016 | 1031 |
| 1017 // Android does first run in Java instead of native. | 1032 // Android does first run in Java instead of native. |
| 1018 // Chrome OS has its own out-of-box-experience code. | 1033 // Chrome OS has its own out-of-box-experience code. |
| 1034 // TODO(bshe): Figure out which first run code to use for Aura Android. See | |
| 1035 // crbug.com/560498 | |
| 1019 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 1036 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| 1020 // On first run, we need to process the predictor preferences before the | 1037 // On first run, we need to process the predictor preferences before the |
| 1021 // browser's profile_manager object is created, but after ResourceBundle | 1038 // browser's profile_manager object is created, but after ResourceBundle |
| 1022 // is initialized. | 1039 // is initialized. |
| 1023 if (first_run::IsChromeFirstRun()) { | 1040 if (first_run::IsChromeFirstRun()) { |
| 1024 first_run::ProcessMasterPreferencesResult pmp_result = | 1041 first_run::ProcessMasterPreferencesResult pmp_result = |
| 1025 first_run::ProcessMasterPreferences(user_data_dir_, | 1042 first_run::ProcessMasterPreferences(user_data_dir_, |
| 1026 master_prefs_.get()); | 1043 master_prefs_.get()); |
| 1027 if (pmp_result == first_run::EULA_EXIT_NOW) | 1044 if (pmp_result == first_run::EULA_EXIT_NOW) |
| 1028 return chrome::RESULT_CODE_EULA_REFUSED; | 1045 return chrome::RESULT_CODE_EULA_REFUSED; |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1442 base::TimeTicks::Now() - start_time_step1); | 1459 base::TimeTicks::Now() - start_time_step1); |
| 1443 | 1460 |
| 1444 // This step is costly and is already measured in Startup.CreateFirstProfile | 1461 // This step is costly and is already measured in Startup.CreateFirstProfile |
| 1445 // and more directly Profile.CreateAndInitializeProfile. | 1462 // and more directly Profile.CreateAndInitializeProfile. |
| 1446 profile_ = CreatePrimaryProfile(parameters(), | 1463 profile_ = CreatePrimaryProfile(parameters(), |
| 1447 user_data_dir_, | 1464 user_data_dir_, |
| 1448 parsed_command_line()); | 1465 parsed_command_line()); |
| 1449 if (!profile_) | 1466 if (!profile_) |
| 1450 return content::RESULT_CODE_NORMAL_EXIT; | 1467 return content::RESULT_CODE_NORMAL_EXIT; |
| 1451 | 1468 |
| 1452 #if !defined(OS_ANDROID) | 1469 // TODO(bshe): Use !defined(ANDROID_JAVA_UI) once |
| 1470 // codereview.chromium.org/1459793002 landed. | |
| 1471 #if !defined(OS_ANDROID) || defined(USE_AURA) | |
| 1453 const base::TimeTicks start_time_step2 = base::TimeTicks::Now(); | 1472 const base::TimeTicks start_time_step2 = base::TimeTicks::Now(); |
| 1454 // The first run sentinel must be created after the process singleton was | 1473 // The first run sentinel must be created after the process singleton was |
| 1455 // grabbed and no early return paths were otherwise hit above. | 1474 // grabbed and no early return paths were otherwise hit above. |
| 1456 first_run::CreateSentinelIfNeeded(); | 1475 first_run::CreateSentinelIfNeeded(); |
| 1457 #endif // !defined(OS_ANDROID) | 1476 #endif // !defined(OS_ANDROID) || defined(USE_AURA) |
| 1458 | 1477 |
| 1459 #if defined(ENABLE_BACKGROUND) | 1478 #if defined(ENABLE_BACKGROUND) |
| 1460 // Autoload any profiles which are running background apps. | 1479 // Autoload any profiles which are running background apps. |
| 1461 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. | 1480 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. |
| 1462 browser_process_->profile_manager()->AutoloadProfiles(); | 1481 browser_process_->profile_manager()->AutoloadProfiles(); |
| 1463 #endif // defined(ENABLE_BACKGROUND) | 1482 #endif // defined(ENABLE_BACKGROUND) |
| 1464 // Post-profile init --------------------------------------------------------- | 1483 // Post-profile init --------------------------------------------------------- |
| 1465 | 1484 |
| 1466 TranslateService::Initialize(); | 1485 TranslateService::Initialize(); |
| 1467 | 1486 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1489 | 1508 |
| 1490 // Create an instance of GpuModeManager to watch gpu mode pref change. | 1509 // Create an instance of GpuModeManager to watch gpu mode pref change. |
| 1491 g_browser_process->gpu_mode_manager(); | 1510 g_browser_process->gpu_mode_manager(); |
| 1492 | 1511 |
| 1493 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 1512 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| 1494 // Show the First Run UI if this is the first time Chrome has been run on | 1513 // Show the First Run UI if this is the first time Chrome has been run on |
| 1495 // this computer, or we're being compelled to do so by a command line flag. | 1514 // this computer, or we're being compelled to do so by a command line flag. |
| 1496 // Note that this be done _after_ the PrefService is initialized and all | 1515 // Note that this be done _after_ the PrefService is initialized and all |
| 1497 // preferences are registered, since some of the code that the importer | 1516 // preferences are registered, since some of the code that the importer |
| 1498 // touches reads preferences. | 1517 // touches reads preferences. |
| 1518 // TODO(bshe): Figure out which first run code to use for Aura Android. See | |
| 1519 // crbug.com/560498 | |
| 1499 if (first_run::IsChromeFirstRun()) { | 1520 if (first_run::IsChromeFirstRun()) { |
| 1500 first_run::AutoImport(profile_, | 1521 first_run::AutoImport(profile_, |
| 1501 master_prefs_->homepage_defined, | 1522 master_prefs_->homepage_defined, |
| 1502 master_prefs_->do_import_items, | 1523 master_prefs_->do_import_items, |
| 1503 master_prefs_->dont_import_items, | 1524 master_prefs_->dont_import_items, |
| 1504 master_prefs_->import_bookmarks_path); | 1525 master_prefs_->import_bookmarks_path); |
| 1505 | 1526 |
| 1506 // Note: this can pop the first run consent dialog on linux. | 1527 // Note: this can pop the first run consent dialog on linux. |
| 1507 first_run::DoPostImportTasks(profile_, | 1528 first_run::DoPostImportTasks(profile_, |
| 1508 master_prefs_->make_chrome_default_for_user); | 1529 master_prefs_->make_chrome_default_for_user); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1623 // instead? | 1644 // instead? |
| 1624 CloudPrintProxyServiceFactory::GetForProfile(profile_); | 1645 CloudPrintProxyServiceFactory::GetForProfile(profile_); |
| 1625 #endif // defined(ENABLE_PRINT_PREVIEW) | 1646 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 1626 | 1647 |
| 1627 // Start watching all browser threads for responsiveness. | 1648 // Start watching all browser threads for responsiveness. |
| 1628 metrics::MetricsService::SetExecutionPhase( | 1649 metrics::MetricsService::SetExecutionPhase( |
| 1629 metrics::MetricsService::THREAD_WATCHER_START, | 1650 metrics::MetricsService::THREAD_WATCHER_START, |
| 1630 g_browser_process->local_state()); | 1651 g_browser_process->local_state()); |
| 1631 ThreadWatcherList::StartWatchingAll(parsed_command_line()); | 1652 ThreadWatcherList::StartWatchingAll(parsed_command_line()); |
| 1632 | 1653 |
| 1633 #if defined(OS_ANDROID) | 1654 // TODO(bshe): Aura Android may need this call. See crbug.com/565317. |
| 1655 #if defined(OS_ANDROID) && !defined(USE_AURA) | |
| 1634 ThreadWatcherAndroid::RegisterApplicationStatusListener(); | 1656 ThreadWatcherAndroid::RegisterApplicationStatusListener(); |
| 1635 #endif // defined(OS_ANDROID) | 1657 #endif // defined(OS_ANDROID) && !defined(USE_AURA) |
| 1636 | 1658 |
| 1637 #if !defined(DISABLE_NACL) | 1659 #if !defined(DISABLE_NACL) |
| 1638 BrowserThread::PostTask( | 1660 BrowserThread::PostTask( |
| 1639 BrowserThread::IO, | 1661 BrowserThread::IO, |
| 1640 FROM_HERE, | 1662 FROM_HERE, |
| 1641 base::Bind(nacl::NaClProcessHost::EarlyStartup)); | 1663 base::Bind(nacl::NaClProcessHost::EarlyStartup)); |
| 1642 #endif // !defined(DISABLE_NACL) | 1664 #endif // !defined(DISABLE_NACL) |
| 1643 | 1665 |
| 1644 // Make sure initial prefs are recorded | 1666 // Make sure initial prefs are recorded |
| 1645 PrefMetricsService::Factory::GetForProfile(profile_); | 1667 PrefMetricsService::Factory::GetForProfile(profile_); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1662 #if defined(OS_ANDROID) | 1684 #if defined(OS_ANDROID) |
| 1663 variations::VariationsService* variations_service = | 1685 variations::VariationsService* variations_service = |
| 1664 browser_process_->variations_service(); | 1686 browser_process_->variations_service(); |
| 1665 if (variations_service) { | 1687 if (variations_service) { |
| 1666 // Just initialize the policy prefs service here. Variations seed fetching | 1688 // Just initialize the policy prefs service here. Variations seed fetching |
| 1667 // will be initialized when the app enters foreground mode. | 1689 // will be initialized when the app enters foreground mode. |
| 1668 variations_service->set_policy_pref_service(profile_->GetPrefs()); | 1690 variations_service->set_policy_pref_service(profile_->GetPrefs()); |
| 1669 } | 1691 } |
| 1670 translate::TranslateDownloadManager::RequestLanguageList( | 1692 translate::TranslateDownloadManager::RequestLanguageList( |
| 1671 profile_->GetPrefs()); | 1693 profile_->GetPrefs()); |
| 1672 | |
| 1673 #else | 1694 #else |
| 1674 // Most general initialization is behind us, but opening a | 1695 // Most general initialization is behind us, but opening a |
| 1675 // tab and/or session restore and such is still to be done. | 1696 // tab and/or session restore and such is still to be done. |
| 1676 base::TimeTicks browser_open_start = base::TimeTicks::Now(); | 1697 base::TimeTicks browser_open_start = base::TimeTicks::Now(); |
| 1677 | 1698 |
| 1678 // We are in regular browser boot sequence. Open initial tabs and enter the | 1699 // We are in regular browser boot sequence. Open initial tabs and enter the |
| 1679 // main message loop. | 1700 // main message loop. |
| 1680 std::vector<Profile*> last_opened_profiles; | 1701 std::vector<Profile*> last_opened_profiles; |
| 1681 #if !defined(OS_CHROMEOS) | 1702 #if !defined(OS_CHROMEOS) |
| 1682 // On ChromeOS multiple profiles doesn't apply, and will break if we load | 1703 // On ChromeOS multiple profiles doesn't apply, and will break if we load |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1739 } | 1760 } |
| 1740 } | 1761 } |
| 1741 run_message_loop_ = started; | 1762 run_message_loop_ = started; |
| 1742 browser_creator_.reset(); | 1763 browser_creator_.reset(); |
| 1743 | 1764 |
| 1744 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) // http://crbug.com/426393 | 1765 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) // http://crbug.com/426393 |
| 1745 if (g_browser_process->metrics_service()->reporting_active()) | 1766 if (g_browser_process->metrics_service()->reporting_active()) |
| 1746 content::StartPowerUsageMonitor(); | 1767 content::StartPowerUsageMonitor(); |
| 1747 #endif // !defined(OS_LINUX) || defined(OS_CHROMEOS) | 1768 #endif // !defined(OS_LINUX) || defined(OS_CHROMEOS) |
| 1748 | 1769 |
| 1770 #if !defined(OS_ANDROID) | |
|
mfomitchev
2015/12/03 17:56:25
We are already inside and #else (for #if in line 1
bshe
2015/12/03 18:18:18
Good catch! Looks like I accidentally removed my c
| |
| 1749 process_power_collector_.reset(new ProcessPowerCollector); | 1771 process_power_collector_.reset(new ProcessPowerCollector); |
| 1750 process_power_collector_->Initialize(); | 1772 process_power_collector_->Initialize(); |
| 1751 #endif // !defined(OS_ANDROID) | 1773 #endif // !defined(OS_ANDROID) |
| 1774 #endif // !defined(OS_ANDROID) && !defined(USE_AURA) | |
|
mfomitchev
2015/12/03 17:56:25
Notably, we should never have
!defined(OS_ANDROID)
bshe
2015/12/03 18:18:18
oops. missed this one. Done
| |
| 1752 | 1775 |
| 1753 PostBrowserStart(); | 1776 PostBrowserStart(); |
| 1754 | 1777 |
| 1755 if (parameters().ui_task) { | 1778 if (parameters().ui_task) { |
| 1756 parameters().ui_task->Run(); | 1779 parameters().ui_task->Run(); |
| 1757 delete parameters().ui_task; | 1780 delete parameters().ui_task; |
| 1758 run_message_loop_ = false; | 1781 run_message_loop_ = false; |
| 1759 } | 1782 } |
| 1760 #if defined(OS_ANDROID) | 1783 #if defined(OS_ANDROID) |
| 1761 // We never run the C++ main loop on Android, since the UI thread message | 1784 // We never run the C++ main loop on Android, since the UI thread message |
| 1762 // loop is controlled by the OS, so this is as close as we can get to | 1785 // loop is controlled by the OS, so this is as close as we can get to |
| 1763 // the start of the main loop. | 1786 // the start of the main loop. |
| 1764 if (result_code_ <= 0) { | 1787 if (result_code_ <= 0) { |
| 1765 RecordBrowserStartupTime(); | 1788 RecordBrowserStartupTime(); |
| 1766 } | 1789 } |
| 1767 #endif // defined(OS_ANDROID) | 1790 #endif // defined(OS_ANDROID) |
| 1768 | 1791 |
| 1769 #if !defined(OS_ANDROID) | 1792 // TODO(bshe): Use !defined(ANDROID_JAVA_UI) once |
| 1793 // codereview.chromium.org/1459793002 landed. | |
| 1794 #if !defined(OS_ANDROID) || defined(USE_AURA) | |
| 1770 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep3Time", | 1795 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep3Time", |
| 1771 base::TimeTicks::Now() - start_time_step3); | 1796 base::TimeTicks::Now() - start_time_step3); |
| 1772 #endif // !defined(OS_ANDROID) | 1797 #endif // !defined(OS_ANDROID) || defined(USE_AURA) |
| 1773 | 1798 |
| 1774 return result_code_; | 1799 return result_code_; |
| 1775 } | 1800 } |
| 1776 | 1801 |
| 1777 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { | 1802 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 1778 // Trace the entry and exit of this method. We don't use the TRACE_EVENT0 | 1803 // Trace the entry and exit of this method. We don't use the TRACE_EVENT0 |
| 1779 // macro because the tracing infrastructure doesn't expect a synchronous event | 1804 // macro because the tracing infrastructure doesn't expect a synchronous event |
| 1780 // around the main loop of a thread. | 1805 // around the main loop of a thread. |
| 1781 ScopedMainMessageLoopRunEvent scoped_main_message_loop_run_event; | 1806 ScopedMainMessageLoopRunEvent scoped_main_message_loop_run_event; |
| 1782 #if defined(OS_ANDROID) | 1807 #if defined(OS_ANDROID) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1882 chromeos::CrosSettings::Shutdown(); | 1907 chromeos::CrosSettings::Shutdown(); |
| 1883 #endif // defined(OS_CHROMEOS) | 1908 #endif // defined(OS_CHROMEOS) |
| 1884 #endif // defined(OS_ANDROID) | 1909 #endif // defined(OS_ANDROID) |
| 1885 } | 1910 } |
| 1886 | 1911 |
| 1887 // Public members: | 1912 // Public members: |
| 1888 | 1913 |
| 1889 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1914 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 1890 chrome_extra_parts_.push_back(parts); | 1915 chrome_extra_parts_.push_back(parts); |
| 1891 } | 1916 } |
| OLD | NEW |