diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-21 00:26:43 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-21 00:26:43 +0000 |
commit | 4614f1974881ecfd0a0118683bac628c6128c2a9 (patch) | |
tree | c69836459560dd8003f7e18ca554f2e1d7f79b4d /ppapi/proxy/plugin_resource_tracker.cc | |
parent | b8e6654fb91108033580f510e2d411093936fc2f (diff) | |
download | chromium_src-4614f1974881ecfd0a0118683bac628c6128c2a9.zip chromium_src-4614f1974881ecfd0a0118683bac628c6128c2a9.tar.gz chromium_src-4614f1974881ecfd0a0118683bac628c6128c2a9.tar.bz2 |
First pass at making the proxy handle multiple renderers. This associates the
instance with resources and has most callers retrieve the dispatcher
according to the appropriate instance. This isn't hooked up to anything yet.
This changes some PPB_Flash interface methods to use PP_Bool.
The most challenging part of the change is in the plugin_var_tracker which
now needs to track which dispatcher each var object came from, and remap var
IDs since each renderer will be generating var IDs in its own space, which
will likely overlap. A similar system will need to be done for resources
which is not implemented yet.
I added some null checks in audio_impl because audio_ can be NULL in some
cases when using the trusted API. I discovered this when testing NaCl for
this patch.
Review URL: http://codereview.chromium.org/6282007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/plugin_resource_tracker.cc')
-rw-r--r-- | ppapi/proxy/plugin_resource_tracker.cc | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/ppapi/proxy/plugin_resource_tracker.cc b/ppapi/proxy/plugin_resource_tracker.cc index 84a0054..f81a5f3 100644 --- a/ppapi/proxy/plugin_resource_tracker.cc +++ b/ppapi/proxy/plugin_resource_tracker.cc @@ -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 @@ PluginResourceTracker::ResourceInfo::operator=( 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 @@ bool PluginResourceTracker::PreparePreviouslyTrackedResource( // 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 @@ void PluginResourceTracker::ReleasePluginResourceRef( 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 |