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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1204 // the calls below end up implicitly creating threads and as such new calls | 1204 // the calls below end up implicitly creating threads and as such new calls |
| 1205 // typically either belong before them or in a later startup phase. | 1205 // typically either belong before them or in a later startup phase. |
| 1206 | 1206 |
| 1207 // Now that the command line has been mutated based on about:flags, we can | 1207 // Now that the command line has been mutated based on about:flags, we can |
| 1208 // initialize field trials and setup metrics. The field trials are needed by | 1208 // initialize field trials and setup metrics. The field trials are needed by |
| 1209 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. | 1209 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. |
| 1210 SetupFieldTrials(); | 1210 SetupFieldTrials(); |
| 1211 | 1211 |
| 1212 // Task Scheduler initialization needs to be here for the following reasons: | 1212 // Task Scheduler initialization needs to be here for the following reasons: |
| 1213 // * After |SetupFieldTrials()|: Initialization uses variations. | 1213 // * After |SetupFieldTrials()|: Initialization uses variations. |
| 1214 // * Before |SetupMetrics()|: |SetupMetrics()| uses the blocking pool. The | |
| 1215 // Task Scheduler must do any necessary redirection before then. | |
| 1216 // * Near the end of |PreCreateThreads()|: The TaskScheduler needs to be | 1214 // * Near the end of |PreCreateThreads()|: The TaskScheduler needs to be |
| 1217 // created before any other threads are (by contract) but it creates | 1215 // created before any other threads are (by contract) but it creates |
| 1218 // threads itself so instantiating it earlier is also incorrect. | 1216 // threads itself so instantiating it earlier is also incorrect. |
| 1219 // To maintain scoping symmetry, if this line is moved, the corresponding | 1217 // To maintain scoping symmetry, if this line is moved, the corresponding |
| 1220 // shutdown call may also need to be moved. | 1218 // shutdown call may also need to be moved. |
| 1221 task_scheduler_util::InitializeDefaultBrowserTaskScheduler(); | 1219 task_scheduler_util::InitializeDefaultBrowserTaskScheduler(); |
| 1222 | 1220 |
| 1223 SetupMetrics(); | |
| 1224 | |
| 1225 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. | 1221 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. |
| 1226 browser_process_->PreCreateThreads(); | 1222 browser_process_->PreCreateThreads(); |
| 1227 | 1223 |
| 1228 return content::RESULT_CODE_NORMAL_EXIT; | 1224 return content::RESULT_CODE_NORMAL_EXIT; |
| 1229 } | 1225 } |
| 1230 | 1226 |
| 1231 void ChromeBrowserMainParts::ServiceManagerConnectionStarted( | 1227 void ChromeBrowserMainParts::ServiceManagerConnectionStarted( |
| 1232 content::ServiceManagerConnection* connection) { | 1228 content::ServiceManagerConnection* connection) { |
| 1233 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1229 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 1234 chrome_extra_parts_[i]->ServiceManagerConnectionStarted(connection); | 1230 chrome_extra_parts_[i]->ServiceManagerConnectionStarted(connection); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1408 // task posted via PostAfterStartupTask until its complete. | 1404 // task posted via PostAfterStartupTask until its complete. |
| 1409 AfterStartupTaskUtils::StartMonitoringStartup(); | 1405 AfterStartupTaskUtils::StartMonitoringStartup(); |
| 1410 } | 1406 } |
| 1411 | 1407 |
| 1412 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { | 1408 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
| 1413 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); | 1409 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); |
| 1414 | 1410 |
| 1415 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime"); | 1411 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime"); |
| 1416 const base::TimeTicks start_time_step1 = base::TimeTicks::Now(); | 1412 const base::TimeTicks start_time_step1 = base::TimeTicks::Now(); |
| 1417 | 1413 |
| 1414 // This must occur at PreMainMessageLoopRun because |SetupMetrics()| uses the | |
| 1415 // blocking pool, which is disabled until the CreateThreads phase of startup. | |
| 1416 SetupMetrics(); | |
|
Alexei Svitkine (slow)
2016/11/24 21:32:48
Do we have stats on how much later this happens th
gab
2016/11/25 13:16:08
We do not have specific stats but as you can see @
robliao
2016/11/28 14:41:48
Agreed. A few things do occur at CreateThreads and
| |
| 1417 | |
| 1418 #if defined(OS_WIN) | 1418 #if defined(OS_WIN) |
| 1419 // Windows parental controls calls can be slow, so we do an early init here | 1419 // Windows parental controls calls can be slow, so we do an early init here |
| 1420 // that calculates this value off of the UI thread. | 1420 // that calculates this value off of the UI thread. |
| 1421 IncognitoModePrefs::InitializePlatformParentalControls(); | 1421 IncognitoModePrefs::InitializePlatformParentalControls(); |
| 1422 #endif | 1422 #endif |
| 1423 | 1423 |
| 1424 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1424 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 1425 if (!variations::GetVariationParamValue( | 1425 if (!variations::GetVariationParamValue( |
| 1426 "LightSpeed", "EarlyInitStartup").empty()) { | 1426 "LightSpeed", "EarlyInitStartup").empty()) { |
| 1427 // Try to compute this early on another thread so that we don't spend time | 1427 // Try to compute this early on another thread so that we don't spend time |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2090 chromeos::CrosSettings::Shutdown(); | 2090 chromeos::CrosSettings::Shutdown(); |
| 2091 #endif // defined(OS_CHROMEOS) | 2091 #endif // defined(OS_CHROMEOS) |
| 2092 #endif // defined(OS_ANDROID) | 2092 #endif // defined(OS_ANDROID) |
| 2093 } | 2093 } |
| 2094 | 2094 |
| 2095 // Public members: | 2095 // Public members: |
| 2096 | 2096 |
| 2097 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 2097 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 2098 chrome_extra_parts_.push_back(parts); | 2098 chrome_extra_parts_.push_back(parts); |
| 2099 } | 2099 } |
| OLD | NEW |