summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 02:24:06 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 02:24:06 +0000
commita5e5c7605a54ee3cb16aef3f07015f42429b291f (patch)
tree65ef532237daf697f851fba3a87afd3821291648
parent762c724a9bcf0c3d20d63dd1b6d17e4b9d2b68c0 (diff)
downloadchromium_src-a5e5c7605a54ee3cb16aef3f07015f42429b291f.zip
chromium_src-a5e5c7605a54ee3cb16aef3f07015f42429b291f.tar.gz
chromium_src-a5e5c7605a54ee3cb16aef3f07015f42429b291f.tar.bz2
CDM: Don't create a new plugin Resource when HostResource is sent twice
BUG=165717,166498 Review URL: https://chromiumcodereview.appspot.com/11568024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173626 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ppapi/proxy/ppp_content_decryptor_private_proxy.cc47
1 files changed, 25 insertions, 22 deletions
diff --git a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc
index 9aca5e7..7370849 100644
--- a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc
+++ b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc
@@ -110,6 +110,24 @@ bool InitializePppDecryptorBuffer(PP_Instance instance,
return true;
}
+PP_Resource GetOrAddProxyResource(const PPPDecryptor_Buffer& buffer) {
+ PluginResourceTracker* resource_tracker =
+ PluginGlobals::Get()->plugin_resource_tracker();
+ PP_Resource resource =
+ resource_tracker->PluginResourceForHostResource(buffer.resource);
+ if (resource) {
+ // This buffer is already in the tracker. We don't need to create a plugin-
+ // side entry for it in the tracker; instead, just add a reference and
+ // return.
+ resource_tracker->AddRefResource(resource);
+ return resource;
+ }
+ // This is the first time we've seen this HostResource, so add it to the
+ // tracker.
+ return PPB_Buffer_Proxy::AddProxyResource(buffer.resource, buffer.handle,
+ buffer.size);
+}
+
void GenerateKeyRequest(PP_Instance instance,
PP_Var key_system,
PP_Var type,
@@ -434,10 +452,7 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgDecrypt(
const PPPDecryptor_Buffer& encrypted_buffer,
const std::string& serialized_block_info) {
if (ppp_decryptor_impl_) {
- PP_Resource plugin_resource =
- PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource,
- encrypted_buffer.handle,
- encrypted_buffer.size);
+ PP_Resource plugin_resource = GetOrAddProxyResource(encrypted_buffer);
PP_EncryptedBlockInfo block_info;
if (!DeserializeBlockInfo(serialized_block_info, &block_info))
return;
@@ -459,12 +474,8 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgInitializeAudioDecoder(
if (ppp_decryptor_impl_) {
PP_Resource plugin_resource = 0;
- if (extra_data_buffer.size > 0) {
- plugin_resource =
- PPB_Buffer_Proxy::AddProxyResource(extra_data_buffer.resource,
- extra_data_buffer.handle,
- extra_data_buffer.size);
- }
+ if (extra_data_buffer.size > 0)
+ plugin_resource = GetOrAddProxyResource(extra_data_buffer);
CallWhileUnlocked(
ppp_decryptor_impl_->InitializeAudioDecoder,
@@ -485,12 +496,8 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgInitializeVideoDecoder(
if (ppp_decryptor_impl_) {
PP_Resource plugin_resource = 0;
- if (extra_data_buffer.resource.host_resource() != 0) {
- plugin_resource =
- PPB_Buffer_Proxy::AddProxyResource(extra_data_buffer.resource,
- extra_data_buffer.handle,
- extra_data_buffer.size);
- }
+ if (extra_data_buffer.resource.host_resource() != 0)
+ plugin_resource = GetOrAddProxyResource(extra_data_buffer);
CallWhileUnlocked(
ppp_decryptor_impl_->InitializeVideoDecoder,
@@ -537,12 +544,8 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecode(
return;
PP_Resource plugin_resource = 0;
- if (encrypted_buffer.resource.host_resource() != 0) {
- plugin_resource =
- PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource,
- encrypted_buffer.handle,
- encrypted_buffer.size);
- }
+ if (encrypted_buffer.resource.host_resource() != 0)
+ plugin_resource = GetOrAddProxyResource(encrypted_buffer);
CallWhileUnlocked(
ppp_decryptor_impl_->DecryptAndDecode,