Commit 5a10c79b authored by xhwang@chromium.org's avatar xhwang@chromium.org

VideoRenderer: Fires all pending callbacks in dtor.

This make VideoRenderer consistent with the rest of the media pipeline.

BUG=349211
TEST=All existing tests pass.

Review URL: https://codereview.chromium.org/414583002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284898 0039d316-1c4b-4281-b951-d872f2087c98
parent ff0d8537
......@@ -28,9 +28,7 @@ class MEDIA_EXPORT VideoRenderer {
VideoRenderer();
// Stops all operations and drops all pending callbacks.
// TODO(xhwang): Fires all pending callbacks to be consistent with the rest of
// media pipeline.
// Stops all operations and fires all pending callbacks.
virtual ~VideoRenderer();
// Initializes a VideoRenderer with |stream|, executing |init_cb| upon
......
......@@ -57,6 +57,12 @@ VideoRendererImpl::~VideoRendererImpl() {
if (!thread_.is_null())
base::PlatformThread::Join(thread_);
if (!init_cb_.is_null())
base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT);
if (!flush_cb_.is_null())
base::ResetAndReturn(&flush_cb_).Run();
}
void VideoRendererImpl::Flush(const base::Closure& callback) {
......
......@@ -26,10 +26,8 @@
using ::testing::_;
using ::testing::AnyNumber;
using ::testing::AtLeast;
using ::testing::Invoke;
using ::testing::NiceMock;
using ::testing::NotNull;
using ::testing::Return;
using ::testing::SaveArg;
using ::testing::StrictMock;
......@@ -357,13 +355,8 @@ TEST_F(VideoRendererImplTest, InitializeAndStartPlaying) {
Destroy();
}
static void ExpectNotCalled(PipelineStatus) {
base::debug::StackTrace stack;
ADD_FAILURE() << "Expected callback not to be called\n" << stack.ToString();
}
TEST_F(VideoRendererImplTest, DestroyWhileInitializing) {
CallInitialize(base::Bind(&ExpectNotCalled), false, PIPELINE_OK);
CallInitialize(NewExpectedStatusCB(PIPELINE_ERROR_ABORT), false, PIPELINE_OK);
Destroy();
}
......@@ -374,7 +367,7 @@ TEST_F(VideoRendererImplTest, DestroyWhileFlushing) {
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH));
StartPlaying();
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING));
renderer_->Flush(base::Bind(&ExpectNotCalled, PIPELINE_OK));
renderer_->Flush(NewExpectedClosure());
Destroy();
}
......
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