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 "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 Loading... | |
| 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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 startup_task_runner_->RunAllTasksNow(); | 863 startup_task_runner_->RunAllTasksNow(); |
| 862 } | 864 } |
| 863 #else | 865 #else |
| 864 startup_task_runner_->RunAllTasksNow(); | 866 startup_task_runner_->RunAllTasksNow(); |
| 865 #endif | 867 #endif |
| 866 } | 868 } |
| 867 | 869 |
| 868 int BrowserMainLoop::CreateThreads() { | 870 int BrowserMainLoop::CreateThreads() { |
| 869 TRACE_EVENT0("startup,rail", "BrowserMainLoop::CreateThreads"); | 871 TRACE_EVENT0("startup,rail", "BrowserMainLoop::CreateThreads"); |
| 870 | 872 |
| 873 std::vector<base::SchedulerWorkerPoolParams> params_vector; | |
| 874 base::TaskScheduler::WorkerPoolIndexForTraitsCallback | |
| 875 index_to_traits_callback; | |
| 876 GetContentClient()->browser()->GetTaskSchedulerInitializationParams( | |
| 877 ¶ms_vector, &index_to_traits_callback); | |
| 878 | |
| 879 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( | |
| 880 params_vector, index_to_traits_callback); | |
| 881 | |
| 882 GetContentClient()->browser()->PerformRedirectionToTaskScheduler(); | |
| 883 | |
| 871 base::Thread::Options io_message_loop_options; | 884 base::Thread::Options io_message_loop_options; |
| 872 io_message_loop_options.message_loop_type = base::MessageLoop::TYPE_IO; | 885 io_message_loop_options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 873 base::Thread::Options ui_message_loop_options; | 886 base::Thread::Options ui_message_loop_options; |
| 874 ui_message_loop_options.message_loop_type = base::MessageLoop::TYPE_UI; | 887 ui_message_loop_options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 875 | 888 |
| 876 // Start threads in the order they occur in the BrowserThread::ID | 889 // Start threads in the order they occur in the BrowserThread::ID |
| 877 // enumeration, except for BrowserThread::UI which is the main | 890 // enumeration, except for BrowserThread::UI which is the main |
| 878 // thread. | 891 // thread. |
| 879 // | 892 // |
| 880 // Must be size_t so we can increment it. | 893 // Must be size_t so we can increment it. |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1190 { | 1203 { |
| 1191 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:BatteryStatusService"); | 1204 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:BatteryStatusService"); |
| 1192 device::BatteryStatusService::GetInstance()->Shutdown(); | 1205 device::BatteryStatusService::GetInstance()->Shutdown(); |
| 1193 } | 1206 } |
| 1194 #endif | 1207 #endif |
| 1195 { | 1208 { |
| 1196 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DeleteDataSources"); | 1209 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DeleteDataSources"); |
| 1197 URLDataManager::DeleteDataSources(); | 1210 URLDataManager::DeleteDataSources(); |
| 1198 } | 1211 } |
| 1199 | 1212 |
| 1213 { | |
| 1214 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:TaskScheduler"); | |
| 1215 base::TaskScheduler::GetInstance()->Shutdown(); | |
|
fdoray
2016/12/06 21:14:12
TaskScheduler is initialized just before browser t
robliao
2016/12/07 00:57:32
Looks like I was too aggressive with the lifetime
| |
| 1216 } | |
| 1217 | |
| 1200 if (parts_) { | 1218 if (parts_) { |
| 1201 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads"); | 1219 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads"); |
| 1202 parts_->PostDestroyThreads(); | 1220 parts_->PostDestroyThreads(); |
| 1203 } | 1221 } |
| 1204 } | 1222 } |
| 1205 | 1223 |
| 1206 void BrowserMainLoop::StopStartupTracingTimer() { | 1224 void BrowserMainLoop::StopStartupTracingTimer() { |
| 1207 startup_trace_timer_.Stop(); | 1225 startup_trace_timer_.Stop(); |
| 1208 } | 1226 } |
| 1209 | 1227 |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1609 if (!audio_manager_) { | 1627 if (!audio_manager_) { |
| 1610 audio_thread_ = base::MakeUnique<AudioDeviceThread>(); | 1628 audio_thread_ = base::MakeUnique<AudioDeviceThread>(); |
| 1611 audio_manager_ = media::AudioManager::Create( | 1629 audio_manager_ = media::AudioManager::Create( |
| 1612 audio_thread_->GetTaskRunner(), audio_thread_->worker_task_runner(), | 1630 audio_thread_->GetTaskRunner(), audio_thread_->worker_task_runner(), |
| 1613 MediaInternals::GetInstance()); | 1631 MediaInternals::GetInstance()); |
| 1614 } | 1632 } |
| 1615 CHECK(audio_manager_); | 1633 CHECK(audio_manager_); |
| 1616 } | 1634 } |
| 1617 | 1635 |
| 1618 } // namespace content | 1636 } // namespace content |
| OLD | NEW |