| 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/dev/pp_file_info_dev.h" | |
| 20 #include "ppapi/c/pp_errors.h" | 19 #include "ppapi/c/pp_errors.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.h" |
| 24 #include "ppapi/proxy/ppapi_messages.h" | 24 #include "ppapi/proxy/ppapi_messages.h" |
| 25 | 25 |
| 26 namespace pp { | 26 namespace pp { |
| 27 namespace proxy { | 27 namespace proxy { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 // Called on the I/O thread when the channel is being destroyed and the | 71 // Called on the I/O thread when the channel is being destroyed and the |
| 72 // given message will never be issued a reply. | 72 // given message will never be issued a reply. |
| 73 void OnModuleLocalMessageFailed(int message_id); | 73 void OnModuleLocalMessageFailed(int message_id); |
| 74 | 74 |
| 75 bool Send(PP_Instance instance, IPC::Message* msg); | 75 bool Send(PP_Instance instance, IPC::Message* msg); |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 class Filter : public IPC::ChannelProxy::MessageFilter { | 78 class Filter : public IPC::ChannelProxy::MessageFilter { |
| 79 public: | 79 public: |
| 80 Filter(Dispatcher* dispatcher); | 80 explicit Filter(Dispatcher* dispatcher); |
| 81 ~Filter(); | 81 ~Filter(); |
| 82 | 82 |
| 83 void Send(IPC::Message* msg); | 83 void Send(IPC::Message* msg); |
| 84 | 84 |
| 85 virtual void OnFilterAdded(IPC::Channel* channel); | 85 virtual void OnFilterAdded(IPC::Channel* channel); |
| 86 virtual void OnFilterRemoved(); | 86 virtual void OnFilterRemoved(); |
| 87 virtual bool OnMessageReceived(const IPC::Message& message); | 87 virtual bool OnMessageReceived(const IPC::Message& message); |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 // DO NOT DEREFERENCE! This is used only for tracking. | 90 // DO NOT DEREFERENCE! This is used only for tracking. |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 436 |
| 437 int32_t result = PP_ERROR_FAILED; | 437 int32_t result = PP_ERROR_FAILED; |
| 438 g_module_local_thread_adapter->Send(instance, | 438 g_module_local_thread_adapter->Send(instance, |
| 439 new PpapiHostMsg_PPBFlashFile_ModuleLocal_CreateDir( | 439 new PpapiHostMsg_PPBFlashFile_ModuleLocal_CreateDir( |
| 440 INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL, instance, path, &result)); | 440 INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL, instance, path, &result)); |
| 441 return result; | 441 return result; |
| 442 } | 442 } |
| 443 | 443 |
| 444 int32_t QueryModuleLocalFile(PP_Instance instance, | 444 int32_t QueryModuleLocalFile(PP_Instance instance, |
| 445 const char* path, | 445 const char* path, |
| 446 PP_FileInfo_Dev* info) { | 446 PP_FileInfo* info) { |
| 447 if (!g_module_local_thread_adapter) | 447 if (!g_module_local_thread_adapter) |
| 448 return PP_ERROR_FAILED; | 448 return PP_ERROR_FAILED; |
| 449 | 449 |
| 450 int32_t result = PP_ERROR_FAILED; | 450 int32_t result = PP_ERROR_FAILED; |
| 451 g_module_local_thread_adapter->Send(instance, | 451 g_module_local_thread_adapter->Send(instance, |
| 452 new PpapiHostMsg_PPBFlashFile_ModuleLocal_QueryFile( | 452 new PpapiHostMsg_PPBFlashFile_ModuleLocal_QueryFile( |
| 453 INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL, instance, path, | 453 INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL, instance, path, |
| 454 info, &result)); | 454 info, &result)); |
| 455 return result; | 455 return result; |
| 456 } | 456 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 | 583 |
| 584 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgCreateDir(PP_Instance instance, | 584 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgCreateDir(PP_Instance instance, |
| 585 const std::string& path, | 585 const std::string& path, |
| 586 int32_t* result) { | 586 int32_t* result) { |
| 587 *result = ppb_flash_file_module_local_target()-> | 587 *result = ppb_flash_file_module_local_target()-> |
| 588 CreateDir(instance, path.c_str()); | 588 CreateDir(instance, path.c_str()); |
| 589 } | 589 } |
| 590 | 590 |
| 591 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgQueryFile(PP_Instance instance, | 591 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgQueryFile(PP_Instance instance, |
| 592 const std::string& path, | 592 const std::string& path, |
| 593 PP_FileInfo_Dev* info, | 593 PP_FileInfo* info, |
| 594 int32_t* result) { | 594 int32_t* result) { |
| 595 *result = ppb_flash_file_module_local_target()-> | 595 *result = ppb_flash_file_module_local_target()-> |
| 596 QueryFile(instance, path.c_str(), info); | 596 QueryFile(instance, path.c_str(), info); |
| 597 } | 597 } |
| 598 | 598 |
| 599 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgGetDirContents( | 599 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgGetDirContents( |
| 600 PP_Instance instance, | 600 PP_Instance instance, |
| 601 const std::string& path, | 601 const std::string& path, |
| 602 std::vector<pp::proxy::SerializedDirEntry>* entries, | 602 std::vector<pp::proxy::SerializedDirEntry>* entries, |
| 603 int32_t* result) { | 603 int32_t* result) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 int32_t result = PP_ERROR_FAILED; | 636 int32_t result = PP_ERROR_FAILED; |
| 637 IPC::PlatformFileForTransit transit; | 637 IPC::PlatformFileForTransit transit; |
| 638 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_OpenFile( | 638 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_OpenFile( |
| 639 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, | 639 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, |
| 640 file_ref->host_resource(), mode, &transit, &result)); | 640 file_ref->host_resource(), mode, &transit, &result)); |
| 641 *file = IPC::PlatformFileForTransitToPlatformFile(transit); | 641 *file = IPC::PlatformFileForTransitToPlatformFile(transit); |
| 642 return result; | 642 return result; |
| 643 } | 643 } |
| 644 | 644 |
| 645 int32_t QueryFileRefFile(PP_Resource file_ref_id, | 645 int32_t QueryFileRefFile(PP_Resource file_ref_id, |
| 646 PP_FileInfo_Dev* info) { | 646 PP_FileInfo* info) { |
| 647 PluginResource* file_ref = | 647 PluginResource* file_ref = |
| 648 PluginResourceTracker::GetInstance()->GetResourceObject(file_ref_id); | 648 PluginResourceTracker::GetInstance()->GetResourceObject(file_ref_id); |
| 649 if (!file_ref) | 649 if (!file_ref) |
| 650 return PP_ERROR_BADRESOURCE; | 650 return PP_ERROR_BADRESOURCE; |
| 651 | 651 |
| 652 PluginDispatcher* dispatcher = | 652 PluginDispatcher* dispatcher = |
| 653 PluginDispatcher::GetForInstance(file_ref->instance()); | 653 PluginDispatcher::GetForInstance(file_ref->instance()); |
| 654 if (!dispatcher) | 654 if (!dispatcher) |
| 655 return PP_ERROR_BADARGUMENT; | 655 return PP_ERROR_BADARGUMENT; |
| 656 | 656 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 int32_t* result) { | 715 int32_t* result) { |
| 716 base::PlatformFile file; | 716 base::PlatformFile file; |
| 717 *result = ppb_flash_file_module_local_target()-> | 717 *result = ppb_flash_file_module_local_target()-> |
| 718 OpenFile(host_resource.host_resource(), mode, &file); | 718 OpenFile(host_resource.host_resource(), mode, &file); |
| 719 *file_handle = PlatformFileToPlatformFileForTransit( | 719 *file_handle = PlatformFileToPlatformFileForTransit( |
| 720 dispatcher(), result, file); | 720 dispatcher(), result, file); |
| 721 } | 721 } |
| 722 | 722 |
| 723 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( | 723 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( |
| 724 const HostResource& host_resource, | 724 const HostResource& host_resource, |
| 725 PP_FileInfo_Dev* info, | 725 PP_FileInfo* info, |
| 726 int32_t* result) { | 726 int32_t* result) { |
| 727 *result = ppb_flash_file_module_local_target()-> | 727 *result = ppb_flash_file_module_local_target()-> |
| 728 QueryFile(host_resource.host_resource(), info); | 728 QueryFile(host_resource.host_resource(), info); |
| 729 } | 729 } |
| 730 | 730 |
| 731 } // namespace proxy | 731 } // namespace proxy |
| 732 } // namespace pp | 732 } // namespace pp |
| OLD | NEW |