| Index: ppapi/proxy/plugin_resource_tracker.cc
|
| ===================================================================
|
| --- ppapi/proxy/plugin_resource_tracker.cc (revision 71973)
|
| +++ ppapi/proxy/plugin_resource_tracker.cc (working copy)
|
| @@ -5,6 +5,7 @@
|
| #include "ppapi/proxy/plugin_resource_tracker.h"
|
|
|
| #include "base/logging.h"
|
| +#include "base/singleton.h"
|
| #include "ppapi/proxy/plugin_dispatcher.h"
|
| #include "ppapi/proxy/ppapi_messages.h"
|
| #include "ppapi/proxy/plugin_resource.h"
|
| @@ -38,13 +39,17 @@
|
| return *this;
|
| }
|
|
|
| -PluginResourceTracker::PluginResourceTracker(PluginDispatcher* dispatcher)
|
| - : dispatcher_(dispatcher) {
|
| +PluginResourceTracker::PluginResourceTracker() {
|
| }
|
|
|
| PluginResourceTracker::~PluginResourceTracker() {
|
| }
|
|
|
| +// static
|
| +PluginResourceTracker* PluginResourceTracker::GetInstance() {
|
| + return Singleton<PluginResourceTracker>::get();
|
| +}
|
| +
|
| PluginResource* PluginResourceTracker::GetResourceObject(
|
| PP_Resource pp_resource) {
|
| ResourceMap::iterator found = resource_map_.find(pp_resource);
|
| @@ -81,8 +86,8 @@
|
| // in the plugin for the additional ref, and then a Release in the renderer
|
| // because the code in the renderer addrefed on behalf of the caller.
|
| found->second.ref_count++;
|
| - dispatcher_->Send(new PpapiHostMsg_PPBCore_ReleaseResource(
|
| - INTERFACE_ID_PPB_CORE, resource));
|
| +
|
| + SendReleaseResourceToHost(resource, found->second.resource.get());
|
| return true;
|
| }
|
|
|
| @@ -94,13 +99,24 @@
|
| return;
|
| found->second.ref_count--;
|
| if (found->second.ref_count == 0) {
|
| - if (notify_browser_on_release) {
|
| - dispatcher_->Send(new PpapiHostMsg_PPBCore_ReleaseResource(
|
| - INTERFACE_ID_PPB_CORE, resource));
|
| - }
|
| + if (notify_browser_on_release)
|
| + SendReleaseResourceToHost(resource, found->second.resource.get());
|
| resource_map_.erase(found);
|
| }
|
| }
|
|
|
| +void PluginResourceTracker::SendReleaseResourceToHost(
|
| + PP_Resource resource_id,
|
| + PluginResource* resource) {
|
| + PluginDispatcher* dispatcher =
|
| + PluginDispatcher::GetForInstance(resource->instance());
|
| + if (dispatcher) {
|
| + dispatcher->Send(new PpapiHostMsg_PPBCore_ReleaseResource(
|
| + INTERFACE_ID_PPB_CORE, resource_id));
|
| + } else {
|
| + NOTREACHED();
|
| + }
|
| +}
|
| +
|
| } // namespace proxy
|
| } // namespace pp
|
|
|