OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ppb_flash_file_proxy.h" | 5 #include "ppapi/proxy/ppb_flash_file_proxy.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "ipc/ipc_channel_proxy.h" | 16 #include "ipc/ipc_channel_proxy.h" |
17 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
18 #include "ipc/ipc_sync_message.h" | 18 #include "ipc/ipc_sync_message.h" |
19 #include "ppapi/c/pp_errors.h" | 19 #include "ppapi/c/pp_errors.h" |
20 #include "ppapi/c/pp_file_info.h" | 20 #include "ppapi/c/pp_file_info.h" |
21 #include "ppapi/c/private/ppb_flash_file.h" | 21 #include "ppapi/c/private/ppb_flash_file.h" |
22 #include "ppapi/proxy/plugin_dispatcher.h" | 22 #include "ppapi/proxy/plugin_dispatcher.h" |
23 #include "ppapi/proxy/plugin_resource.h" | 23 #include "ppapi/proxy/plugin_resource_tracker.h" |
24 #include "ppapi/proxy/ppapi_messages.h" | 24 #include "ppapi/proxy/ppapi_messages.h" |
| 25 #include "ppapi/shared_impl/resource.h" |
25 | 26 |
26 using ppapi::HostResource; | 27 using ppapi::HostResource; |
| 28 using ppapi::Resource; |
27 | 29 |
28 namespace pp { | 30 namespace pp { |
29 namespace proxy { | 31 namespace proxy { |
30 | 32 |
31 namespace { | 33 namespace { |
32 | 34 |
33 // Given an error code and a handle result from a Pepper API call, converts to a | 35 // Given an error code and a handle result from a Pepper API call, converts to a |
34 // PlatformFileForTransit by sharing with the other side, closing the original | 36 // PlatformFileForTransit by sharing with the other side, closing the original |
35 // handle, possibly also updating the error value if an error occurred. | 37 // handle, possibly also updating the error value if an error occurred. |
36 IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit( | 38 IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit( |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 ppb_flash_file_module_local_target()->FreeDirContents(instance, contents); | 620 ppb_flash_file_module_local_target()->FreeDirContents(instance, contents); |
619 } | 621 } |
620 | 622 |
621 // PPB_Flash_File_FileRef ------------------------------------------------------ | 623 // PPB_Flash_File_FileRef ------------------------------------------------------ |
622 | 624 |
623 namespace { | 625 namespace { |
624 | 626 |
625 int32_t OpenFileRefFile(PP_Resource file_ref_id, | 627 int32_t OpenFileRefFile(PP_Resource file_ref_id, |
626 int32_t mode, | 628 int32_t mode, |
627 PP_FileHandle* file) { | 629 PP_FileHandle* file) { |
628 PluginResource* file_ref = | 630 Resource* file_ref = |
629 PluginResourceTracker::GetInstance()->GetResourceObject(file_ref_id); | 631 PluginResourceTracker::GetInstance()->GetResource(file_ref_id); |
630 if (!file_ref) | 632 if (!file_ref) |
631 return PP_ERROR_BADRESOURCE; | 633 return PP_ERROR_BADRESOURCE; |
632 | 634 |
633 PluginDispatcher* dispatcher = | 635 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(file_ref); |
634 PluginDispatcher::GetForInstance(file_ref->instance()); | |
635 if (!dispatcher) | 636 if (!dispatcher) |
636 return PP_ERROR_BADARGUMENT; | 637 return PP_ERROR_BADARGUMENT; |
637 | 638 |
638 int32_t result = PP_ERROR_FAILED; | 639 int32_t result = PP_ERROR_FAILED; |
639 IPC::PlatformFileForTransit transit; | 640 IPC::PlatformFileForTransit transit; |
640 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_OpenFile( | 641 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_OpenFile( |
641 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, | 642 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, |
642 file_ref->host_resource(), mode, &transit, &result)); | 643 file_ref->host_resource(), mode, &transit, &result)); |
643 *file = IPC::PlatformFileForTransitToPlatformFile(transit); | 644 *file = IPC::PlatformFileForTransitToPlatformFile(transit); |
644 return result; | 645 return result; |
645 } | 646 } |
646 | 647 |
647 int32_t QueryFileRefFile(PP_Resource file_ref_id, | 648 int32_t QueryFileRefFile(PP_Resource file_ref_id, |
648 PP_FileInfo* info) { | 649 PP_FileInfo* info) { |
649 PluginResource* file_ref = | 650 Resource* file_ref = |
650 PluginResourceTracker::GetInstance()->GetResourceObject(file_ref_id); | 651 PluginResourceTracker::GetInstance()->GetResource(file_ref_id); |
651 if (!file_ref) | 652 if (!file_ref) |
652 return PP_ERROR_BADRESOURCE; | 653 return PP_ERROR_BADRESOURCE; |
653 | 654 |
654 PluginDispatcher* dispatcher = | 655 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(file_ref); |
655 PluginDispatcher::GetForInstance(file_ref->instance()); | |
656 if (!dispatcher) | 656 if (!dispatcher) |
657 return PP_ERROR_BADARGUMENT; | 657 return PP_ERROR_BADARGUMENT; |
658 | 658 |
659 int32_t result = PP_ERROR_FAILED; | 659 int32_t result = PP_ERROR_FAILED; |
660 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_QueryFile( | 660 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_QueryFile( |
661 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, | 661 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, |
662 file_ref->host_resource(), info, &result)); | 662 file_ref->host_resource(), info, &result)); |
663 return result; | 663 return result; |
664 } | 664 } |
665 | 665 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( | 725 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( |
726 const HostResource& host_resource, | 726 const HostResource& host_resource, |
727 PP_FileInfo* info, | 727 PP_FileInfo* info, |
728 int32_t* result) { | 728 int32_t* result) { |
729 *result = ppb_flash_file_module_local_target()-> | 729 *result = ppb_flash_file_module_local_target()-> |
730 QueryFile(host_resource.host_resource(), info); | 730 QueryFile(host_resource.host_resource(), info); |
731 } | 731 } |
732 | 732 |
733 } // namespace proxy | 733 } // namespace proxy |
734 } // namespace pp | 734 } // namespace pp |
OLD | NEW |