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

Unified Diff: content/browser/renderer_host/media/audio_renderer_host_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/audio_renderer_host_unittest.cc
diff --git a/content/browser/renderer_host/media/audio_renderer_host_unittest.cc b/content/browser/renderer_host/media/audio_renderer_host_unittest.cc
index 20ea45557eb243a36ef6ec40955a899fecfa02bd..1f934cf5297022185924c1384aabb6e6f7879366 100644
--- a/content/browser/renderer_host/media/audio_renderer_host_unittest.cc
+++ b/content/browser/renderer_host/media/audio_renderer_host_unittest.cc
@@ -29,6 +29,7 @@
#include "media/audio/audio_system_impl.h"
#include "media/audio/fake_audio_log_factory.h"
#include "media/audio/fake_audio_manager.h"
+#include "media/audio/test_audio_thread.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/media_switches.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -97,10 +98,8 @@ class MockRenderProcessHostWithSignaling : public MockRenderProcessHost {
class FakeAudioManagerWithAssociations : public media::FakeAudioManager {
public:
- FakeAudioManagerWithAssociations(
- scoped_refptr<base::SingleThreadTaskRunner> task_runner,
- media::AudioLogFactory* factory)
- : FakeAudioManager(task_runner, task_runner, factory) {}
+ FakeAudioManagerWithAssociations(media::AudioLogFactory* factory)
+ : FakeAudioManager(base::MakeUnique<media::TestAudioThread>(), factory) {}
void CreateDeviceAssociation(const std::string& input_device_id,
const std::string& output_device_id) {
@@ -236,7 +235,6 @@ class AudioRendererHostTest : public testing::Test {
AudioRendererHostTest()
: log_factory(base::MakeUnique<media::FakeAudioLogFactory>()),
audio_manager_(base::MakeUnique<FakeAudioManagerWithAssociations>(
- base::ThreadTaskRunnerHandle::Get(),
log_factory.get())),
audio_system_(media::AudioSystemImpl::Create(audio_manager_.get())),
render_process_host_(&browser_context_, &auth_run_loop_) {
@@ -257,11 +255,7 @@ class AudioRendererHostTest : public testing::Test {
// Simulate closing the IPC channel and give the audio thread time to close
// the underlying streams.
host_->OnChannelClosing();
- SyncWithAudioThread();
- // To correctly clean up the audio manager, we first put it in a
- // ScopedAudioManagerPtr. It will immediately destruct, cleaning up the
- // audio manager correctly.
- media::ScopedAudioManagerPtr(audio_manager_.release());
+ audio_manager_->Shutdown();
// Release the reference to the mock object. The object will be destructed
// on message_loop_.

Powered by Google App Engine
This is Rietveld 408576698