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