Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: content/browser/browser_main_loop.cc

Issue 2539263003: Move Task Scheduler Initialization From chrome/browser to Content (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/browser/browser_main_loop.h" 5 #include "content/browser/browser_main_loop.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 13 matching lines...) Expand all
24 #include "base/metrics/user_metrics.h" 24 #include "base/metrics/user_metrics.h"
25 #include "base/pending_task.h" 25 #include "base/pending_task.h"
26 #include "base/power_monitor/power_monitor.h" 26 #include "base/power_monitor/power_monitor.h"
27 #include "base/power_monitor/power_monitor_device_source.h" 27 #include "base/power_monitor/power_monitor_device_source.h"
28 #include "base/process/process_metrics.h" 28 #include "base/process/process_metrics.h"
29 #include "base/run_loop.h" 29 #include "base/run_loop.h"
30 #include "base/single_thread_task_runner.h" 30 #include "base/single_thread_task_runner.h"
31 #include "base/strings/string_number_conversions.h" 31 #include "base/strings/string_number_conversions.h"
32 #include "base/strings/string_split.h" 32 #include "base/strings/string_split.h"
33 #include "base/system_monitor/system_monitor.h" 33 #include "base/system_monitor/system_monitor.h"
34 #include "base/task_scheduler/scheduler_worker_pool_params.h"
35 #include "base/task_scheduler/task_scheduler.h"
34 #include "base/threading/sequenced_worker_pool.h" 36 #include "base/threading/sequenced_worker_pool.h"
35 #include "base/threading/thread_restrictions.h" 37 #include "base/threading/thread_restrictions.h"
36 #include "base/threading/thread_task_runner_handle.h" 38 #include "base/threading/thread_task_runner_handle.h"
37 #include "base/timer/hi_res_timer_manager.h" 39 #include "base/timer/hi_res_timer_manager.h"
38 #include "base/trace_event/memory_dump_manager.h" 40 #include "base/trace_event/memory_dump_manager.h"
39 #include "base/trace_event/trace_event.h" 41 #include "base/trace_event/trace_event.h"
40 #include "build/build_config.h" 42 #include "build/build_config.h"
41 #include "components/discardable_memory/service/discardable_shared_memory_manage r.h" 43 #include "components/discardable_memory/service/discardable_shared_memory_manage r.h"
42 #include "components/tracing/browser/trace_config_file.h" 44 #include "components/tracing/browser/trace_config_file.h"
43 #include "components/tracing/common/process_metrics_memory_dump_provider.h" 45 #include "components/tracing/common/process_metrics_memory_dump_provider.h"
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 startup_task_runner_->RunAllTasksNow(); 865 startup_task_runner_->RunAllTasksNow();
864 } 866 }
865 #else 867 #else
866 startup_task_runner_->RunAllTasksNow(); 868 startup_task_runner_->RunAllTasksNow();
867 #endif 869 #endif
868 } 870 }
869 871
870 int BrowserMainLoop::CreateThreads() { 872 int BrowserMainLoop::CreateThreads() {
871 TRACE_EVENT0("startup,rail", "BrowserMainLoop::CreateThreads"); 873 TRACE_EVENT0("startup,rail", "BrowserMainLoop::CreateThreads");
872 874
875 std::vector<base::SchedulerWorkerPoolParams> params_vector;
876 base::TaskScheduler::WorkerPoolIndexForTraitsCallback
877 index_to_traits_callback;
878 GetContentClient()->browser()->GetTaskSchedulerInitializationParams(
879 &params_vector, &index_to_traits_callback);
880
881 base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
882 params_vector, index_to_traits_callback);
883
884 GetContentClient()->browser()->PerformRedirectionToTaskScheduler();
885
873 base::Thread::Options io_message_loop_options; 886 base::Thread::Options io_message_loop_options;
874 io_message_loop_options.message_loop_type = base::MessageLoop::TYPE_IO; 887 io_message_loop_options.message_loop_type = base::MessageLoop::TYPE_IO;
875 base::Thread::Options ui_message_loop_options; 888 base::Thread::Options ui_message_loop_options;
876 ui_message_loop_options.message_loop_type = base::MessageLoop::TYPE_UI; 889 ui_message_loop_options.message_loop_type = base::MessageLoop::TYPE_UI;
877 890
878 // Start threads in the order they occur in the BrowserThread::ID 891 // Start threads in the order they occur in the BrowserThread::ID
879 // enumeration, except for BrowserThread::UI which is the main 892 // enumeration, except for BrowserThread::UI which is the main
880 // thread. 893 // thread.
881 // 894 //
882 // Must be size_t so we can increment it. 895 // Must be size_t so we can increment it.
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 { 1205 {
1193 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:BatteryStatusService"); 1206 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:BatteryStatusService");
1194 device::BatteryStatusService::GetInstance()->Shutdown(); 1207 device::BatteryStatusService::GetInstance()->Shutdown();
1195 } 1208 }
1196 #endif 1209 #endif
1197 { 1210 {
1198 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DeleteDataSources"); 1211 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DeleteDataSources");
1199 URLDataManager::DeleteDataSources(); 1212 URLDataManager::DeleteDataSources();
1200 } 1213 }
1201 1214
1215 base::TaskScheduler* task_scheduler = base::TaskScheduler::GetInstance();
fdoray 2016/12/01 15:26:21 There should always be a TaskScheduler.
robliao 2016/12/06 01:31:30 Done.
1216 if (task_scheduler)
1217 task_scheduler->Shutdown();
1218
1202 if (parts_) { 1219 if (parts_) {
1203 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads"); 1220 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads");
1204 parts_->PostDestroyThreads(); 1221 parts_->PostDestroyThreads();
1205 } 1222 }
1206 } 1223 }
1207 1224
1208 void BrowserMainLoop::StopStartupTracingTimer() { 1225 void BrowserMainLoop::StopStartupTracingTimer() {
1209 startup_trace_timer_.Stop(); 1226 startup_trace_timer_.Stop();
1210 } 1227 }
1211 1228
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = 1643 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner =
1627 audio_thread_->task_runner(); 1644 audio_thread_->task_runner();
1628 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), 1645 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner),
1629 std::move(worker_task_runner), 1646 std::move(worker_task_runner),
1630 MediaInternals::GetInstance()); 1647 MediaInternals::GetInstance());
1631 } 1648 }
1632 CHECK(audio_manager_); 1649 CHECK(audio_manager_);
1633 } 1650 }
1634 1651
1635 } // namespace content 1652 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698