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

Unified Diff: content/browser/renderer_host/media/video_capture_unittest.cc

Issue 2784433002: Ensures that audio tasks cannot run after AudioManager is deleted. (Closed)
Patch Set: rebase Created 3 years, 7 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/renderer_host/media/video_capture_unittest.cc
diff --git a/content/browser/renderer_host/media/video_capture_unittest.cc b/content/browser/renderer_host/media/video_capture_unittest.cc
index 9cb9347eb441e6e65ec1b39a32f429c050017b59..3cb283c2008087d861ced1e743b0198180ea3015 100644
--- a/content/browser/renderer_host/media/video_capture_unittest.cc
+++ b/content/browser/renderer_host/media/video_capture_unittest.cc
@@ -29,6 +29,7 @@
#include "content/test/test_content_browser_client.h"
#include "media/audio/audio_system_impl.h"
#include "media/audio/mock_audio_manager.h"
+#include "media/audio/test_audio_thread.h"
#include "media/base/media_switches.h"
#include "media/capture/video_capture_types.h"
#include "mojo/public/cpp/bindings/binding.h"
@@ -114,12 +115,13 @@ class VideoCaptureTest : public testing::Test,
public:
VideoCaptureTest()
: thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
- audio_manager_(
- new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())),
+ audio_manager_(new media::MockAudioManager(
+ base::MakeUnique<media::TestAudioThread>())),
audio_system_(media::AudioSystemImpl::Create(audio_manager_.get())),
task_runner_(base::ThreadTaskRunnerHandle::Get()),
opened_session_id_(kInvalidMediaCaptureSessionId),
observer_binding_(this) {}
+ ~VideoCaptureTest() override { audio_manager_->Shutdown(); }
void SetUp() override {
SetBrowserClientForTesting(&browser_client_);
@@ -309,9 +311,7 @@ class VideoCaptureTest : public testing::Test,
StrictMock<MockMediaStreamRequester> stream_requester_;
std::unique_ptr<MediaStreamManager> media_stream_manager_;
const content::TestBrowserThreadBundle thread_bundle_;
- // |audio_manager_| needs to outlive |thread_bundle_| because it uses the
- // underlying message loop.
- media::ScopedAudioManagerPtr audio_manager_;
+ std::unique_ptr<media::AudioManager> audio_manager_;
std::unique_ptr<media::AudioSystem> audio_system_;
content::TestBrowserContext browser_context_;
content::TestContentBrowserClient browser_client_;

Powered by Google App Engine
This is Rietveld 408576698