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 <algorithm> | 10 #include <algorithm> |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "base/strings/string_piece.h" | 34 #include "base/strings/string_piece.h" |
35 #include "base/strings/string_split.h" | 35 #include "base/strings/string_split.h" |
36 #include "base/strings/sys_string_conversions.h" | 36 #include "base/strings/sys_string_conversions.h" |
37 #include "base/strings/utf_string_conversions.h" | 37 #include "base/strings/utf_string_conversions.h" |
38 #include "base/sys_info.h" | 38 #include "base/sys_info.h" |
39 #include "base/task_scheduler/scheduler_worker_pool_params.h" | 39 #include "base/task_scheduler/scheduler_worker_pool_params.h" |
40 #include "base/task_scheduler/switches.h" | 40 #include "base/task_scheduler/switches.h" |
41 #include "base/task_scheduler/task_scheduler.h" | 41 #include "base/task_scheduler/task_scheduler.h" |
42 #include "base/task_scheduler/task_traits.h" | 42 #include "base/task_scheduler/task_traits.h" |
43 #include "base/threading/platform_thread.h" | 43 #include "base/threading/platform_thread.h" |
| 44 #include "base/threading/sequenced_worker_pool.h" |
44 #include "base/time/default_tick_clock.h" | 45 #include "base/time/default_tick_clock.h" |
45 #include "base/time/time.h" | 46 #include "base/time/time.h" |
46 #include "base/trace_event/trace_event.h" | 47 #include "base/trace_event/trace_event.h" |
47 #include "base/values.h" | 48 #include "base/values.h" |
48 #include "build/build_config.h" | 49 #include "build/build_config.h" |
49 #include "cc/base/switches.h" | 50 #include "cc/base/switches.h" |
50 #include "chrome/browser/about_flags.h" | 51 #include "chrome/browser/about_flags.h" |
51 #include "chrome/browser/after_startup_task_utils.h" | 52 #include "chrome/browser/after_startup_task_utils.h" |
52 #include "chrome/browser/browser_process.h" | 53 #include "chrome/browser/browser_process.h" |
53 #include "chrome/browser/browser_process_impl.h" | 54 #include "chrome/browser/browser_process_impl.h" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 predefined_params.priority_hint, | 446 predefined_params.priority_hint, |
446 predefined_params.io_restriction, | 447 predefined_params.io_restriction, |
447 variation_values.threads, | 448 variation_values.threads, |
448 variation_values.detach_period); | 449 variation_values.detach_period); |
449 } | 450 } |
450 | 451 |
451 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size()); | 452 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size()); |
452 | 453 |
453 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( | 454 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( |
454 params_vector, base::Bind(WorkerPoolIndexForTraits)); | 455 params_vector, base::Bind(WorkerPoolIndexForTraits)); |
| 456 |
| 457 // TODO(gab): Remove this when http://crbug.com/622400 concludes. |
| 458 const auto sequenced_worker_pool_param = |
| 459 variation_params.find("RedirectSequencedWorkerPools"); |
| 460 if (sequenced_worker_pool_param != variation_params.end() && |
| 461 sequenced_worker_pool_param->second == "true") { |
| 462 base::SequencedWorkerPool:: |
| 463 RedirectSequencedWorkerPoolsToTaskSchedulerForProcess(); |
| 464 } |
455 } | 465 } |
456 | 466 |
457 // Returns the new local state object, guaranteed non-NULL. | 467 // Returns the new local state object, guaranteed non-NULL. |
458 // |local_state_task_runner| must be a shutdown-blocking task runner. | 468 // |local_state_task_runner| must be a shutdown-blocking task runner. |
459 PrefService* InitializeLocalState( | 469 PrefService* InitializeLocalState( |
460 base::SequencedTaskRunner* local_state_task_runner, | 470 base::SequencedTaskRunner* local_state_task_runner, |
461 const base::CommandLine& parsed_command_line) { | 471 const base::CommandLine& parsed_command_line) { |
462 TRACE_EVENT0("startup", "ChromeBrowserMainParts::InitializeLocalState") | 472 TRACE_EVENT0("startup", "ChromeBrowserMainParts::InitializeLocalState") |
463 | 473 |
464 // Load local state. This includes the application locale so we know which | 474 // Load local state. This includes the application locale so we know which |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 chromeos::CrosSettings::Initialize(); | 1350 chromeos::CrosSettings::Initialize(); |
1341 #endif // defined(OS_CHROMEOS) | 1351 #endif // defined(OS_CHROMEOS) |
1342 | 1352 |
1343 SetupOriginTrialsCommandLine(); | 1353 SetupOriginTrialsCommandLine(); |
1344 | 1354 |
1345 // Now the command line has been mutated based on about:flags, we can setup | 1355 // Now the command line has been mutated based on about:flags, we can setup |
1346 // metrics and initialize field trials. The field trials are needed by | 1356 // metrics and initialize field trials. The field trials are needed by |
1347 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. | 1357 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. |
1348 SetupMetricsAndFieldTrials(); | 1358 SetupMetricsAndFieldTrials(); |
1349 | 1359 |
1350 MaybeInitializeTaskScheduler(); | |
1351 | |
1352 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. | 1360 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. |
1353 browser_process_->PreCreateThreads(); | 1361 browser_process_->PreCreateThreads(); |
1354 | 1362 |
1355 device::GeolocationProvider::SetGeolocationDelegate( | 1363 device::GeolocationProvider::SetGeolocationDelegate( |
1356 new ChromeGeolocationDelegate()); | 1364 new ChromeGeolocationDelegate()); |
1357 | 1365 |
| 1366 // This needs to be the last thing in PreCreateThreads() because the |
| 1367 // TaskScheduler needs to be created before any other threads are (by |
| 1368 // contract) but it creates threads itself so instantiating it earlier is also |
| 1369 // incorrect. It also has to be after SetupMetricsAndFieldTrials() to allow it |
| 1370 // to use field trials. Note: it could also be the first thing in |
| 1371 // CreateThreads() but being in chrome/ is convenient for now as the |
| 1372 // initialization uses variations parameters extensively. |
| 1373 MaybeInitializeTaskScheduler(); |
| 1374 |
1358 return content::RESULT_CODE_NORMAL_EXIT; | 1375 return content::RESULT_CODE_NORMAL_EXIT; |
1359 } | 1376 } |
1360 | 1377 |
1361 void ChromeBrowserMainParts::MojoShellConnectionStarted( | 1378 void ChromeBrowserMainParts::MojoShellConnectionStarted( |
1362 content::MojoShellConnection* connection) { | 1379 content::MojoShellConnection* connection) { |
1363 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1380 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
1364 chrome_extra_parts_[i]->MojoShellConnectionStarted(connection); | 1381 chrome_extra_parts_[i]->MojoShellConnectionStarted(connection); |
1365 } | 1382 } |
1366 | 1383 |
1367 void ChromeBrowserMainParts::PreMainMessageLoopRun() { | 1384 void ChromeBrowserMainParts::PreMainMessageLoopRun() { |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 chromeos::CrosSettings::Shutdown(); | 2226 chromeos::CrosSettings::Shutdown(); |
2210 #endif // defined(OS_CHROMEOS) | 2227 #endif // defined(OS_CHROMEOS) |
2211 #endif // defined(OS_ANDROID) | 2228 #endif // defined(OS_ANDROID) |
2212 } | 2229 } |
2213 | 2230 |
2214 // Public members: | 2231 // Public members: |
2215 | 2232 |
2216 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 2233 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
2217 chrome_extra_parts_.push_back(parts); | 2234 chrome_extra_parts_.push_back(parts); |
2218 } | 2235 } |
OLD | NEW |