Chromium Code Reviews| Index: chrome/browser/chrome_browser_main.cc |
| diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc |
| index 6e3e14b2cc96c364e574a4d97e1b5cb07c1a5512..fb2ecf27650e624966e592fbfa82d94b508047b1 100644 |
| --- a/chrome/browser/chrome_browser_main.cc |
| +++ b/chrome/browser/chrome_browser_main.cc |
| @@ -314,7 +314,12 @@ void AddFirstRunNewTabs(StartupBrowserCreator* browser_creator, |
| } |
| #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| -void MaybeInitializeTaskScheduler() { |
| +// Initializes TaskScheduler if enabled via field trial or command line flag. |
| +// The function returns true if it enables redirection of SequencedWorkerPool to |
| +// TaskScheduler. |
| +bool MaybeInitializeTaskScheduler() { |
| + bool sequenced_worker_pool_redirected = false; |
| + |
| static constexpr char kFieldTrialName[] = "BrowserScheduler"; |
| std::map<std::string, std::string> variation_params; |
| if (!variations::GetVariationParams(kFieldTrialName, &variation_params)) { |
| @@ -324,19 +329,22 @@ void MaybeInitializeTaskScheduler() { |
| << switches::kEnableBrowserTaskScheduler |
| << " because there is no available variation param for this build or " |
| " the task scheduler is disabled in chrome://flags."; |
| - return; |
| + return sequenced_worker_pool_redirected; |
|
gab
2016/11/02 13:29:55
No var, just return false on each failure and retu
fdoray
2016/11/02 20:02:16
We may reach the end of the method without having
|
| } |
| if (!task_scheduler_util::InitializeDefaultTaskScheduler(variation_params)) |
| - return; |
| + return sequenced_worker_pool_redirected; |
| // TODO(gab): Remove this when http://crbug.com/622400 concludes. |
| const auto sequenced_worker_pool_param = |
| variation_params.find("RedirectSequencedWorkerPools"); |
| if (sequenced_worker_pool_param != variation_params.end() && |
| sequenced_worker_pool_param->second == "true") { |
| - base::SequencedWorkerPool::RedirectToTaskSchedulerForProcess(); |
| + sequenced_worker_pool_redirected = true; |
| + base::SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess(); |
| } |
| + |
| + return sequenced_worker_pool_redirected; |
| } |
| // Returns the new local state object, guaranteed non-NULL. |
| @@ -1229,7 +1237,8 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
| // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. |
| SetupFieldTrials(); |
| - // Task Scheduler initialization needs to be here for the following reasons: |
| + // Initializing TaskScheduler and enabling SequencedWorkerPool needs to be |
| + // here for the following reasons: |
| // * After |SetupFieldTrials()|: Initialization uses variations. |
| // * Before |SetupMetrics()|: |SetupMetrics()| uses the blocking pool. The |
| // Task Scheduler must do any necessary redirection before then. |
| @@ -1238,7 +1247,14 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
| // 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. |
| - MaybeInitializeTaskScheduler(); |
| + const bool sequenced_worker_pool_redirected = MaybeInitializeTaskScheduler(); |
| + |
| + // If MaybeInitializeTaskScheduler() hasn't enabled SequencedWorkerPool with |
| + // redirection to TaskScheduler, enable it without redirection. |
| + // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler |
| + // redirection experiment concludes https://crbug.com/622400. |
| + if (!sequenced_worker_pool_redirected) |
| + base::SequencedWorkerPool::EnableForProcess(); |
| SetupMetrics(); |