Chromium Code Reviews| Index: webkit/plugins/ppapi/ppb_audio_impl.cc |
| diff --git a/webkit/plugins/ppapi/ppb_audio_impl.cc b/webkit/plugins/ppapi/ppb_audio_impl.cc |
| index f13dda9198b1ccc5f711e0abab45b78d6576cf5d..3d65e68eed474286b4198f9686fecee77556ca5c 100644 |
| --- a/webkit/plugins/ppapi/ppb_audio_impl.cc |
| +++ b/webkit/plugins/ppapi/ppb_audio_impl.cc |
| @@ -9,10 +9,13 @@ |
| #include "ppapi/c/ppb_audio.h" |
| #include "ppapi/c/ppb_audio_config.h" |
| #include "ppapi/c/trusted/ppb_audio_trusted.h" |
| +#include "ppapi/shared_impl/resource_tracker.h" |
| +#include "ppapi/shared_impl/tracker_base.h" |
| #include "ppapi/thunk/enter.h" |
| #include "ppapi/thunk/ppb_audio_config_api.h" |
| #include "ppapi/thunk/thunk.h" |
| #include "webkit/plugins/ppapi/common.h" |
| +#include "webkit/plugins/ppapi/resource_helper.h" |
| using ppapi::thunk::EnterResourceNoLock; |
| using ppapi::thunk::PPB_Audio_API; |
| @@ -23,7 +26,7 @@ namespace ppapi { |
| // PPB_AudioConfig ------------------------------------------------------------- |
| -PPB_AudioConfig_Impl::PPB_AudioConfig_Impl(PluginInstance* instance) |
| +PPB_AudioConfig_Impl::PPB_AudioConfig_Impl(PP_Instance instance) |
| : Resource(instance) { |
| } |
| @@ -31,7 +34,7 @@ PPB_AudioConfig_Impl::~PPB_AudioConfig_Impl() { |
| } |
| // static |
| -PP_Resource PPB_AudioConfig_Impl::Create(PluginInstance* instance, |
| +PP_Resource PPB_AudioConfig_Impl::Create(PP_Instance instance, |
| PP_AudioSampleRate sample_rate, |
| uint32_t sample_frame_count) { |
| scoped_refptr<PPB_AudioConfig_Impl> config( |
| @@ -47,9 +50,8 @@ PPB_AudioConfig_API* PPB_AudioConfig_Impl::AsPPB_AudioConfig_API() { |
| // PPB_Audio_Impl -------------------------------------------------------------- |
| -PPB_Audio_Impl::PPB_Audio_Impl(PluginInstance* instance) |
| +PPB_Audio_Impl::PPB_Audio_Impl(PP_Instance instance) |
| : Resource(instance), |
| - config_id_(0), |
| audio_(NULL), |
| create_callback_pending_(false), |
| shared_memory_size_for_create_callback_(0) { |
| @@ -57,9 +59,6 @@ PPB_Audio_Impl::PPB_Audio_Impl(PluginInstance* instance) |
| } |
| PPB_Audio_Impl::~PPB_Audio_Impl() { |
| - if (config_id_) |
| - ResourceTracker::Get()->ReleaseResource(config_id_); |
| - |
| // Calling ShutDown() makes sure StreamCreated cannot be called anymore and |
| // releases the audio data associated with the pointer. Note however, that |
| // until ShutDown returns, StreamCreated may still be called. This will be |
| @@ -79,7 +78,7 @@ PPB_Audio_Impl::~PPB_Audio_Impl() { |
| } |
| // static |
| -PP_Resource PPB_Audio_Impl::Create(PluginInstance* instance, |
| +PP_Resource PPB_Audio_Impl::Create(PP_Instance instance, |
| PP_Resource config_id, |
|
viettrungluu
2011/08/22 23:19:46
I think you should rename s/config_id/config/.
|
| PPB_Audio_Callback audio_callback, |
| void* user_data) { |
| @@ -99,8 +98,7 @@ bool PPB_Audio_Impl::Init(PP_Resource config_id, |
| EnterResourceNoLock<PPB_AudioConfig_API> enter(config_id, true); |
| if (enter.failed()) |
| return false; |
| - config_id_ = config_id; |
| - ResourceTracker::Get()->AddRefResource(config_id); |
| + config_ = config_id; |
| if (!callback) |
| return false; |
| @@ -108,7 +106,7 @@ bool PPB_Audio_Impl::Init(PP_Resource config_id, |
| // When the stream is created, we'll get called back on StreamCreated(). |
| CHECK(!audio_); |
| - audio_ = instance()->delegate()->CreateAudio( |
| + audio_ = ResourceHelper::GetPluginDelegate(this)->CreateAudio( |
| enter.object()->GetSampleRate(), |
| enter.object()->GetSampleFrameCount(), |
| this); |
| @@ -116,9 +114,9 @@ bool PPB_Audio_Impl::Init(PP_Resource config_id, |
| } |
| PP_Resource PPB_Audio_Impl::GetCurrentConfig() { |
| - // AddRef on behalf of caller. |
| - ResourceTracker::Get()->AddRefResource(config_id_); |
| - return config_id_; |
| + // AddRef on behalf of caller, while keeping a ref for ourselves. |
| + ::ppapi::TrackerBase::Get()->GetResourceTracker()->AddRefResource(config_); |
| + return config_; |
| } |
| PP_Bool PPB_Audio_Impl::StartPlayback() { |
| @@ -148,12 +146,11 @@ int32_t PPB_Audio_Impl::OpenTrusted(PP_Resource config_id, |
| EnterResourceNoLock<PPB_AudioConfig_API> enter(config_id, true); |
| if (enter.failed()) |
| return false; |
| - config_id_ = config_id; |
| - ResourceTracker::Get()->AddRefResource(config_id); |
| + config_ = config_id; |
| // When the stream is created, we'll get called back on StreamCreated(). |
| DCHECK(!audio_); |
| - audio_ = instance()->delegate()->CreateAudio( |
| + audio_ = ResourceHelper::GetPluginDelegate(this)->CreateAudio( |
| enter.object()->GetSampleRate(), |
| enter.object()->GetSampleFrameCount(), |
| this); |