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 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 1128 |
| 1129 if (!command_line->HasSwitch("do-init-after-starting-gpu-process")) { |
| 1130 if (g_browser_process->gl_string_manager()) |
| 1131 g_browser_process->gl_string_manager()->Initialize(); |
| 1132 |
| 1133 // Create an instance of GpuModeManager to watch gpu mode pref change. |
| 1134 g_browser_process->gpu_mode_manager(); |
| 1135 } |
| 1136 } |
| 1137 |
1119 void ChromeBrowserMainParts::PreMainMessageLoopRun() { | 1138 void ChromeBrowserMainParts::PreMainMessageLoopRun() { |
1120 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRun"); | 1139 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRun"); |
1121 TRACK_SCOPED_REGION( | 1140 TRACK_SCOPED_REGION( |
1122 "Startup", "ChromeBrowserMainParts::PreMainMessageLoopRun"); | 1141 "Startup", "ChromeBrowserMainParts::PreMainMessageLoopRun"); |
1123 | 1142 |
1124 result_code_ = PreMainMessageLoopRunImpl(); | 1143 result_code_ = PreMainMessageLoopRunImpl(); |
1125 | 1144 |
1126 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1145 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
1127 chrome_extra_parts_[i]->PreMainMessageLoopRun(); | 1146 chrome_extra_parts_[i]->PreMainMessageLoopRun(); |
1128 } | 1147 } |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 #if !defined(DISABLE_NACL) | 1493 #if !defined(DISABLE_NACL) |
1475 NaClBrowserDelegateImpl* delegate = | 1494 NaClBrowserDelegateImpl* delegate = |
1476 new NaClBrowserDelegateImpl(browser_process_->profile_manager()); | 1495 new NaClBrowserDelegateImpl(browser_process_->profile_manager()); |
1477 nacl::NaClBrowser::SetDelegate(delegate); | 1496 nacl::NaClBrowser::SetDelegate(delegate); |
1478 #endif // !defined(DISABLE_NACL) | 1497 #endif // !defined(DISABLE_NACL) |
1479 | 1498 |
1480 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. | 1499 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. |
1481 // (requires supporting early exit). | 1500 // (requires supporting early exit). |
1482 PostProfileInit(); | 1501 PostProfileInit(); |
1483 | 1502 |
1484 // Retrieve cached GL strings from local state and use them for GPU | 1503 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
1485 // blacklist decisions. | |
1486 if (g_browser_process->gl_string_manager()) | |
1487 g_browser_process->gl_string_manager()->Initialize(); | |
1488 | 1504 |
1489 // Create an instance of GpuModeManager to watch gpu mode pref change. | 1505 if (command_line->HasSwitch("do-init-after-starting-gpu-process")) { |
1490 g_browser_process->gpu_mode_manager(); | 1506 VLOG(1) << "do init after starting gpu process"; |
| 1507 if (g_browser_process->gl_string_manager()) |
| 1508 g_browser_process->gl_string_manager()->Initialize(); |
| 1509 |
| 1510 // Create an instance of GpuModeManager to watch gpu mode pref change. |
| 1511 g_browser_process->gpu_mode_manager(); |
| 1512 } |
1491 | 1513 |
1492 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 1514 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
1493 // Show the First Run UI if this is the first time Chrome has been run on | 1515 // 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. | 1516 // 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 | 1517 // Note that this be done _after_ the PrefService is initialized and all |
1496 // preferences are registered, since some of the code that the importer | 1518 // preferences are registered, since some of the code that the importer |
1497 // touches reads preferences. | 1519 // touches reads preferences. |
1498 if (first_run::IsChromeFirstRun()) { | 1520 if (first_run::IsChromeFirstRun()) { |
1499 first_run::AutoImport(profile_, | 1521 first_run::AutoImport(profile_, |
1500 master_prefs_->homepage_defined, | 1522 master_prefs_->homepage_defined, |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 chromeos::CrosSettings::Shutdown(); | 1903 chromeos::CrosSettings::Shutdown(); |
1882 #endif // defined(OS_CHROMEOS) | 1904 #endif // defined(OS_CHROMEOS) |
1883 #endif // defined(OS_ANDROID) | 1905 #endif // defined(OS_ANDROID) |
1884 } | 1906 } |
1885 | 1907 |
1886 // Public members: | 1908 // Public members: |
1887 | 1909 |
1888 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1910 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1889 chrome_extra_parts_.push_back(parts); | 1911 chrome_extra_parts_.push_back(parts); |
1890 } | 1912 } |
OLD | NEW |