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

Unified Diff: media/test/pipeline_integration_test_base.cc

Issue 2840593002: Remove usage of ScopedTaskScheduler. (Closed)
Patch Set: rebase 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: media/test/pipeline_integration_test_base.cc
diff --git a/media/test/pipeline_integration_test_base.cc b/media/test/pipeline_integration_test_base.cc
index 4f5636fba3893f68193b5e15f02c357f50faef8a..5db5a86fc2e4aad89b2e865f120b88e0e3669583 100644
--- a/media/test/pipeline_integration_test_base.cc
+++ b/media/test/pipeline_integration_test_base.cc
@@ -106,7 +106,7 @@ class RendererFactoryImpl final : public PipelineTestRendererFactory {
PipelineIntegrationTestBase::PipelineIntegrationTestBase()
: hashing_enabled_(false),
clockless_playback_(false),
- pipeline_(new PipelineImpl(message_loop_.task_runner(), &media_log_)),
+ pipeline_(new PipelineImpl(main_thread_task_runner_, &media_log_)),
ended_(false),
pipeline_status_(PIPELINE_OK),
last_video_frame_format_(PIXEL_FORMAT_UNKNOWN),
@@ -136,8 +136,8 @@ void PipelineIntegrationTestBase::OnSeeked(base::TimeDelta seek_time,
void PipelineIntegrationTestBase::OnStatusCallback(PipelineStatus status) {
pipeline_status_ = status;
- message_loop_.task_runner()->PostTask(
- FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
+ main_thread_task_runner_->PostTask(FROM_HERE,
+ base::MessageLoop::QuitWhenIdleClosure());
}
void PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB(
@@ -165,8 +165,8 @@ void PipelineIntegrationTestBase::OnEnded() {
DCHECK(!ended_);
ended_ = true;
pipeline_status_ = PIPELINE_OK;
- message_loop_.task_runner()->PostTask(
- FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
+ main_thread_task_runner_->PostTask(FROM_HERE,
+ base::MessageLoop::QuitWhenIdleClosure());
}
bool PipelineIntegrationTestBase::WaitUntilOnEnded() {
@@ -187,8 +187,8 @@ PipelineStatus PipelineIntegrationTestBase::WaitUntilEndedOrError() {
void PipelineIntegrationTestBase::OnError(PipelineStatus status) {
DCHECK_NE(status, PIPELINE_OK);
pipeline_status_ = status;
- message_loop_.task_runner()->PostTask(
- FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
+ main_thread_task_runner_->PostTask(FROM_HERE,
+ base::MessageLoop::QuitWhenIdleClosure());
}
PipelineStatus PipelineIntegrationTestBase::StartInternal(
@@ -298,11 +298,12 @@ void PipelineIntegrationTestBase::Pause() {
bool PipelineIntegrationTestBase::Seek(base::TimeDelta seek_time) {
ended_ = false;
+ base::RunLoop run_loop;
EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
- .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow));
+ .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
pipeline_->Seek(seek_time, base::Bind(&PipelineIntegrationTestBase::OnSeeked,
base::Unretained(this), seek_time));
- base::RunLoop().Run();
+ run_loop.Run();
EXPECT_CALL(*this, OnBufferingStateChange(_)).Times(AnyNumber());
return (pipeline_status_ == PIPELINE_OK);
}
@@ -317,14 +318,15 @@ bool PipelineIntegrationTestBase::Suspend() {
bool PipelineIntegrationTestBase::Resume(base::TimeDelta seek_time) {
ended_ = false;
+ base::RunLoop run_loop;
EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
- .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow));
+ .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
pipeline_->Resume(renderer_factory_->CreateRenderer(CreateVideoDecodersCB(),
CreateAudioDecodersCB()),
seek_time,
base::Bind(&PipelineIntegrationTestBase::OnSeeked,
base::Unretained(this), seek_time));
- base::RunLoop().Run();
+ run_loop.Run();
return (pipeline_status_ == PIPELINE_OK);
}
@@ -343,11 +345,11 @@ void PipelineIntegrationTestBase::QuitAfterCurrentTimeTask(
const base::TimeDelta& quit_time) {
if (pipeline_->GetMediaTime() >= quit_time ||
pipeline_status_ != PIPELINE_OK) {
- message_loop_.QuitWhenIdle();
+ base::MessageLoop::current()->QuitWhenIdle();
return;
}
- message_loop_.task_runner()->PostDelayedTask(
+ main_thread_task_runner_->PostDelayedTask(
FROM_HERE,
base::Bind(&PipelineIntegrationTestBase::QuitAfterCurrentTimeTask,
base::Unretained(this), quit_time),
@@ -360,7 +362,7 @@ bool PipelineIntegrationTestBase::WaitUntilCurrentTimeIsAfter(
DCHECK_GT(pipeline_->GetPlaybackRate(), 0);
DCHECK(wait_time <= pipeline_->GetMediaDuration());
- message_loop_.task_runner()->PostDelayedTask(
+ main_thread_task_runner_->PostDelayedTask(
FROM_HERE,
base::Bind(&PipelineIntegrationTestBase::QuitAfterCurrentTimeTask,
base::Unretained(this), wait_time),
@@ -374,9 +376,8 @@ void PipelineIntegrationTestBase::CreateDemuxer(
data_source_ = std::move(data_source);
#if !defined(MEDIA_DISABLE_FFMPEG)
- task_scheduler_.reset(new base::test::ScopedTaskScheduler(&message_loop_));
demuxer_ = std::unique_ptr<Demuxer>(new FFmpegDemuxer(
- message_loop_.task_runner(), data_source_.get(),
+ main_thread_task_runner_, data_source_.get(),
base::Bind(&PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB,
base::Unretained(this)),
base::Bind(&PipelineIntegrationTestBase::DemuxerMediaTracksUpdatedCB,
@@ -393,18 +394,18 @@ std::unique_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer(
clockless_playback_, base::TimeDelta::FromSecondsD(1.0 / 60),
base::Bind(&PipelineIntegrationTestBase::OnVideoFramePaint,
base::Unretained(this)),
- message_loop_.task_runner()));
+ main_thread_task_runner_));
// Disable frame dropping if hashing is enabled.
- std::unique_ptr<VideoRenderer> video_renderer(new VideoRendererImpl(
- message_loop_.task_runner(), message_loop_.task_runner().get(),
- video_sink_.get(),
- base::Bind(&CreateVideoDecodersForTest, &media_log_,
- prepend_video_decoders_cb),
- false, nullptr, &media_log_));
+ std::unique_ptr<VideoRenderer> video_renderer(
+ new VideoRendererImpl(main_thread_task_runner_,
+ main_thread_task_runner_.get(), video_sink_.get(),
+ base::Bind(&CreateVideoDecodersForTest, &media_log_,
+ prepend_video_decoders_cb),
+ false, nullptr, &media_log_));
if (!clockless_playback_) {
- audio_sink_ = new NullAudioSink(message_loop_.task_runner());
+ audio_sink_ = new NullAudioSink(main_thread_task_runner_);
} else {
clockless_audio_sink_ = new ClocklessAudioSink(OutputDeviceInfo(
"", OUTPUT_DEVICE_STATUS_OK,
@@ -417,12 +418,12 @@ std::unique_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer(
}
std::unique_ptr<AudioRenderer> audio_renderer(new AudioRendererImpl(
- message_loop_.task_runner(),
+ main_thread_task_runner_,
(clockless_playback_)
? static_cast<AudioRendererSink*>(clockless_audio_sink_.get())
: audio_sink_.get(),
base::Bind(&CreateAudioDecodersForTest, &media_log_,
- message_loop_.task_runner(), prepend_audio_decoders_cb),
+ main_thread_task_runner_, prepend_audio_decoders_cb),
&media_log_));
if (hashing_enabled_) {
if (clockless_playback_)
@@ -432,7 +433,7 @@ std::unique_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer(
}
std::unique_ptr<RendererImpl> renderer_impl(
- new RendererImpl(message_loop_.task_runner(), std::move(audio_renderer),
+ new RendererImpl(main_thread_task_runner_, std::move(audio_renderer),
std::move(video_renderer)));
// Prevent non-deterministic buffering state callbacks from firing (e.g., slow
« media/gpu/video_decode_accelerator_unittest.cc ('K') | « media/test/pipeline_integration_test_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698