diff options
author | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-14 19:07:51 +0000 |
---|---|---|
committer | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-14 19:07:51 +0000 |
commit | 63877e435c810bb0f4f290f9b875b7c79bdeeccc (patch) | |
tree | 78a676ae761888633b39ffa9ba824e589c14f582 /ppapi | |
parent | fed02971a4d1f2882c9b91c5ec85d6182d8b0472 (diff) | |
download | chromium_src-63877e435c810bb0f4f290f9b875b7c79bdeeccc.zip chromium_src-63877e435c810bb0f4f290f9b875b7c79bdeeccc.tar.gz chromium_src-63877e435c810bb0f4f290f9b875b7c79bdeeccc.tar.bz2 |
Fix the ref-count issue related to the url_loader parameter of PPP_Instance.HandleDocumentLoad().
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/6835002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81618 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/proxy/ppp_instance_proxy.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ppapi/proxy/ppp_instance_proxy.cc b/ppapi/proxy/ppp_instance_proxy.cc index 393f031..98e2615 100644 --- a/ppapi/proxy/ppp_instance_proxy.cc +++ b/ppapi/proxy/ppp_instance_proxy.cc @@ -7,9 +7,11 @@ #include <algorithm> #include "ppapi/c/pp_var.h" +#include "ppapi/c/ppb_core.h" #include "ppapi/c/ppp_instance.h" #include "ppapi/proxy/host_dispatcher.h" #include "ppapi/proxy/plugin_dispatcher.h" +#include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/ppb_url_loader_proxy.h" @@ -81,6 +83,20 @@ PP_Bool HandleDocumentLoad(PP_Instance instance, dispatcher->GetOrCreatePPBInterfaceProxy(INTERFACE_ID_PPB_URL_LOADER)); url_loader_proxy->PrepareURLLoaderForSendingToPlugin(url_loader); + // PluginResourceTracker in the plugin process assumes that resources that it + // tracks have been addrefed on behalf of the plugin at the renderer side. So + // we explicitly do it for |url_loader| here. + // + // Please also see comments in PPP_Instance_Proxy::OnMsgHandleDocumentLoad() + // about releasing of this extra reference. + const PPB_Core* core = reinterpret_cast<const PPB_Core*>( + dispatcher->GetLocalInterface(PPB_CORE_INTERFACE)); + if (!core) { + NOTREACHED(); + return PP_FALSE; + } + core->AddRefResource(url_loader); + HostResource serialized_loader; serialized_loader.SetHostResource(instance, url_loader); dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( @@ -224,6 +240,14 @@ void PPP_Instance_Proxy::OnMsgHandleDocumentLoad(PP_Instance instance, PPB_URLLoader_Proxy::TrackPluginResource(url_loader); *result = ppp_instance_target()->HandleDocumentLoad( instance, plugin_loader); + + // This balances the one reference that TrackPluginResource() initialized it + // with. The plugin will normally take an additional reference which will keep + // the resource alive in the plugin (and the one reference in the renderer + // representing all plugin references). + // Once all references at the plugin side are released, the renderer side will + // be notified and release the reference added in HandleDocumentLoad() above. + PluginResourceTracker::GetInstance()->ReleaseResource(plugin_loader); } void PPP_Instance_Proxy::OnMsgGetInstanceObject( |