Commit b26e93a5 authored by Wan-Teh Chang's avatar Wan-Teh Chang Committed by Commit Bot

Fix callers of VideoDecoder::Reset to use BindOnce

Update callers of VideoDecoder::Reset() to ensure they are using a
OnceCallback or BindOnce.

Change-Id: I3560af2fd75dafc1ea1e4cc471b00b1cef2d17e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079781
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745636}
parent c07e135e
...@@ -211,9 +211,9 @@ class VideoDecoderAdapter : public CdmVideoDecoder { ...@@ -211,9 +211,9 @@ class VideoDecoderAdapter : public CdmVideoDecoder {
// Reset |video_decoder_| and wait for completion. // Reset |video_decoder_| and wait for completion.
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed); base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
video_decoder_->Reset(base::BindRepeating(&VideoDecoderAdapter::OnReset, video_decoder_->Reset(base::BindOnce(&VideoDecoderAdapter::OnReset,
weak_factory_.GetWeakPtr(), weak_factory_.GetWeakPtr(),
run_loop.QuitClosure())); run_loop.QuitClosure()));
run_loop.Run(); run_loop.Run();
} }
......
...@@ -903,8 +903,8 @@ void DecoderStream<StreamType>::ResetDecoder() { ...@@ -903,8 +903,8 @@ void DecoderStream<StreamType>::ResetDecoder() {
<< state_; << state_;
DCHECK(reset_cb_); DCHECK(reset_cb_);
decoder_->Reset(base::BindRepeating( decoder_->Reset(base::BindOnce(&DecoderStream<StreamType>::OnDecoderReset,
&DecoderStream<StreamType>::OnDecoderReset, weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
template <DemuxerStream::Type StreamType> template <DemuxerStream::Type StreamType>
......
...@@ -196,8 +196,8 @@ class FakeVideoDecoderTest ...@@ -196,8 +196,8 @@ class FakeVideoDecoderTest
void ResetAndExpect(CallbackResult result) { void ResetAndExpect(CallbackResult result) {
is_reset_pending_ = true; is_reset_pending_ = true;
decoder_->Reset(base::Bind(&FakeVideoDecoderTest::OnDecoderReset, decoder_->Reset(base::BindOnce(&FakeVideoDecoderTest::OnDecoderReset,
base::Unretained(this))); base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
ExpectResetResult(result); ExpectResetResult(result);
} }
......
...@@ -98,11 +98,11 @@ class OffloadingVideoDecoderTest : public testing::Test { ...@@ -98,11 +98,11 @@ class OffloadingVideoDecoderTest : public testing::Test {
base::Unretained(this)); base::Unretained(this));
} }
base::Closure ExpectResetCB() { base::OnceClosure ExpectResetCB() {
EXPECT_CALL(*this, ResetDone()) EXPECT_CALL(*this, ResetDone())
.WillOnce(VerifyOn(task_env_.GetMainThreadTaskRunner())); .WillOnce(VerifyOn(task_env_.GetMainThreadTaskRunner()));
return base::Bind(&OffloadingVideoDecoderTest::ResetDone, return base::BindOnce(&OffloadingVideoDecoderTest::ResetDone,
base::Unretained(this)); base::Unretained(this));
} }
void TestNoOffloading(const VideoDecoderConfig& config) { void TestNoOffloading(const VideoDecoderConfig& config) {
......
...@@ -259,7 +259,7 @@ class MediaCodecVideoDecoderTest : public testing::TestWithParam<VideoCodec> { ...@@ -259,7 +259,7 @@ class MediaCodecVideoDecoderTest : public testing::TestWithParam<VideoCodec> {
// Start and finish a reset. // Start and finish a reset.
void DoReset() { void DoReset() {
bool reset_complete = false; bool reset_complete = false;
mcvd_->Reset(base::BindRepeating( mcvd_->Reset(base::BindOnce(
[](bool* reset_complete) { *reset_complete = true; }, &reset_complete)); [](bool* reset_complete) { *reset_complete = true; }, &reset_complete));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
if (!reset_complete) { if (!reset_complete) {
...@@ -597,7 +597,7 @@ TEST_P(MediaCodecVideoDecoderTest, TransitionToSameSurfaceIsIgnored) { ...@@ -597,7 +597,7 @@ TEST_P(MediaCodecVideoDecoderTest, TransitionToSameSurfaceIsIgnored) {
TEST_P(MediaCodecVideoDecoderTest, TEST_P(MediaCodecVideoDecoderTest,
ResetBeforeCodecInitializedSucceedsImmediately) { ResetBeforeCodecInitializedSucceedsImmediately) {
InitializeWithTextureOwner_OneDecodePending(TestVideoConfig::Large(codec_)); InitializeWithTextureOwner_OneDecodePending(TestVideoConfig::Large(codec_));
base::MockCallback<base::Closure> reset_cb; base::MockCallback<base::OnceClosure> reset_cb;
EXPECT_CALL(reset_cb, Run()); EXPECT_CALL(reset_cb, Run());
mcvd_->Reset(reset_cb.Get()); mcvd_->Reset(reset_cb.Get());
testing::Mock::VerifyAndClearExpectations(&reset_cb); testing::Mock::VerifyAndClearExpectations(&reset_cb);
...@@ -635,7 +635,7 @@ TEST_P(MediaCodecVideoDecoderTest, ResetDoesNotFlushAnAlreadyFlushedCodec) { ...@@ -635,7 +635,7 @@ TEST_P(MediaCodecVideoDecoderTest, ResetDoesNotFlushAnAlreadyFlushedCodec) {
// The codec is still in the flushed state so Reset() doesn't need to flush. // The codec is still in the flushed state so Reset() doesn't need to flush.
EXPECT_CALL(*codec, Flush()).Times(0); EXPECT_CALL(*codec, Flush()).Times(0);
base::MockCallback<base::Closure> reset_cb; base::MockCallback<base::OnceClosure> reset_cb;
EXPECT_CALL(reset_cb, Run()); EXPECT_CALL(reset_cb, Run());
mcvd_->Reset(reset_cb.Get()); mcvd_->Reset(reset_cb.Get());
testing::Mock::VerifyAndClearExpectations(&decode_cb_); testing::Mock::VerifyAndClearExpectations(&decode_cb_);
...@@ -651,7 +651,7 @@ TEST_P(MediaCodecVideoDecoderVp8Test, ResetDrainsVP8CodecsBeforeFlushing) { ...@@ -651,7 +651,7 @@ TEST_P(MediaCodecVideoDecoderVp8Test, ResetDrainsVP8CodecsBeforeFlushing) {
// The reset should not complete immediately because the codec needs to be // The reset should not complete immediately because the codec needs to be
// drained. // drained.
EXPECT_CALL(*codec, Flush()).Times(0); EXPECT_CALL(*codec, Flush()).Times(0);
base::MockCallback<base::Closure> reset_cb; base::MockCallback<base::OnceClosure> reset_cb;
EXPECT_CALL(reset_cb, Run()).Times(0); EXPECT_CALL(reset_cb, Run()).Times(0);
mcvd_->Reset(reset_cb.Get()); mcvd_->Reset(reset_cb.Get());
...@@ -720,7 +720,7 @@ TEST_P(MediaCodecVideoDecoderVp8Test, ResetDoesNotDrainVp8WithAsyncApi) { ...@@ -720,7 +720,7 @@ TEST_P(MediaCodecVideoDecoderVp8Test, ResetDoesNotDrainVp8WithAsyncApi) {
// The reset should complete immediately because the codec is not VP8 so // The reset should complete immediately because the codec is not VP8 so
// it doesn't need draining. We don't expect a call to Flush on the codec // it doesn't need draining. We don't expect a call to Flush on the codec
// since it will be deferred until the first decode after the reset. // since it will be deferred until the first decode after the reset.
base::MockCallback<base::Closure> reset_cb; base::MockCallback<base::OnceClosure> reset_cb;
EXPECT_CALL(reset_cb, Run()); EXPECT_CALL(reset_cb, Run());
mcvd_->Reset(reset_cb.Get()); mcvd_->Reset(reset_cb.Get());
// The reset should complete before destroying the codec, since TearDown will // The reset should complete before destroying the codec, since TearDown will
...@@ -739,7 +739,7 @@ TEST_P(MediaCodecVideoDecoderH264Test, ResetDoesNotDrainNonVp8Codecs) { ...@@ -739,7 +739,7 @@ TEST_P(MediaCodecVideoDecoderH264Test, ResetDoesNotDrainNonVp8Codecs) {
// The reset should complete immediately because the codec is not VP8 so // The reset should complete immediately because the codec is not VP8 so
// it doesn't need draining. We don't expect a call to Flush on the codec // it doesn't need draining. We don't expect a call to Flush on the codec
// since it will be deferred until the first decode after the reset. // since it will be deferred until the first decode after the reset.
base::MockCallback<base::Closure> reset_cb; base::MockCallback<base::OnceClosure> reset_cb;
EXPECT_CALL(reset_cb, Run()); EXPECT_CALL(reset_cb, Run());
mcvd_->Reset(reset_cb.Get()); mcvd_->Reset(reset_cb.Get());
// The reset should complete before destroying the codec, since TearDown will // The reset should complete before destroying the codec, since TearDown will
...@@ -756,7 +756,7 @@ TEST_P(MediaCodecVideoDecoderVp8Test, TeardownCompletesPendingReset) { ...@@ -756,7 +756,7 @@ TEST_P(MediaCodecVideoDecoderVp8Test, TeardownCompletesPendingReset) {
codec->AcceptOneInput(); codec->AcceptOneInput();
PumpCodec(); PumpCodec();
base::MockCallback<base::Closure> reset_cb; base::MockCallback<base::OnceClosure> reset_cb;
EXPECT_CALL(reset_cb, Run()).Times(0); EXPECT_CALL(reset_cb, Run()).Times(0);
mcvd_->Reset(reset_cb.Get()); mcvd_->Reset(reset_cb.Get());
EXPECT_CALL(reset_cb, Run()); EXPECT_CALL(reset_cb, Run());
......
...@@ -297,7 +297,7 @@ class VdaVideoDecoderTest : public testing::TestWithParam<bool> { ...@@ -297,7 +297,7 @@ class VdaVideoDecoderTest : public testing::TestWithParam<bool> {
testing::StrictMock<base::MockCallback<VideoDecoder::OutputCB>> output_cb_; testing::StrictMock<base::MockCallback<VideoDecoder::OutputCB>> output_cb_;
testing::StrictMock<base::MockCallback<WaitingCB>> waiting_cb_; testing::StrictMock<base::MockCallback<WaitingCB>> waiting_cb_;
testing::StrictMock<base::MockCallback<VideoDecoder::DecodeCB>> decode_cb_; testing::StrictMock<base::MockCallback<VideoDecoder::DecodeCB>> decode_cb_;
testing::StrictMock<base::MockCallback<base::RepeatingClosure>> reset_cb_; testing::StrictMock<base::MockCallback<base::OnceClosure>> reset_cb_;
scoped_refptr<FakeCommandBufferHelper> cbh_; scoped_refptr<FakeCommandBufferHelper> cbh_;
testing::StrictMock<MockVideoDecodeAccelerator>* vda_; testing::StrictMock<MockVideoDecodeAccelerator>* vda_;
......
...@@ -345,10 +345,10 @@ void VideoDecoderClient::ResetTask() { ...@@ -345,10 +345,10 @@ void VideoDecoderClient::ResetTask() {
// TODO(dstaessens@) Allow resetting to any point in the stream. // TODO(dstaessens@) Allow resetting to any point in the stream.
encoded_data_helper_->Rewind(); encoded_data_helper_->Rewind();
base::RepeatingClosure reset_done_cb = base::BindRepeating( decoder_->Reset(base::BindOnce(
CallbackThunk<decltype(&VideoDecoderClient::ResetDoneTask)>, weak_this_, CallbackThunk<decltype(&VideoDecoderClient::ResetDoneTask)>, weak_this_,
decoder_client_thread_.task_runner(), &VideoDecoderClient::ResetDoneTask); decoder_client_thread_.task_runner(),
decoder_->Reset(reset_done_cb); &VideoDecoderClient::ResetDoneTask));
FireEvent(VideoPlayerEvent::kResetting); FireEvent(VideoPlayerEvent::kResetting);
} }
......
...@@ -293,8 +293,8 @@ void MojoVideoDecoderService::OnReaderRead( ...@@ -293,8 +293,8 @@ void MojoVideoDecoderService::OnReaderRead(
} }
void MojoVideoDecoderService::OnReaderFlushed() { void MojoVideoDecoderService::OnReaderFlushed() {
decoder_->Reset(base::BindRepeating(&MojoVideoDecoderService::OnDecoderReset, decoder_->Reset(
weak_this_)); base::BindOnce(&MojoVideoDecoderService::OnDecoderReset, weak_this_));
} }
void MojoVideoDecoderService::OnDecoderDecoded( void MojoVideoDecoderService::OnDecoderDecoded(
......
...@@ -480,7 +480,7 @@ TEST_F(MojoVideoDecoderIntegrationTest, ResetDuringDecode) { ...@@ -480,7 +480,7 @@ TEST_F(MojoVideoDecoderIntegrationTest, ResetDuringDecode) {
ASSERT_TRUE(Initialize()); ASSERT_TRUE(Initialize());
StrictMock<base::MockCallback<VideoDecoder::DecodeCB>> decode_cb; StrictMock<base::MockCallback<VideoDecoder::DecodeCB>> decode_cb;
StrictMock<base::MockCallback<base::Closure>> reset_cb; StrictMock<base::MockCallback<base::OnceClosure>> reset_cb;
EXPECT_CALL(*decoder_, DidGetReleaseMailboxCB()).Times(AtLeast(0)); EXPECT_CALL(*decoder_, DidGetReleaseMailboxCB()).Times(AtLeast(0));
EXPECT_CALL(output_cb_, Run(_)).Times(kMaxDecodeRequests); EXPECT_CALL(output_cb_, Run(_)).Times(kMaxDecodeRequests);
...@@ -508,7 +508,7 @@ TEST_F(MojoVideoDecoderIntegrationTest, ResetDuringDecode_ChunkedWrite) { ...@@ -508,7 +508,7 @@ TEST_F(MojoVideoDecoderIntegrationTest, ResetDuringDecode_ChunkedWrite) {
VideoFrame::ReleaseMailboxCB release_cb = VideoFrame::ReleaseMailboxCB(); VideoFrame::ReleaseMailboxCB release_cb = VideoFrame::ReleaseMailboxCB();
StrictMock<base::MockCallback<VideoDecoder::DecodeCB>> decode_cb; StrictMock<base::MockCallback<VideoDecoder::DecodeCB>> decode_cb;
StrictMock<base::MockCallback<base::Closure>> reset_cb; StrictMock<base::MockCallback<base::OnceClosure>> reset_cb;
EXPECT_CALL(*decoder_, DidGetReleaseMailboxCB()).Times(AtLeast(0)); EXPECT_CALL(*decoder_, DidGetReleaseMailboxCB()).Times(AtLeast(0));
EXPECT_CALL(output_cb_, Run(_)).Times(kMaxDecodeRequests); EXPECT_CALL(output_cb_, Run(_)).Times(kMaxDecodeRequests);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment