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