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 <map> | 10 #include <map> |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 } | 328 } |
| 329 | 329 |
| 330 if (!task_scheduler_util::InitializeDefaultTaskScheduler(variation_params)) | 330 if (!task_scheduler_util::InitializeDefaultTaskScheduler(variation_params)) |
| 331 return; | 331 return; |
| 332 | 332 |
| 333 // TODO(gab): Remove this when http://crbug.com/622400 concludes. | 333 // TODO(gab): Remove this when http://crbug.com/622400 concludes. |
| 334 const auto sequenced_worker_pool_param = | 334 const auto sequenced_worker_pool_param = |
| 335 variation_params.find("RedirectSequencedWorkerPools"); | 335 variation_params.find("RedirectSequencedWorkerPools"); |
| 336 if (sequenced_worker_pool_param != variation_params.end() && | 336 if (sequenced_worker_pool_param != variation_params.end() && |
| 337 sequenced_worker_pool_param->second == "true") { | 337 sequenced_worker_pool_param->second == "true") { |
| 338 base::SequencedWorkerPool::RedirectToTaskSchedulerForProcess(); | 338 base::SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess(); |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 // Returns the new local state object, guaranteed non-NULL. | 342 // Returns the new local state object, guaranteed non-NULL. |
| 343 // |local_state_task_runner| must be a shutdown-blocking task runner. | 343 // |local_state_task_runner| must be a shutdown-blocking task runner. |
| 344 PrefService* InitializeLocalState( | 344 PrefService* InitializeLocalState( |
| 345 base::SequencedTaskRunner* local_state_task_runner, | 345 base::SequencedTaskRunner* local_state_task_runner, |
| 346 const base::CommandLine& parsed_command_line) { | 346 const base::CommandLine& parsed_command_line) { |
| 347 TRACE_EVENT0("startup", "ChromeBrowserMainParts::InitializeLocalState") | 347 TRACE_EVENT0("startup", "ChromeBrowserMainParts::InitializeLocalState") |
| 348 | 348 |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1222 // Do not add anything below this line until you've verified your new code | 1222 // Do not add anything below this line until you've verified your new code |
| 1223 // does not interfere with the critical initialization order below. Some of | 1223 // does not interfere with the critical initialization order below. Some of |
| 1224 // the calls below end up implicitly creating threads and as such new calls | 1224 // the calls below end up implicitly creating threads and as such new calls |
| 1225 // typically either belong before them or in a later startup phase. | 1225 // typically either belong before them or in a later startup phase. |
| 1226 | 1226 |
| 1227 // Now that the command line has been mutated based on about:flags, we can | 1227 // Now that the command line has been mutated based on about:flags, we can |
| 1228 // initialize field trials and setup metrics. The field trials are needed by | 1228 // initialize field trials and setup metrics. The field trials are needed by |
| 1229 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. | 1229 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. |
| 1230 SetupFieldTrials(); | 1230 SetupFieldTrials(); |
| 1231 | 1231 |
| 1232 // Task Scheduler initialization needs to be here for the following reasons: | 1232 // Initializing TaskScheduler and enabling SequencedWorkerPool needs to be |
| 1233 // here for the following reasons: | |
| 1233 // * After |SetupFieldTrials()|: Initialization uses variations. | 1234 // * After |SetupFieldTrials()|: Initialization uses variations. |
| 1234 // * Before |SetupMetrics()|: |SetupMetrics()| uses the blocking pool. The | 1235 // * Before |SetupMetrics()|: |SetupMetrics()| uses the blocking pool. The |
| 1235 // Task Scheduler must do any necessary redirection before then. | 1236 // Task Scheduler must do any necessary redirection before then. |
| 1236 // * Near the end of |PreCreateThreads()|: The TaskScheduler needs to be | 1237 // * Near the end of |PreCreateThreads()|: The TaskScheduler needs to be |
| 1237 // created before any other threads are (by contract) but it creates | 1238 // created before any other threads are (by contract) but it creates |
| 1238 // threads itself so instantiating it earlier is also incorrect. | 1239 // threads itself so instantiating it earlier is also incorrect. |
| 1239 // To maintain scoping symmetry, if this line is moved, the corresponding | 1240 // To maintain scoping symmetry, if this line is moved, the corresponding |
| 1240 // shutdown call may also need to be moved. | 1241 // shutdown call may also need to be moved. |
| 1241 MaybeInitializeTaskScheduler(); | 1242 MaybeInitializeTaskScheduler(); |
| 1242 | 1243 |
| 1244 // If MaybeInitializeTaskScheduler() hasn't enabled SequencedWorkerPool with | |
| 1245 // redirection to TaskScheduler, enable it without redirection. | |
| 1246 // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler | |
| 1247 // redirection experiment concludes https://crbug.com/622400. | |
| 1248 base::SequencedWorkerPool::EnableForProcess(); | |
|
gab
2016/11/01 16:09:48
Add a bool to MaybeInitializeTaskScheduler() and m
fdoray
2016/11/01 20:40:28
Done.
| |
| 1249 | |
| 1243 SetupMetrics(); | 1250 SetupMetrics(); |
| 1244 | 1251 |
| 1245 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. | 1252 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. |
| 1246 // This also instantiates the IOThread which requests the metrics service and | 1253 // This also instantiates the IOThread which requests the metrics service and |
| 1247 // must be after |SetupMetrics()|. | 1254 // must be after |SetupMetrics()|. |
| 1248 browser_process_->PreCreateThreads(); | 1255 browser_process_->PreCreateThreads(); |
| 1249 | 1256 |
| 1250 return content::RESULT_CODE_NORMAL_EXIT; | 1257 return content::RESULT_CODE_NORMAL_EXIT; |
| 1251 } | 1258 } |
| 1252 | 1259 |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2111 chromeos::CrosSettings::Shutdown(); | 2118 chromeos::CrosSettings::Shutdown(); |
| 2112 #endif // defined(OS_CHROMEOS) | 2119 #endif // defined(OS_CHROMEOS) |
| 2113 #endif // defined(OS_ANDROID) | 2120 #endif // defined(OS_ANDROID) |
| 2114 } | 2121 } |
| 2115 | 2122 |
| 2116 // Public members: | 2123 // Public members: |
| 2117 | 2124 |
| 2118 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 2125 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 2119 chrome_extra_parts_.push_back(parts); | 2126 chrome_extra_parts_.push_back(parts); |
| 2120 } | 2127 } |
| OLD | NEW |