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/bind.h" | 11 #include "base/bind.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop_proxy.h" | 13 #include "base/message_loop_proxy.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "ipc/ipc_channel_proxy.h" | 17 #include "ipc/ipc_channel_proxy.h" |
18 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
19 #include "ipc/ipc_sync_message.h" | 19 #include "ipc/ipc_sync_message.h" |
20 #include "ppapi/c/pp_errors.h" | 20 #include "ppapi/c/pp_errors.h" |
21 #include "ppapi/c/pp_file_info.h" | 21 #include "ppapi/c/pp_file_info.h" |
22 #include "ppapi/c/private/ppb_flash_file.h" | 22 #include "ppapi/c/private/ppb_flash_file.h" |
23 #include "ppapi/proxy/plugin_dispatcher.h" | 23 #include "ppapi/proxy/plugin_dispatcher.h" |
| 24 #include "ppapi/proxy/plugin_resource_tracker.h" |
24 #include "ppapi/proxy/ppapi_messages.h" | 25 #include "ppapi/proxy/ppapi_messages.h" |
25 #include "ppapi/shared_impl/ppapi_globals.h" | |
26 #include "ppapi/shared_impl/resource.h" | 26 #include "ppapi/shared_impl/resource.h" |
27 #include "ppapi/shared_impl/resource_tracker.h" | |
28 | 27 |
29 namespace ppapi { | 28 namespace ppapi { |
30 namespace proxy { | 29 namespace proxy { |
31 | 30 |
32 namespace { | 31 namespace { |
33 | 32 |
34 // Given an error code and a handle result from a Pepper API call, converts to a | 33 // Given an error code and a handle result from a Pepper API call, converts to a |
35 // PlatformFileForTransit by sharing with the other side, closing the original | 34 // PlatformFileForTransit by sharing with the other side, closing the original |
36 // handle, possibly also updating the error value if an error occurred. | 35 // handle, possibly also updating the error value if an error occurred. |
37 IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit( | 36 IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit( |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 } | 624 } |
626 | 625 |
627 // PPB_Flash_File_FileRef ------------------------------------------------------ | 626 // PPB_Flash_File_FileRef ------------------------------------------------------ |
628 | 627 |
629 namespace { | 628 namespace { |
630 | 629 |
631 int32_t OpenFileRefFile(PP_Resource file_ref_id, | 630 int32_t OpenFileRefFile(PP_Resource file_ref_id, |
632 int32_t mode, | 631 int32_t mode, |
633 PP_FileHandle* file) { | 632 PP_FileHandle* file) { |
634 Resource* file_ref = | 633 Resource* file_ref = |
635 PpapiGlobals::Get()->GetResourceTracker()->GetResource(file_ref_id); | 634 PluginResourceTracker::GetInstance()->GetResource(file_ref_id); |
636 if (!file_ref) | 635 if (!file_ref) |
637 return PP_ERROR_BADRESOURCE; | 636 return PP_ERROR_BADRESOURCE; |
638 | 637 |
639 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(file_ref); | 638 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(file_ref); |
640 if (!dispatcher) | 639 if (!dispatcher) |
641 return PP_ERROR_BADARGUMENT; | 640 return PP_ERROR_BADARGUMENT; |
642 | 641 |
643 int32_t result = PP_ERROR_FAILED; | 642 int32_t result = PP_ERROR_FAILED; |
644 IPC::PlatformFileForTransit transit; | 643 IPC::PlatformFileForTransit transit; |
645 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_OpenFile( | 644 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_OpenFile( |
646 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, | 645 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, |
647 file_ref->host_resource(), mode, &transit, &result)); | 646 file_ref->host_resource(), mode, &transit, &result)); |
648 *file = IPC::PlatformFileForTransitToPlatformFile(transit); | 647 *file = IPC::PlatformFileForTransitToPlatformFile(transit); |
649 return result; | 648 return result; |
650 } | 649 } |
651 | 650 |
652 int32_t QueryFileRefFile(PP_Resource file_ref_id, | 651 int32_t QueryFileRefFile(PP_Resource file_ref_id, |
653 PP_FileInfo* info) { | 652 PP_FileInfo* info) { |
654 Resource* file_ref = | 653 Resource* file_ref = |
655 PpapiGlobals::Get()->GetResourceTracker()->GetResource(file_ref_id); | 654 PluginResourceTracker::GetInstance()->GetResource(file_ref_id); |
656 if (!file_ref) | 655 if (!file_ref) |
657 return PP_ERROR_BADRESOURCE; | 656 return PP_ERROR_BADRESOURCE; |
658 | 657 |
659 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(file_ref); | 658 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(file_ref); |
660 if (!dispatcher) | 659 if (!dispatcher) |
661 return PP_ERROR_BADARGUMENT; | 660 return PP_ERROR_BADARGUMENT; |
662 | 661 |
663 int32_t result = PP_ERROR_FAILED; | 662 int32_t result = PP_ERROR_FAILED; |
664 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_QueryFile( | 663 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_QueryFile( |
665 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, | 664 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( | 731 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( |
733 const HostResource& host_resource, | 732 const HostResource& host_resource, |
734 PP_FileInfo* info, | 733 PP_FileInfo* info, |
735 int32_t* result) { | 734 int32_t* result) { |
736 *result = ppb_flash_file_fileref_impl_->QueryFile( | 735 *result = ppb_flash_file_fileref_impl_->QueryFile( |
737 host_resource.host_resource(), info); | 736 host_resource.host_resource(), info); |
738 } | 737 } |
739 | 738 |
740 } // namespace proxy | 739 } // namespace proxy |
741 } // namespace ppapi | 740 } // namespace ppapi |
OLD | NEW |