OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/proxy/ppp_content_decryptor_private_proxy.h" | 5 #include "ppapi/proxy/ppp_content_decryptor_private_proxy.h" |
6 | 6 |
7 #include "base/platform_file.h" | 7 #include "base/platform_file.h" |
8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
9 #include "ppapi/c/ppb_core.h" | 9 #include "ppapi/c/ppb_core.h" |
10 #include "ppapi/proxy/content_decryptor_private_serializer.h" | 10 #include "ppapi/proxy/content_decryptor_private_serializer.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 // SerializedVarReceiveInput will decrement the reference count, but we want | 68 // SerializedVarReceiveInput will decrement the reference count, but we want |
69 // to give the recipient a reference. This utility function takes care of that | 69 // to give the recipient a reference. This utility function takes care of that |
70 // work for the message handlers defined below. | 70 // work for the message handlers defined below. |
71 PP_Var ExtractReceivedVarAndAddRef(Dispatcher* dispatcher, | 71 PP_Var ExtractReceivedVarAndAddRef(Dispatcher* dispatcher, |
72 SerializedVarReceiveInput* serialized_var) { | 72 SerializedVarReceiveInput* serialized_var) { |
73 PP_Var var = serialized_var->Get(dispatcher); | 73 PP_Var var = serialized_var->Get(dispatcher); |
74 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var); | 74 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var); |
75 return var; | 75 return var; |
76 } | 76 } |
77 | 77 |
78 // Increments the reference count on |resource| to ensure that it remains valid | |
79 // until the plugin receives the resource within the asynchronous message sent | |
80 // from the proxy. The plugin side takes ownership of that reference. Returns | |
81 // PP_TRUE when the reference is successfully added, PP_FALSE otherwise. | |
82 PP_Bool AddRefResourceForPlugin(HostDispatcher* dispatcher, | |
83 PP_Resource resource) { | |
84 const PPB_Core* core = static_cast<const PPB_Core*>( | |
85 dispatcher->local_get_interface()(PPB_CORE_INTERFACE)); | |
86 if (!core) { | |
87 NOTREACHED(); | |
88 return PP_FALSE; | |
89 } | |
90 core->AddRefResource(resource); | |
91 return PP_TRUE; | |
92 } | |
dmichael (off chromium)
2012/12/13 19:20:35
I was confused when reading the CL... I think thi
| |
93 | |
94 bool InitializePppDecryptorBuffer(PP_Instance instance, | 78 bool InitializePppDecryptorBuffer(PP_Instance instance, |
95 HostDispatcher* dispatcher, | 79 HostDispatcher* dispatcher, |
96 PP_Resource resource, | 80 PP_Resource resource, |
97 PPPDecryptor_Buffer* buffer) { | 81 PPPDecryptor_Buffer* buffer) { |
98 if (!buffer) { | 82 if (!buffer) { |
99 NOTREACHED(); | 83 NOTREACHED(); |
100 return false; | 84 return false; |
101 } | 85 } |
102 | 86 |
103 if (resource == 0) { | 87 if (resource == 0) { |
104 buffer->resource = HostResource(); | 88 buffer->resource = HostResource(); |
105 buffer->handle = base::SharedMemoryHandle(); | 89 buffer->handle = base::SharedMemoryHandle(); |
106 buffer->size = 0; | 90 buffer->size = 0; |
107 return true; | 91 return true; |
108 } | 92 } |
109 | 93 |
110 if (!AddRefResourceForPlugin(dispatcher, resource)) | |
111 return false; | |
112 | |
113 HostResource host_resource; | 94 HostResource host_resource; |
114 host_resource.SetHostResource(instance, resource); | 95 host_resource.SetHostResource(instance, resource); |
115 | 96 |
116 uint32_t size = 0; | 97 uint32_t size = 0; |
117 if (DescribeHostBufferResource(resource, &size) == PP_FALSE) | 98 if (DescribeHostBufferResource(resource, &size) == PP_FALSE) |
118 return false; | 99 return false; |
119 | 100 |
120 base::SharedMemoryHandle handle; | 101 base::SharedMemoryHandle handle; |
121 if (ShareHostBufferResourceToPlugin(dispatcher, | 102 if (ShareHostBufferResourceToPlugin(dispatcher, |
122 resource, | 103 resource, |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 ppp_decryptor_impl_->DecryptAndDecode, | 548 ppp_decryptor_impl_->DecryptAndDecode, |
568 instance, | 549 instance, |
569 decoder_type, | 550 decoder_type, |
570 plugin_resource, | 551 plugin_resource, |
571 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); | 552 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); |
572 } | 553 } |
573 } | 554 } |
574 | 555 |
575 } // namespace proxy | 556 } // namespace proxy |
576 } // namespace ppapi | 557 } // namespace ppapi |
OLD | NEW |