| 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 // This also instantiates the IOThread which requests the metrics service and | 1222 // This also instantiates the IOThread which requests the metrics service and |
| 1227 // must be after |SetupMetrics()|. | 1223 // must be after |SetupMetrics()|. |
| 1228 browser_process_->PreCreateThreads(); | 1224 browser_process_->PreCreateThreads(); |
| 1229 | 1225 |
| 1230 return content::RESULT_CODE_NORMAL_EXIT; | 1226 return content::RESULT_CODE_NORMAL_EXIT; |
| 1231 } | 1227 } |
| 1232 | 1228 |
| 1233 void ChromeBrowserMainParts::ServiceManagerConnectionStarted( | 1229 void ChromeBrowserMainParts::ServiceManagerConnectionStarted( |
| 1234 content::ServiceManagerConnection* connection) { | 1230 content::ServiceManagerConnection* connection) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 // task posted via PostAfterStartupTask until its complete. | 1406 // task posted via PostAfterStartupTask until its complete. |
| 1411 AfterStartupTaskUtils::StartMonitoringStartup(); | 1407 AfterStartupTaskUtils::StartMonitoringStartup(); |
| 1412 } | 1408 } |
| 1413 | 1409 |
| 1414 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { | 1410 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
| 1415 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); | 1411 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); |
| 1416 | 1412 |
| 1417 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime"); | 1413 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime"); |
| 1418 const base::TimeTicks start_time_step1 = base::TimeTicks::Now(); | 1414 const base::TimeTicks start_time_step1 = base::TimeTicks::Now(); |
| 1419 | 1415 |
| 1416 // This must occur at PreMainMessageLoopRun because |SetupMetrics()| uses the |
| 1417 // blocking pool, which is disabled until the CreateThreads phase of startup. |
| 1418 SetupMetrics(); |
| 1419 |
| 1420 #if defined(OS_WIN) | 1420 #if defined(OS_WIN) |
| 1421 // Windows parental controls calls can be slow, so we do an early init here | 1421 // Windows parental controls calls can be slow, so we do an early init here |
| 1422 // that calculates this value off of the UI thread. | 1422 // that calculates this value off of the UI thread. |
| 1423 IncognitoModePrefs::InitializePlatformParentalControls(); | 1423 IncognitoModePrefs::InitializePlatformParentalControls(); |
| 1424 #endif | 1424 #endif |
| 1425 | 1425 |
| 1426 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1426 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 1427 if (!variations::GetVariationParamValue( | 1427 if (!variations::GetVariationParamValue( |
| 1428 "LightSpeed", "EarlyInitStartup").empty()) { | 1428 "LightSpeed", "EarlyInitStartup").empty()) { |
| 1429 // Try to compute this early on another thread so that we don't spend time | 1429 // 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... |
| 2092 chromeos::CrosSettings::Shutdown(); | 2092 chromeos::CrosSettings::Shutdown(); |
| 2093 #endif // defined(OS_CHROMEOS) | 2093 #endif // defined(OS_CHROMEOS) |
| 2094 #endif // defined(OS_ANDROID) | 2094 #endif // defined(OS_ANDROID) |
| 2095 } | 2095 } |
| 2096 | 2096 |
| 2097 // Public members: | 2097 // Public members: |
| 2098 | 2098 |
| 2099 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 2099 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 2100 chrome_extra_parts_.push_back(parts); | 2100 chrome_extra_parts_.push_back(parts); |
| 2101 } | 2101 } |
| OLD | NEW |