| Index: ios/chrome/browser/ios_chrome_main_parts.mm
|
| diff --git a/ios/chrome/browser/ios_chrome_main_parts.mm b/ios/chrome/browser/ios_chrome_main_parts.mm
|
| index e295f9fa993fc7daba857985cef140772b162181..f7e37960ec631ce981270af35835c6a1bd7ead16 100644
|
| --- a/ios/chrome/browser/ios_chrome_main_parts.mm
|
| +++ b/ios/chrome/browser/ios_chrome_main_parts.mm
|
| @@ -11,7 +11,6 @@
|
| #include "base/memory/ptr_util.h"
|
| #include "base/metrics/user_metrics.h"
|
| #include "base/path_service.h"
|
| -#include "base/task_scheduler/task_scheduler.h"
|
| #include "base/time/default_tick_clock.h"
|
| #include "components/content_settings/core/browser/cookie_settings.h"
|
| #include "components/content_settings/core/common/content_settings_pattern.h"
|
| @@ -25,7 +24,6 @@
|
| #include "components/prefs/json_pref_store.h"
|
| #include "components/prefs/pref_service.h"
|
| #include "components/rappor/rappor_service_impl.h"
|
| -#include "components/task_scheduler_util/initialization_util.h"
|
| #include "components/translate/core/browser/translate_download_manager.h"
|
| #include "components/variations/field_trial_config/field_trial_util.h"
|
| #include "components/variations/service/variations_service.h"
|
| @@ -89,6 +87,11 @@ void IOSChromeMainParts::PreMainMessageLoopStart() {
|
| }
|
|
|
| void IOSChromeMainParts::PreCreateThreads() {
|
| + // IMPORTANT
|
| + // Calls in this function should not post tasks or create threads as
|
| + // components used to handle those tasks are not yet available. This work
|
| + // should be deferred to PreMainMessageLoopRunImpl.
|
| +
|
| base::FilePath local_state_path;
|
| CHECK(PathService::Get(ios::FILE_LOCAL_STATE, &local_state_path));
|
| scoped_refptr<base::SequencedTaskRunner> local_state_task_runner =
|
| @@ -119,27 +122,12 @@ void IOSChromeMainParts::PreCreateThreads() {
|
| base::MakeUnique<base::DefaultTickClock>(),
|
| base::Bind(&metrics::IOSTrackingSynchronizerDelegate::Create));
|
|
|
| - // IMPORTANT
|
| - // Do not add anything below this line until you've verified your new code
|
| - // does not interfere with the critical initialization order below. Some of
|
| - // the calls below end up implicitly creating threads and as such new calls
|
| - // typically either belong before them or in a later startup phase.
|
| -
|
| // Now that the command line has been mutated based on about:flags, we can
|
| - // initialize field trials and setup metrics. The field trials are needed by
|
| - // IOThread's initialization in ApplicationContext's PreCreateThreads.
|
| + // initialize field trials. The field trials are needed by IOThread's
|
| + // initialization which happens in BrowserProcess:PreCreateThreads. Metrics
|
| + // initialization is handled in PreMainMessageLoopRun since it posts tasks.
|
| SetupFieldTrials();
|
|
|
| - // Task Scheduler initialization needs to be here for the following reasons:
|
| - // * After |SetupFieldTrials()|: Initialization uses variations.
|
| - // * Near the end of |PreCreateThreads()|: The TaskScheduler needs to be
|
| - // created before any other threads are (by contract) but it creates
|
| - // threads itself so instantiating it earlier is also incorrect.
|
| - // To maintain scoping symmetry, if this line is moved, the corresponding
|
| - // shutdown call may also need to be moved.
|
| - task_scheduler_util::InitializeDefaultBrowserTaskScheduler();
|
| -
|
| -
|
| // Initialize FieldTrialSynchronizer system.
|
| field_trial_synchronizer_.reset(new ios::FieldTrialSynchronizer);
|
|
|
| @@ -216,13 +204,6 @@ void IOSChromeMainParts::PostMainMessageLoopRun() {
|
|
|
| void IOSChromeMainParts::PostDestroyThreads() {
|
| application_context_->PostDestroyThreads();
|
| -
|
| - // The TaskScheduler was initialized before invoking
|
| - // |application_context_->PreCreateThreads()|. To maintain scoping symmetry,
|
| - // perform the shutdown after |application_context_->PostDestroyThreads()|.
|
| - base::TaskScheduler* task_scheduler = base::TaskScheduler::GetInstance();
|
| - if (task_scheduler)
|
| - task_scheduler->Shutdown();
|
| }
|
|
|
| // This will be called after the command-line has been mutated by about:flags
|
|
|