diff options
author | polina@google.com <polina@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-04 01:33:11 +0000 |
---|---|---|
committer | polina@google.com <polina@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-04 01:33:11 +0000 |
commit | b47815f17b42a73d3da78364bd10b501450db00b (patch) | |
tree | 2158508cbe879ac10076191e31681347eabf8ef2 /webkit | |
parent | 1b576261ac143b13a290be9b2c3be0f246a6e466 (diff) | |
download | chromium_src-b47815f17b42a73d3da78364bd10b501450db00b.zip chromium_src-b47815f17b42a73d3da78364bd10b501450db00b.tar.gz chromium_src-b47815f17b42a73d3da78364bd10b501450db00b.tar.bz2 |
PPAPI: Fix interface functions that take PP_CompletionCallbacks, but don't
return codes from pp_errors.h
BUG=none
TEST=compile + manually run ppapi_tests::VideoDecoder
Review URL: http://codereview.chromium.org/6975053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87905 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/ppapi/ppb_layer_compositor_impl.cc | 11 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_layer_compositor_impl.h | 2 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_video_decoder_impl.cc | 93 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_video_decoder_impl.h | 12 |
4 files changed, 69 insertions, 49 deletions
diff --git a/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc b/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc index 65e5d10..93e3032 100644 --- a/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc +++ b/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc @@ -4,6 +4,7 @@ #include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h" +#include "ppapi/c/pp_errors.h" #include "webkit/plugins/ppapi/common.h" namespace webkit { @@ -40,9 +41,9 @@ void SetDisplay(PP_Resource compositor, PP_Resource layer, void MarkAsDirty(PP_Resource compositor, PP_Resource layer) { } -PP_Bool SwapBuffers(PP_Resource compositor, - struct PP_CompletionCallback callback) { - return PP_FALSE; +int32_t SwapBuffers(PP_Resource compositor, + struct PP_CompletionCallback callback) { + return PP_ERROR_FAILED; } const PPB_LayerCompositor_Dev ppb_layercompositor = { @@ -97,9 +98,9 @@ void PPB_LayerCompositor_Impl::SetDisplay(PP_Resource layer, void PPB_LayerCompositor_Impl::MarkAsDirty(PP_Resource layer) { } -PP_Bool PPB_LayerCompositor_Impl::SwapBuffers( +int32_t PPB_LayerCompositor_Impl::SwapBuffers( struct PP_CompletionCallback callback) { - return PP_FALSE; + return PP_ERROR_FAILED; } } // namespace ppapi diff --git a/webkit/plugins/ppapi/ppb_layer_compositor_impl.h b/webkit/plugins/ppapi/ppb_layer_compositor_impl.h index a84fb27..7d3a023 100644 --- a/webkit/plugins/ppapi/ppb_layer_compositor_impl.h +++ b/webkit/plugins/ppapi/ppb_layer_compositor_impl.h @@ -32,7 +32,7 @@ class PPB_LayerCompositor_Impl : public Resource { void SetRect(PP_Resource layer, const struct PP_Rect* rect); void SetDisplay(PP_Resource layer, PP_Bool is_displayed); void MarkAsDirty(PP_Resource layer); - PP_Bool SwapBuffers(struct PP_CompletionCallback callback); + int32_t SwapBuffers(struct PP_CompletionCallback callback); private: DISALLOW_COPY_AND_ASSIGN(PPB_LayerCompositor_Impl); diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc index 6448192..5fd318a 100644 --- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc +++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc @@ -44,37 +44,39 @@ PP_Bool GetConfigs(PP_Instance instance_id, num_of_matching_configs)); } -PP_Resource Create(PP_Instance instance_id, - const PP_VideoConfigElement* decoder_config, - PP_CompletionCallback callback) { +PP_Resource Create(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) return 0; - scoped_refptr<PPB_VideoDecoder_Impl> decoder( - new PPB_VideoDecoder_Impl(instance)); + PPB_VideoDecoder_Impl* decoder = new PPB_VideoDecoder_Impl(instance); + return decoder->GetReference(); +} - if (!decoder->Init( - const_cast<PP_VideoConfigElement*>(decoder_config), callback)) { - return 0; - } +int32_t Initialize(PP_Resource video_decoder, + const PP_VideoConfigElement* decoder_config, + struct PP_CompletionCallback callback) { + scoped_refptr<PPB_VideoDecoder_Impl> decoder( + Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); + if (!decoder) + return PP_ERROR_BADRESOURCE; - return decoder->GetReference(); + return decoder->Initialize(decoder_config, callback); } PP_Bool IsVideoDecoder(PP_Resource resource) { return BoolToPPBool(!!Resource::GetAs<PPB_VideoDecoder_Impl>(resource)); } -PP_Bool Decode(PP_Resource decoder_id, +int32_t Decode(PP_Resource decoder_id, const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, PP_CompletionCallback callback) { scoped_refptr<PPB_VideoDecoder_Impl> decoder( Resource::GetAs<PPB_VideoDecoder_Impl>(decoder_id)); if (!decoder) - return PP_FALSE; + return PP_ERROR_BADRESOURCE; - return BoolToPPBool(decoder->Decode(bitstream_buffer, callback)); + return decoder->Decode(bitstream_buffer, callback); } void AssignGLESBuffers(PP_Resource video_decoder, @@ -108,28 +110,29 @@ void ReusePictureBuffer(PP_Resource video_decoder, int32_t picture_buffer_id) { decoder->ReusePictureBuffer(picture_buffer_id); } -PP_Bool Flush(PP_Resource video_decoder, PP_CompletionCallback callback) { +int32_t Flush(PP_Resource video_decoder, PP_CompletionCallback callback) { scoped_refptr<PPB_VideoDecoder_Impl> decoder( Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); if (!decoder) - return PP_FALSE; + return PP_ERROR_BADRESOURCE; - return BoolToPPBool(decoder->Flush(callback)); + return decoder->Flush(callback); } -PP_Bool Abort(PP_Resource video_decoder, +int32_t Abort(PP_Resource video_decoder, PP_CompletionCallback callback) { scoped_refptr<PPB_VideoDecoder_Impl> decoder( Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); if (!decoder) - return PP_FALSE; + return PP_ERROR_BADRESOURCE; - return BoolToPPBool(decoder->Abort(callback)); + return decoder->Abort(callback); } const PPB_VideoDecoder_Dev ppb_videodecoder = { &GetConfigs, &Create, + &Initialize, &IsVideoDecoder, &Decode, &AssignGLESBuffers, @@ -216,34 +219,41 @@ bool PPB_VideoDecoder_Impl::GetConfigs( return true; } -bool PPB_VideoDecoder_Impl::Init(const PP_VideoConfigElement* decoder_config, - PP_CompletionCallback callback) { +int32_t PPB_VideoDecoder_Impl::Initialize( + const PP_VideoConfigElement* decoder_config, + PP_CompletionCallback callback) { + if (!callback.func) + return PP_ERROR_BADARGUMENT; if (!instance()) - return false; + return PP_ERROR_FAILED; platform_video_decoder_.reset( instance()->delegate()->CreateVideoDecoder(this)); + if (!platform_video_decoder_.get()) + return PP_ERROR_FAILED; + std::vector<uint32> copied; // TODO(vrk): Validate configs before copy. CopyToConfigList(decoder_config, &copied); - platform_video_decoder_->Initialize(copied); - - initialization_callback_ = callback; - - return platform_video_decoder_.get()? true : false; + if (platform_video_decoder_->Initialize(copied)) { + initialization_callback_ = callback; + return PP_OK_COMPLETIONPENDING; + } else { + return PP_ERROR_FAILED; + } } -bool PPB_VideoDecoder_Impl::Decode( +int32_t PPB_VideoDecoder_Impl::Decode( const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, PP_CompletionCallback callback) { if (!platform_video_decoder_.get()) - return false; + return PP_ERROR_BADRESOURCE; ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_Buffer_API> enter(bitstream_buffer->data, true); if (enter.failed()) - return false; + return PP_ERROR_FAILED; PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); media::BitstreamBuffer decode_buffer(bitstream_buffer->id, @@ -254,7 +264,10 @@ bool PPB_VideoDecoder_Impl::Decode( // TODO(vmr): handle simultaneous decodes + callbacks. bitstream_buffer_callback_ = callback; - return platform_video_decoder_->Decode(decode_buffer); + if (platform_video_decoder_->Decode(decode_buffer)) + return PP_OK_COMPLETIONPENDING; + else + return PP_ERROR_FAILED; } void PPB_VideoDecoder_Impl::AssignGLESBuffers( @@ -293,26 +306,32 @@ void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) { platform_video_decoder_->ReusePictureBuffer(picture_buffer_id); } -bool PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { +int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { if (!platform_video_decoder_.get()) - return false; + return PP_ERROR_BADRESOURCE; // Store the callback to be called when Flush() is done. // TODO(vmr): Check for current flush/abort operations. flush_callback_ = callback; - return platform_video_decoder_->Flush(); + if (platform_video_decoder_->Flush()) + return PP_OK_COMPLETIONPENDING; + else + return PP_ERROR_FAILED; } -bool PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) { +int32_t PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) { if (!platform_video_decoder_.get()) - return false; + return PP_ERROR_BADRESOURCE; // Store the callback to be called when Abort() is done. // TODO(vmr): Check for current flush/abort operations. abort_callback_ = callback; - return platform_video_decoder_->Abort(); + if (platform_video_decoder_->Abort()) + return PP_OK_COMPLETIONPENDING; + else + return PP_ERROR_FAILED; } void PPB_VideoDecoder_Impl::ProvidePictureBuffers( diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.h b/webkit/plugins/ppapi/ppb_video_decoder_impl.h index 9e4b176..f67aa83 100644 --- a/webkit/plugins/ppapi/ppb_video_decoder_impl.h +++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.h @@ -46,17 +46,17 @@ class PPB_VideoDecoder_Impl : public Resource, PP_VideoConfigElement* matching_configs, uint32_t matching_configs_size, uint32_t* num_of_matching_configs); - bool Init(const PP_VideoConfigElement* dec_config, - PP_CompletionCallback callback); - bool Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, - PP_CompletionCallback callback); + int32_t Initialize(const PP_VideoConfigElement* dec_config, + PP_CompletionCallback callback); + int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, + PP_CompletionCallback callback); void AssignGLESBuffers(uint32_t no_of_buffers, const PP_GLESBuffer_Dev* buffers); void AssignSysmemBuffers(uint32_t no_of_buffers, const PP_SysmemBuffer_Dev* buffers); void ReusePictureBuffer(int32_t picture_buffer_id); - bool Flush(PP_CompletionCallback callback); - bool Abort(PP_CompletionCallback callback); + int32_t Flush(PP_CompletionCallback callback); + int32_t Abort(PP_CompletionCallback callback); // media::VideoDecodeAccelerator::Client implementation. virtual void ProvidePictureBuffers( |