summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-12 22:50:19 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-12 22:50:19 +0000
commitd527cdd8d20d760114726a0b65d6ff85f7832880 (patch)
tree971aac9dc208539a380083b1fd336d6a8a341877
parentae3ac17598586553c9963df44566427410afadae (diff)
downloadchromium_src-d527cdd8d20d760114726a0b65d6ff85f7832880.zip
chromium_src-d527cdd8d20d760114726a0b65d6ff85f7832880.tar.gz
chromium_src-d527cdd8d20d760114726a0b65d6ff85f7832880.tar.bz2
Gracefully handle multiple Flush/Reset/Decode with same id
The DCHECKs don't trigger in release, and in any case it's a bit rude to have the renderer crash on a plugin that did the wrong thing, so send an error instead. BUG=None TEST=Pepper Flash Review URL: http://codereview.chromium.org/7628025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96649 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ppapi/proxy/ppb_video_decoder_proxy.cc9
-rw-r--r--ppapi/shared_impl/video_decoder_impl.cc18
-rw-r--r--ppapi/shared_impl/video_decoder_impl.h6
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.cc9
4 files changed, 26 insertions, 16 deletions
diff --git a/ppapi/proxy/ppb_video_decoder_proxy.cc b/ppapi/proxy/ppb_video_decoder_proxy.cc
index dc65d9f..ddeeabd 100644
--- a/ppapi/proxy/ppb_video_decoder_proxy.cc
+++ b/ppapi/proxy/ppb_video_decoder_proxy.cc
@@ -96,7 +96,8 @@ int32_t VideoDecoder::Decode(
if (enter_buffer.failed())
return PP_ERROR_BADRESOURCE;
- SetBitstreamBufferCallback(bitstream_buffer->id, callback);
+ if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback))
+ return PP_ERROR_BADARGUMENT;
Buffer* ppb_buffer =
static_cast<Buffer*>(enter_buffer.object());
@@ -127,7 +128,8 @@ void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) {
}
int32_t VideoDecoder::Flush(PP_CompletionCallback callback) {
- SetFlushCallback(callback);
+ if (!SetFlushCallback(callback))
+ return PP_ERROR_INPROGRESS;
FlushCommandBuffer();
GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Flush(
@@ -136,7 +138,8 @@ int32_t VideoDecoder::Flush(PP_CompletionCallback callback) {
}
int32_t VideoDecoder::Reset(PP_CompletionCallback callback) {
- SetResetCallback(callback);
+ if (!SetResetCallback(callback))
+ return PP_ERROR_INPROGRESS;
FlushCommandBuffer();
GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Reset(
diff --git a/ppapi/shared_impl/video_decoder_impl.cc b/ppapi/shared_impl/video_decoder_impl.cc
index e665941..ef20f8b 100644
--- a/ppapi/shared_impl/video_decoder_impl.cc
+++ b/ppapi/shared_impl/video_decoder_impl.cc
@@ -44,22 +44,26 @@ void VideoDecoderImpl::Destroy() {
UnrefResource(context3d_id_);
}
-void VideoDecoderImpl::SetFlushCallback(PP_CompletionCallback callback) {
+bool VideoDecoderImpl::SetFlushCallback(PP_CompletionCallback callback) {
CHECK(callback.func);
- DCHECK(!flush_callback_.func);
+ if (flush_callback_.func)
+ return false;
flush_callback_ = callback;
+ return true;
}
-void VideoDecoderImpl::SetResetCallback(PP_CompletionCallback callback) {
+bool VideoDecoderImpl::SetResetCallback(PP_CompletionCallback callback) {
CHECK(callback.func);
- DCHECK(!reset_callback_.func);
+ if (reset_callback_.func)
+ return false;
reset_callback_ = callback;
+ return true;
}
-void VideoDecoderImpl::SetBitstreamBufferCallback(
+bool VideoDecoderImpl::SetBitstreamBufferCallback(
int32 bitstream_buffer_id, PP_CompletionCallback callback) {
- CHECK(bitstream_buffer_callbacks_.insert(
- std::make_pair(bitstream_buffer_id, callback)).second);
+ return bitstream_buffer_callbacks_.insert(
+ std::make_pair(bitstream_buffer_id, callback)).second;
}
void VideoDecoderImpl::RunFlushCallback(int32 result) {
diff --git a/ppapi/shared_impl/video_decoder_impl.h b/ppapi/shared_impl/video_decoder_impl.h
index b874bba..6cd8044 100644
--- a/ppapi/shared_impl/video_decoder_impl.h
+++ b/ppapi/shared_impl/video_decoder_impl.h
@@ -44,9 +44,9 @@ class VideoDecoderImpl : public thunk::PPB_VideoDecoder_API {
std::vector<PP_VideoConfigElement>* out_configs);
protected:
- void SetFlushCallback(PP_CompletionCallback callback);
- void SetResetCallback(PP_CompletionCallback callback);
- void SetBitstreamBufferCallback(
+ bool SetFlushCallback(PP_CompletionCallback callback);
+ bool SetResetCallback(PP_CompletionCallback callback);
+ bool SetBitstreamBufferCallback(
int32 bitstream_buffer_id, PP_CompletionCallback callback);
void RunFlushCallback(int32 result);
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
index 57c4dbc..9c8b37e 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
@@ -104,7 +104,8 @@ int32_t PPB_VideoDecoder_Impl::Decode(
bitstream_buffer->id,
buffer->shared_memory()->handle(),
static_cast<size_t>(bitstream_buffer->size));
- SetBitstreamBufferCallback(bitstream_buffer->id, callback);
+ if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback))
+ return PP_ERROR_BADARGUMENT;
FlushCommandBuffer();
platform_video_decoder_->Decode(decode_buffer);
@@ -143,7 +144,8 @@ int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) {
if (!platform_video_decoder_)
return PP_ERROR_BADRESOURCE;
- SetFlushCallback(callback);
+ if (!SetFlushCallback(callback))
+ return PP_ERROR_INPROGRESS;
FlushCommandBuffer();
platform_video_decoder_->Flush();
@@ -154,7 +156,8 @@ int32_t PPB_VideoDecoder_Impl::Reset(PP_CompletionCallback callback) {
if (!platform_video_decoder_)
return PP_ERROR_BADRESOURCE;
- SetResetCallback(callback);
+ if (!SetResetCallback(callback))
+ return PP_ERROR_INPROGRESS;
FlushCommandBuffer();
platform_video_decoder_->Reset();