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

Unified Diff: ppapi/proxy/ppb_video_decoder_proxy.cc

Issue 7629017: Add a unified resource tracker shared between the proxy and the impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Assertion fixed Created 9 years, 4 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: ppapi/proxy/ppb_video_decoder_proxy.cc
diff --git a/ppapi/proxy/ppb_video_decoder_proxy.cc b/ppapi/proxy/ppb_video_decoder_proxy.cc
index 85f6bff02acafda29f3b4387b87fe8aebc94aaf8..3aa95861d6e5c5a8b751bf9d60a4091952a5557f 100644
--- a/ppapi/proxy/ppb_video_decoder_proxy.cc
+++ b/ppapi/proxy/ppb_video_decoder_proxy.cc
@@ -16,6 +16,7 @@
#include "ppapi/thunk/thunk.h"
using ppapi::HostResource;
+using ppapi::Resource;
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_Buffer_API;
using ppapi::thunk::PPB_Context3D_API;
@@ -24,16 +25,18 @@ using ppapi::thunk::PPB_VideoDecoder_API;
namespace pp {
namespace proxy {
-class VideoDecoder : public PluginResource,
+class VideoDecoder : public Resource,
public ::ppapi::VideoDecoderImpl {
public:
+ // You must call Init() before using this class.
+ explicit VideoDecoder(const HostResource& resource);
virtual ~VideoDecoder();
static VideoDecoder* Create(const HostResource& resource,
PP_Resource context3d_id,
const PP_VideoConfigElement* config);
- // ResourceObjectBase overrides.
+ // Resource overrides.
virtual PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE;
// PPB_VideoDecoder_API implementation.
@@ -46,13 +49,10 @@ class VideoDecoder : public PluginResource,
virtual int32_t Reset(PP_CompletionCallback callback) OVERRIDE;
virtual void Destroy() OVERRIDE;
- protected:
- virtual void AddRefResource(PP_Resource resource) OVERRIDE;
- virtual void UnrefResource(PP_Resource resource) OVERRIDE;
-
private:
friend class PPB_VideoDecoder_Proxy;
- explicit VideoDecoder(const HostResource& resource);
+
+ PluginDispatcher* GetDispatcher() const;
// Run the callbacks that were passed into the plugin interface.
void FlushACK(int32_t result);
@@ -62,24 +62,7 @@ class VideoDecoder : public PluginResource,
DISALLOW_COPY_AND_ASSIGN(VideoDecoder);
};
-VideoDecoder::VideoDecoder(const HostResource& decoder)
- : PluginResource(decoder) {
-}
-
-VideoDecoder* VideoDecoder::Create(const HostResource& resource,
- PP_Resource context3d_id,
- const PP_VideoConfigElement* config) {
- if (!context3d_id)
- return NULL;
-
- EnterResourceNoLock<PPB_Context3D_API> enter_context(context3d_id, true);
- if (enter_context.failed())
- return NULL;
-
- scoped_refptr<VideoDecoder> decoder(new VideoDecoder(resource));
- if (decoder->Init(context3d_id, enter_context.object(), config))
- return decoder.release();
- return NULL;
+VideoDecoder::VideoDecoder(const HostResource& decoder) : Resource(decoder) {
}
VideoDecoder::~VideoDecoder() {
@@ -155,12 +138,8 @@ void VideoDecoder::Destroy() {
::ppapi::VideoDecoderImpl::Destroy();
}
-void VideoDecoder::AddRefResource(PP_Resource resource) {
- PluginResourceTracker::GetInstance()->AddRefResource(resource);
-}
-
-void VideoDecoder::UnrefResource(PP_Resource resource) {
- PluginResourceTracker::GetInstance()->ReleaseResource(resource);
+PluginDispatcher* VideoDecoder::GetDispatcher() const {
+ return PluginDispatcher::GetForResource(this);
}
void VideoDecoder::ResetACK(int32_t result) {
@@ -257,8 +236,10 @@ PP_Resource PPB_VideoDecoder_Proxy::CreateProxyResource(
if (result.is_null())
return 0;
- return PluginResourceTracker::GetInstance()->AddResource(
- VideoDecoder::Create(result, context3d_id, config));
+ scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result));
dmichael (off chromium) 2011/08/17 19:02:54 Why are you using scoped_refptr here but not elsew
+ if (!decoder->Init(context3d_id, enter_context.object(), config))
+ return 0;
+ return decoder->GetReference();
}
void PPB_VideoDecoder_Proxy::OnMsgCreate(

Powered by Google App Engine
This is Rietveld 408576698