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

Unified Diff: content/browser/browser_main_loop.cc

Issue 2784433002: Ensures that audio tasks cannot run after AudioManager is deleted. (Closed)
Patch Set: chromeos and android build Created 3 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_main_loop.cc
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index c9828a57bff423c29ef73f368e73877efb9292e4..a0fc7c7004dd32c5000f0980f85fc9e6c15f25c7 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -51,7 +51,6 @@
#include "components/tracing/common/trace_config_file.h"
#include "components/tracing/common/trace_to_console.h"
#include "components/tracing/common/tracing_switches.h"
-#include "content/browser/audio_manager_thread.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/dom_storage/dom_storage_area.h"
#include "content/browser/download/download_resource_handler.h"
@@ -91,7 +90,9 @@
#include "content/public/common/result_codes.h"
#include "device/gamepad/gamepad_service.h"
#include "gpu/vulkan/features.h"
+#include "media/audio/audio_manager.h"
#include "media/audio/audio_system_impl.h"
+#include "media/audio/audio_thread_impl.h"
#include "media/base/media.h"
#include "media/base/user_input_monitor.h"
#include "media/midi/midi_service.h"
@@ -1349,6 +1350,10 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() {
TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DeleteDataSources");
URLDataManager::DeleteDataSources();
}
+ {
+ TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:AudioMan");
+ DestroyAudioManager();
+ }
if (parts_) {
TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:PostDestroyThreads");
@@ -1739,15 +1744,13 @@ void BrowserMainLoop::EndStartupTracing() {
}
void BrowserMainLoop::CreateAudioManager() {
- DCHECK(!audio_thread_);
DCHECK(!audio_manager_);
audio_manager_ = GetContentClient()->browser()->CreateAudioManager(
MediaInternals::GetInstance());
if (!audio_manager_) {
- audio_thread_ = base::MakeUnique<AudioManagerThread>();
audio_manager_ = media::AudioManager::Create(
- audio_thread_->task_runner(), audio_thread_->worker_task_runner(),
+ base::MakeUnique<media::AudioThreadImpl>(),
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
MediaInternals::GetInstance());
}
@@ -1757,4 +1760,13 @@ void BrowserMainLoop::CreateAudioManager() {
CHECK(audio_system_);
}
+void BrowserMainLoop::DestroyAudioManager() {
+ DCHECK(audio_manager_);
+
+ audio_system_.reset();
+
+ audio_manager_->Shutdown();
+ audio_manager_.reset();
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698