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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 // device_event_log must be initialized after the message loop. Calls to | 852 // device_event_log must be initialized after the message loop. Calls to |
853 // {DEVICE}_LOG prior to here will only be logged with VLOG. Some | 853 // {DEVICE}_LOG prior to here will only be logged with VLOG. Some |
854 // platforms (e.g. chromeos) may have already initialized this. | 854 // platforms (e.g. chromeos) may have already initialized this. |
855 if (!device_event_log::IsInitialized()) | 855 if (!device_event_log::IsInitialized()) |
856 device_event_log::Initialize(0 /* default max entries */); | 856 device_event_log::Initialize(0 /* default max entries */); |
857 | 857 |
858 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 858 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
859 chrome_extra_parts_[i]->PostMainMessageLoopStart(); | 859 chrome_extra_parts_[i]->PostMainMessageLoopStart(); |
860 } | 860 } |
861 | 861 |
862 int ChromeBrowserMainParts::PreCreateThreads() { | 862 int ChromeBrowserMainParts::PreCreateThreadsBegin() { |
863 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); | 863 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreadsBegin"); |
864 result_code_ = PreCreateThreadsImpl(); | 864 result_code_ = PreCreateThreadsImpl(); |
865 | 865 |
866 if (result_code_ == content::RESULT_CODE_NORMAL_EXIT) { | 866 if (result_code_ == content::RESULT_CODE_NORMAL_EXIT) { |
867 #if !defined(OS_ANDROID) | 867 #if !defined(OS_ANDROID) |
868 // These members must be initialized before exiting this function normally. | 868 // These members must be initialized before exiting this function normally. |
869 DCHECK(master_prefs_.get()); | 869 DCHECK(master_prefs_.get()); |
870 DCHECK(browser_creator_.get()); | 870 DCHECK(browser_creator_.get()); |
871 #endif // !defined(OS_ANDROID) | 871 #endif // !defined(OS_ANDROID) |
872 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 872 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
873 chrome_extra_parts_[i]->PreCreateThreads(); | 873 chrome_extra_parts_[i]->PreCreateThreadsBegin(); |
874 } | 874 } |
875 | 875 |
876 return result_code_; | 876 return result_code_; |
877 } | 877 } |
878 | 878 |
879 int ChromeBrowserMainParts::PreCreateThreadsImpl() { | 879 int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
880 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreadsImpl") | 880 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreadsImpl") |
881 run_message_loop_ = false; | 881 run_message_loop_ = false; |
882 #if !defined(OS_ANDROID) | 882 #if !defined(OS_ANDROID) |
883 chrome::MaybeShowInvalidUserDataDirWarningDialog(); | 883 chrome::MaybeShowInvalidUserDataDirWarningDialog(); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 // metrics and initialize field trials. The field trials are needed by | 1109 // metrics and initialize field trials. The field trials are needed by |
1110 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. | 1110 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. |
1111 SetupMetricsAndFieldTrials(); | 1111 SetupMetricsAndFieldTrials(); |
1112 | 1112 |
1113 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. | 1113 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. |
1114 browser_process_->PreCreateThreads(); | 1114 browser_process_->PreCreateThreads(); |
1115 | 1115 |
1116 return content::RESULT_CODE_NORMAL_EXIT; | 1116 return content::RESULT_CODE_NORMAL_EXIT; |
1117 } | 1117 } |
1118 | 1118 |
| 1119 void ChromeBrowserMainParts::PreCreateThreadsEnd() { |
| 1120 // It is important to call gl_string_manager()->Initialize() before starting |
| 1121 // the gpu process. Internally it properly setup the black listed features. |
| 1122 // Which it is used to decide whether to start or not the gpu process from |
| 1123 // BrowserMainLoop::BrowserThreadsStarted. |
| 1124 |
| 1125 // Retrieve cached GL strings from local state and use them for GPU |
| 1126 // blacklist decisions. |
| 1127 if (g_browser_process->gl_string_manager()) |
| 1128 g_browser_process->gl_string_manager()->Initialize(); |
| 1129 |
| 1130 // Create an instance of GpuModeManager to watch gpu mode pref change. |
| 1131 g_browser_process->gpu_mode_manager(); |
| 1132 } |
| 1133 |
1119 void ChromeBrowserMainParts::PreMainMessageLoopRun() { | 1134 void ChromeBrowserMainParts::PreMainMessageLoopRun() { |
1120 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRun"); | 1135 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRun"); |
1121 TRACK_SCOPED_REGION( | 1136 TRACK_SCOPED_REGION( |
1122 "Startup", "ChromeBrowserMainParts::PreMainMessageLoopRun"); | 1137 "Startup", "ChromeBrowserMainParts::PreMainMessageLoopRun"); |
1123 | 1138 |
1124 result_code_ = PreMainMessageLoopRunImpl(); | 1139 result_code_ = PreMainMessageLoopRunImpl(); |
1125 | 1140 |
1126 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1141 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
1127 chrome_extra_parts_[i]->PreMainMessageLoopRun(); | 1142 chrome_extra_parts_[i]->PreMainMessageLoopRun(); |
1128 } | 1143 } |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 #if !defined(DISABLE_NACL) | 1489 #if !defined(DISABLE_NACL) |
1475 NaClBrowserDelegateImpl* delegate = | 1490 NaClBrowserDelegateImpl* delegate = |
1476 new NaClBrowserDelegateImpl(browser_process_->profile_manager()); | 1491 new NaClBrowserDelegateImpl(browser_process_->profile_manager()); |
1477 nacl::NaClBrowser::SetDelegate(delegate); | 1492 nacl::NaClBrowser::SetDelegate(delegate); |
1478 #endif // !defined(DISABLE_NACL) | 1493 #endif // !defined(DISABLE_NACL) |
1479 | 1494 |
1480 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. | 1495 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. |
1481 // (requires supporting early exit). | 1496 // (requires supporting early exit). |
1482 PostProfileInit(); | 1497 PostProfileInit(); |
1483 | 1498 |
1484 // Retrieve cached GL strings from local state and use them for GPU | |
1485 // blacklist decisions. | |
1486 if (g_browser_process->gl_string_manager()) | |
1487 g_browser_process->gl_string_manager()->Initialize(); | |
1488 | |
1489 // Create an instance of GpuModeManager to watch gpu mode pref change. | |
1490 g_browser_process->gpu_mode_manager(); | |
1491 | |
1492 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 1499 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
1493 // Show the First Run UI if this is the first time Chrome has been run on | 1500 // Show the First Run UI if this is the first time Chrome has been run on |
1494 // this computer, or we're being compelled to do so by a command line flag. | 1501 // this computer, or we're being compelled to do so by a command line flag. |
1495 // Note that this be done _after_ the PrefService is initialized and all | 1502 // Note that this be done _after_ the PrefService is initialized and all |
1496 // preferences are registered, since some of the code that the importer | 1503 // preferences are registered, since some of the code that the importer |
1497 // touches reads preferences. | 1504 // touches reads preferences. |
1498 if (first_run::IsChromeFirstRun()) { | 1505 if (first_run::IsChromeFirstRun()) { |
1499 first_run::AutoImport(profile_, | 1506 first_run::AutoImport(profile_, |
1500 master_prefs_->homepage_defined, | 1507 master_prefs_->homepage_defined, |
1501 master_prefs_->do_import_items, | 1508 master_prefs_->do_import_items, |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 chromeos::CrosSettings::Shutdown(); | 1888 chromeos::CrosSettings::Shutdown(); |
1882 #endif // defined(OS_CHROMEOS) | 1889 #endif // defined(OS_CHROMEOS) |
1883 #endif // defined(OS_ANDROID) | 1890 #endif // defined(OS_ANDROID) |
1884 } | 1891 } |
1885 | 1892 |
1886 // Public members: | 1893 // Public members: |
1887 | 1894 |
1888 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1895 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1889 chrome_extra_parts_.push_back(parts); | 1896 chrome_extra_parts_.push_back(parts); |
1890 } | 1897 } |
OLD | NEW |