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" |
11 #include "ppapi/proxy/host_dispatcher.h" | 11 #include "ppapi/proxy/host_dispatcher.h" |
12 #include "ppapi/proxy/plugin_globals.h" | 12 #include "ppapi/proxy/plugin_globals.h" |
13 #include "ppapi/proxy/plugin_resource_tracker.h" | 13 #include "ppapi/proxy/plugin_resource_tracker.h" |
14 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
15 #include "ppapi/proxy/ppb_buffer_proxy.h" | 15 #include "ppapi/proxy/ppb_buffer_proxy.h" |
16 #include "ppapi/proxy/serialized_var.h" | 16 #include "ppapi/proxy/serialized_var.h" |
17 #include "ppapi/shared_impl/scoped_pp_resource.h" | 17 #include "ppapi/shared_impl/scoped_pp_resource.h" |
18 #include "ppapi/shared_impl/var_tracker.h" | 18 #include "ppapi/shared_impl/var_tracker.h" |
19 #include "ppapi/thunk/enter.h" | 19 #include "ppapi/thunk/enter.h" |
20 #include "ppapi/thunk/ppb_buffer_api.h" | 20 #include "ppapi/thunk/ppb_buffer_api.h" |
21 #include "ppapi/thunk/ppb_buffer_trusted_api.h" | 21 #include "ppapi/thunk/ppb_buffer_trusted_api.h" |
22 #include "ppapi/thunk/ppb_instance_api.h" | 22 #include "ppapi/thunk/ppb_instance_api.h" |
23 #include "ppapi/thunk/thunk.h" | 23 #include "ppapi/thunk/thunk.h" |
24 | 24 |
25 using ppapi::thunk::EnterResourceNoLock; | 25 using ppapi::thunk::EnterResourceNoLock; |
26 using ppapi::thunk::PPB_Buffer_API; | 26 using ppapi::thunk::PPB_Buffer_API; |
27 using ppapi::thunk::PPB_BufferTrusted_API; | |
28 using ppapi::thunk::PPB_Instance_API; | 27 using ppapi::thunk::PPB_Instance_API; |
29 | 28 |
30 namespace ppapi { | 29 namespace ppapi { |
31 namespace proxy { | 30 namespace proxy { |
32 | 31 |
33 namespace { | 32 namespace { |
34 | 33 |
35 PP_Bool DescribeHostBufferResource(PP_Resource resource, uint32_t* size) { | 34 PP_Bool DescribeHostBufferResource(PP_Resource resource, uint32_t* size) { |
36 EnterResourceNoLock<PPB_Buffer_API> enter(resource, true); | 35 EnterResourceNoLock<PPB_Buffer_API> enter(resource, true); |
37 if (enter.failed()) | 36 if (enter.failed()) |
38 return PP_FALSE; | 37 return PP_FALSE; |
39 return enter.object()->Describe(size); | 38 return enter.object()->Describe(size); |
40 } | 39 } |
41 | 40 |
42 // TODO(dmichael): Refactor so this handle sharing code is in one place. | 41 // TODO(dmichael): Refactor so this handle sharing code is in one place. |
43 PP_Bool ShareHostBufferResourceToPlugin( | 42 PP_Bool ShareHostBufferResourceToPlugin( |
44 HostDispatcher* dispatcher, | 43 HostDispatcher* dispatcher, |
45 PP_Resource resource, | 44 PP_Resource resource, |
46 base::SharedMemoryHandle* shared_mem_handle) { | 45 base::SharedMemoryHandle* shared_mem_handle) { |
47 if (!dispatcher || resource == 0 || !shared_mem_handle) | 46 if (!dispatcher || resource == 0 || !shared_mem_handle) |
48 return PP_FALSE; | 47 return PP_FALSE; |
49 EnterResourceNoLock<PPB_BufferTrusted_API> enter(resource, true); | 48 EnterResourceNoLock<PPB_Buffer_API> enter(resource, true); |
50 if (enter.failed()) | 49 if (enter.failed()) |
51 return PP_FALSE; | 50 return PP_FALSE; |
52 int handle; | 51 int handle; |
53 int32_t result = enter.object()->GetSharedMemory(&handle); | 52 int32_t result = enter.object()->GetSharedMemory(&handle); |
54 if (result != PP_OK) | 53 if (result != PP_OK) |
55 return PP_FALSE; | 54 return PP_FALSE; |
56 base::PlatformFile platform_file = | 55 base::PlatformFile platform_file = |
57 #if defined(OS_WIN) | 56 #if defined(OS_WIN) |
58 reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle)); | 57 reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle)); |
59 #elif defined(OS_POSIX) | 58 #elif defined(OS_POSIX) |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 ppp_decryptor_impl_->DecryptAndDecode, | 573 ppp_decryptor_impl_->DecryptAndDecode, |
575 instance, | 574 instance, |
576 decoder_type, | 575 decoder_type, |
577 plugin_resource.get(), | 576 plugin_resource.get(), |
578 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); | 577 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); |
579 } | 578 } |
580 } | 579 } |
581 | 580 |
582 } // namespace proxy | 581 } // namespace proxy |
583 } // namespace ppapi | 582 } // namespace ppapi |
OLD | NEW |