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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 #include "content/public/browser/render_process_host.h" | 86 #include "content/public/browser/render_process_host.h" |
87 #include "content/public/browser/tracing_controller.h" | 87 #include "content/public/browser/tracing_controller.h" |
88 #include "content/public/common/content_client.h" | 88 #include "content/public/common/content_client.h" |
89 #include "content/public/common/content_features.h" | 89 #include "content/public/common/content_features.h" |
90 #include "content/public/common/content_switches.h" | 90 #include "content/public/common/content_switches.h" |
91 #include "content/public/common/main_function_params.h" | 91 #include "content/public/common/main_function_params.h" |
92 #include "content/public/common/result_codes.h" | 92 #include "content/public/common/result_codes.h" |
93 #include "device/battery/battery_status_service.h" | 93 #include "device/battery/battery_status_service.h" |
94 #include "device/gamepad/gamepad_service.h" | 94 #include "device/gamepad/gamepad_service.h" |
95 #include "gpu/vulkan/features.h" | 95 #include "gpu/vulkan/features.h" |
96 #include "media/audio/audio_manager.h" | |
96 #include "media/audio/audio_system_impl.h" | 97 #include "media/audio/audio_system_impl.h" |
97 #include "media/base/media.h" | 98 #include "media/base/media.h" |
98 #include "media/base/user_input_monitor.h" | 99 #include "media/base/user_input_monitor.h" |
99 #include "media/midi/midi_service.h" | 100 #include "media/midi/midi_service.h" |
100 #include "mojo/edk/embedder/embedder.h" | 101 #include "mojo/edk/embedder/embedder.h" |
101 #include "mojo/edk/embedder/scoped_ipc_support.h" | 102 #include "mojo/edk/embedder/scoped_ipc_support.h" |
102 #include "net/base/network_change_notifier.h" | 103 #include "net/base/network_change_notifier.h" |
103 #include "net/socket/client_socket_factory.h" | 104 #include "net/socket/client_socket_factory.h" |
104 #include "net/ssl/ssl_config_service.h" | 105 #include "net/ssl/ssl_config_service.h" |
105 #include "ppapi/features/features.h" | 106 #include "ppapi/features/features.h" |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1386 #if !defined(OS_ANDROID) | 1387 #if !defined(OS_ANDROID) |
1387 { | 1388 { |
1388 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:BatteryStatusService"); | 1389 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:BatteryStatusService"); |
1389 device::BatteryStatusService::GetInstance()->Shutdown(); | 1390 device::BatteryStatusService::GetInstance()->Shutdown(); |
1390 } | 1391 } |
1391 #endif | 1392 #endif |
1392 { | 1393 { |
1393 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DeleteDataSources"); | 1394 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DeleteDataSources"); |
1394 URLDataManager::DeleteDataSources(); | 1395 URLDataManager::DeleteDataSources(); |
1395 } | 1396 } |
1397 { | |
1398 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:AudioMan"); | |
1399 DestroyAudioManager(); | |
1400 } | |
1396 | 1401 |
1397 if (parts_) { | 1402 if (parts_) { |
1398 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads"); | 1403 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads"); |
1399 parts_->PostDestroyThreads(); | 1404 parts_->PostDestroyThreads(); |
1400 } | 1405 } |
1401 } | 1406 } |
1402 | 1407 |
1403 void BrowserMainLoop::StopStartupTracingTimer() { | 1408 void BrowserMainLoop::StopStartupTracingTimer() { |
1404 startup_trace_timer_.Stop(); | 1409 startup_trace_timer_.Stop(); |
1405 } | 1410 } |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1774 TracingController::GetInstance()->StopTracing( | 1779 TracingController::GetInstance()->StopTracing( |
1775 TracingController::CreateFileSink( | 1780 TracingController::CreateFileSink( |
1776 startup_trace_file_, | 1781 startup_trace_file_, |
1777 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); | 1782 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); |
1778 } | 1783 } |
1779 | 1784 |
1780 void BrowserMainLoop::CreateAudioManager() { | 1785 void BrowserMainLoop::CreateAudioManager() { |
1781 DCHECK(!audio_thread_); | 1786 DCHECK(!audio_thread_); |
1782 DCHECK(!audio_manager_); | 1787 DCHECK(!audio_manager_); |
1783 | 1788 |
1789 audio_thread_ = base::MakeUnique<AudioManagerThread>(); | |
1784 audio_manager_ = GetContentClient()->browser()->CreateAudioManager( | 1790 audio_manager_ = GetContentClient()->browser()->CreateAudioManager( |
1791 audio_thread_->task_runner(), audio_thread_->worker_task_runner(), | |
1785 MediaInternals::GetInstance()); | 1792 MediaInternals::GetInstance()); |
1786 if (!audio_manager_) { | 1793 if (!audio_manager_) { |
1787 audio_thread_ = base::MakeUnique<AudioManagerThread>(); | |
1788 audio_manager_ = media::AudioManager::Create( | 1794 audio_manager_ = media::AudioManager::Create( |
1789 audio_thread_->task_runner(), audio_thread_->worker_task_runner(), | 1795 audio_thread_->task_runner(), audio_thread_->worker_task_runner(), |
1790 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), | 1796 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
1791 MediaInternals::GetInstance()); | 1797 MediaInternals::GetInstance()); |
1792 } | 1798 } |
1793 CHECK(audio_manager_); | 1799 CHECK(audio_manager_); |
1794 | 1800 |
1795 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); | 1801 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); |
1796 CHECK(audio_system_); | 1802 CHECK(audio_system_); |
1797 } | 1803 } |
1798 | 1804 |
1805 void BrowserMainLoop::DestroyAudioManager() { | |
1806 DCHECK(audio_manager_); | |
1807 DCHECK(audio_thread_); | |
1808 | |
1809 // |audio_manager_| must be shut down on |audio_thread_| before it is deleted. | |
1810 if (audio_manager_->GetTaskRunner()->BelongsToCurrentThread()) { | |
1811 audio_manager_->Shutdown(); | |
1812 } else { | |
1813 audio_manager_->GetTaskRunner()->PostTask( | |
1814 FROM_HERE, base::Bind(&media::AudioManager::Shutdown, | |
1815 base::Unretained(audio_manager_.get()))); | |
1816 } | |
1817 | |
1818 // Stop |audio_thread_| before deleting |audio_manager_| so that all tasks | |
1819 // currently in the |audio_thread_| queue run and no more can be posted. | |
1820 audio_thread_.reset(); | |
o1ka
2017/03/28 18:32:23
Is there a guarantee that all the queued tasks wil
o1ka
2017/03/29 09:28:32
Never mind - I checked it now, base::Thread will d
| |
1821 | |
1822 // Safe to delete the |audio_manager_|. | |
1823 audio_manager_.reset(); | |
o1ka
2017/03/28 18:32:23
Looks like we need to reset AudioSystem before thi
| |
1824 } | |
1825 | |
1799 } // namespace content | 1826 } // namespace content |
OLD | NEW |