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/ppb_flash_proxy.h" | 5 #include "ppapi/proxy/ppb_flash_proxy.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "ipc/ipc_channel_proxy.h" | 15 #include "ipc/ipc_channel_proxy.h" |
16 #include "ppapi/c/dev/ppb_font_dev.h" | 16 #include "ppapi/c/dev/ppb_font_dev.h" |
17 #include "ppapi/c/dev/ppb_var_deprecated.h" | 17 #include "ppapi/c/dev/ppb_var_deprecated.h" |
18 #include "ppapi/c/pp_errors.h" | 18 #include "ppapi/c/pp_errors.h" |
19 #include "ppapi/c/pp_resource.h" | 19 #include "ppapi/c/pp_resource.h" |
20 #include "ppapi/c/private/ppb_flash.h" | 20 #include "ppapi/c/private/ppb_flash.h" |
21 #include "ppapi/c/private/ppb_flash_print.h" | 21 #include "ppapi/c/private/ppb_flash_print.h" |
22 #include "ppapi/proxy/host_dispatcher.h" | 22 #include "ppapi/proxy/host_dispatcher.h" |
23 #include "ppapi/proxy/pepper_file_messages.h" | |
23 #include "ppapi/proxy/plugin_dispatcher.h" | 24 #include "ppapi/proxy/plugin_dispatcher.h" |
24 #include "ppapi/proxy/plugin_globals.h" | 25 #include "ppapi/proxy/plugin_globals.h" |
25 #include "ppapi/proxy/plugin_proxy_delegate.h" | 26 #include "ppapi/proxy/plugin_proxy_delegate.h" |
26 #include "ppapi/proxy/ppapi_messages.h" | 27 #include "ppapi/proxy/ppapi_messages.h" |
27 #include "ppapi/proxy/proxy_module.h" | 28 #include "ppapi/proxy/proxy_module.h" |
28 #include "ppapi/proxy/serialized_var.h" | 29 #include "ppapi/proxy/serialized_var.h" |
30 #include "ppapi/shared_impl/dir_contents.h" | |
31 #include "ppapi/shared_impl/file_type_conversion.h" | |
29 #include "ppapi/shared_impl/ppapi_globals.h" | 32 #include "ppapi/shared_impl/ppapi_globals.h" |
30 #include "ppapi/shared_impl/proxy_lock.h" | 33 #include "ppapi/shared_impl/proxy_lock.h" |
31 #include "ppapi/shared_impl/resource.h" | 34 #include "ppapi/shared_impl/resource.h" |
32 #include "ppapi/shared_impl/resource_tracker.h" | 35 #include "ppapi/shared_impl/resource_tracker.h" |
33 #include "ppapi/shared_impl/scoped_pp_resource.h" | 36 #include "ppapi/shared_impl/scoped_pp_resource.h" |
34 #include "ppapi/shared_impl/time_conversion.h" | 37 #include "ppapi/shared_impl/time_conversion.h" |
35 #include "ppapi/shared_impl/var.h" | 38 #include "ppapi/shared_impl/var.h" |
36 #include "ppapi/thunk/enter.h" | 39 #include "ppapi/thunk/enter.h" |
37 #include "ppapi/thunk/ppb_instance_api.h" | 40 #include "ppapi/thunk/ppb_instance_api.h" |
38 #include "ppapi/thunk/ppb_url_request_info_api.h" | 41 #include "ppapi/thunk/ppb_url_request_info_api.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, | 423 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, |
421 OnHostMsgFlashSetFullscreen) | 424 OnHostMsgFlashSetFullscreen) |
422 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, | 425 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, |
423 OnHostMsgFlashGetScreenSize) | 426 OnHostMsgFlashGetScreenSize) |
424 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsClipboardFormatAvailable, | 427 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsClipboardFormatAvailable, |
425 OnHostMsgIsClipboardFormatAvailable) | 428 OnHostMsgIsClipboardFormatAvailable) |
426 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_ReadClipboardData, | 429 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_ReadClipboardData, |
427 OnHostMsgReadClipboardData) | 430 OnHostMsgReadClipboardData) |
428 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_WriteClipboardData, | 431 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_WriteClipboardData, |
429 OnHostMsgWriteClipboardData) | 432 OnHostMsgWriteClipboardData) |
430 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFile, | |
431 OnHostMsgOpenFile) | |
432 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_RenameFile, | |
433 OnHostMsgRenameFile) | |
434 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DeleteFileOrDir, | |
435 OnHostMsgDeleteFileOrDir) | |
436 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_CreateDir, | |
437 OnHostMsgCreateDir) | |
438 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFile, | |
439 OnHostMsgQueryFile) | |
440 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetDirContents, | |
441 OnHostMsgGetDirContents) | |
442 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef, | 433 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef, |
443 OnHostMsgOpenFileRef) | 434 OnHostMsgOpenFileRef) |
444 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFileRef, | 435 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFileRef, |
445 OnHostMsgQueryFileRef) | 436 OnHostMsgQueryFileRef) |
446 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetDeviceID, | 437 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetDeviceID, |
447 OnHostMsgGetDeviceID) | 438 OnHostMsgGetDeviceID) |
448 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting, | 439 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting, |
449 OnHostMsgInvokePrinting) | 440 OnHostMsgInvokePrinting) |
450 IPC_MESSAGE_UNHANDLED(handled = false) | 441 IPC_MESSAGE_UNHANDLED(handled = false) |
451 IPC_END_MESSAGE_MAP() | 442 IPC_END_MESSAGE_MAP() |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
662 instance, | 653 instance, |
663 static_cast<int>(clipboard_type), | 654 static_cast<int>(clipboard_type), |
664 formats_vector, | 655 formats_vector, |
665 data_items_vector)); | 656 data_items_vector)); |
666 // Assume success, since it allows us to avoid a sync IPC. | 657 // Assume success, since it allows us to avoid a sync IPC. |
667 return PP_OK; | 658 return PP_OK; |
668 } | 659 } |
669 | 660 |
670 bool PPB_Flash_Proxy::CreateThreadAdapterForInstance(PP_Instance instance) { | 661 bool PPB_Flash_Proxy::CreateThreadAdapterForInstance(PP_Instance instance) { |
671 if (!g_module_local_thread_adapter) { | 662 if (!g_module_local_thread_adapter) { |
672 g_module_local_thread_adapter = new ModuleLocalThreadAdapter(); | 663 g_module_local_thread_adapter = new ModuleLocalThreadAdapter(); |
yzshen1
2012/06/06 16:56:37
The code no longer uses this. You could make this
| |
673 g_module_local_thread_adapter->AddRef(); // Leaked, this object is global. | 664 g_module_local_thread_adapter->AddRef(); // Leaked, this object is global. |
674 } | 665 } |
675 | 666 |
676 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 667 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
677 if (!dispatcher) { | 668 if (!dispatcher) { |
678 NOTREACHED(); | 669 NOTREACHED(); |
679 return false; | 670 return false; |
680 } | 671 } |
681 g_module_local_thread_adapter->AddInstanceRouting(instance, dispatcher); | 672 g_module_local_thread_adapter->AddInstanceRouting(instance, dispatcher); |
682 return true; | 673 return true; |
683 } | 674 } |
684 | 675 |
685 void PPB_Flash_Proxy::ClearThreadAdapterForInstance(PP_Instance instance) { | 676 void PPB_Flash_Proxy::ClearThreadAdapterForInstance(PP_Instance instance) { |
686 if (g_module_local_thread_adapter) | 677 if (g_module_local_thread_adapter) |
687 g_module_local_thread_adapter->ClearInstanceRouting(instance); | 678 g_module_local_thread_adapter->ClearInstanceRouting(instance); |
688 } | 679 } |
689 | 680 |
690 int32_t PPB_Flash_Proxy::OpenFile(PP_Instance instance, | 681 int32_t PPB_Flash_Proxy::OpenFile(PP_Instance, |
691 const char* path, | 682 const char* path, |
692 int32_t mode, | 683 int32_t mode, |
693 PP_FileHandle* file) { | 684 PP_FileHandle* file) { |
694 if (!g_module_local_thread_adapter) | 685 int flags = 0; |
695 return PP_ERROR_FAILED; | 686 if (!path || |
687 !ppapi::PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || | |
688 !file) | |
689 return PP_ERROR_BADARGUMENT; | |
696 | 690 |
697 int32_t result = PP_ERROR_FAILED; | 691 base::PlatformFileError error; |
698 IPC::PlatformFileForTransit transit; | 692 IPC::PlatformFileForTransit transit_file; |
699 g_module_local_thread_adapter->Send(instance, | 693 ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, |
700 new PpapiHostMsg_PPBFlash_OpenFile( | 694 FilePath::FromUTF8Unsafe(path)); |
701 API_ID_PPB_FLASH, instance, path, mode, &transit, &result)); | 695 |
702 *file = IPC::PlatformFileForTransitToPlatformFile(transit); | 696 if (PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
yzshen1
2012/06/06 16:56:37
I don't think it is safe to do so. OpenFile and ot
| |
703 return result; | 697 new PepperFileMsg_OpenFile(pepper_path, flags, |
698 &error, &transit_file))) { | |
699 *file = IPC::PlatformFileForTransitToPlatformFile(transit_file); | |
700 } else { | |
701 *file = base::kInvalidPlatformFileValue; | |
702 error = base::PLATFORM_FILE_ERROR_FAILED; | |
703 } | |
704 | |
705 return ppapi::PlatformFileErrorToPepperError(error); | |
704 } | 706 } |
705 | 707 |
706 int32_t PPB_Flash_Proxy::RenameFile(PP_Instance instance, | 708 int32_t PPB_Flash_Proxy::RenameFile(PP_Instance, |
707 const char* path_from, | 709 const char* from_path, |
708 const char* path_to) { | 710 const char* to_path) { |
709 if (!g_module_local_thread_adapter) | 711 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; |
710 return PP_ERROR_FAILED; | 712 ppapi::PepperFilePath pepper_from(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, |
713 FilePath::FromUTF8Unsafe(from_path)); | |
714 ppapi::PepperFilePath pepper_to(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, | |
715 FilePath::FromUTF8Unsafe(to_path)); | |
711 | 716 |
712 int32_t result = PP_ERROR_FAILED; | 717 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
713 g_module_local_thread_adapter->Send(instance, | 718 new PepperFileMsg_RenameFile(pepper_from, pepper_to, &error)); |
714 new PpapiHostMsg_PPBFlash_RenameFile( | 719 |
715 API_ID_PPB_FLASH, instance, path_from, path_to, &result)); | 720 return ppapi::PlatformFileErrorToPepperError(error); |
716 return result; | |
717 } | 721 } |
718 | 722 |
719 int32_t PPB_Flash_Proxy::DeleteFileOrDir(PP_Instance instance, | 723 int32_t PPB_Flash_Proxy::DeleteFileOrDir(PP_Instance, |
720 const char* path, | 724 const char* path, |
721 PP_Bool recursive) { | 725 PP_Bool recursive) { |
722 if (!g_module_local_thread_adapter) | 726 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; |
723 return PP_ERROR_FAILED; | 727 ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, |
728 FilePath::FromUTF8Unsafe(path)); | |
724 | 729 |
725 int32_t result = PP_ERROR_FAILED; | 730 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
726 g_module_local_thread_adapter->Send(instance, | 731 new PepperFileMsg_DeleteFileOrDir(pepper_path, |
727 new PpapiHostMsg_PPBFlash_DeleteFileOrDir( | 732 PP_ToBool(recursive), |
728 API_ID_PPB_FLASH, instance, path, recursive, &result)); | 733 &error)); |
729 return result; | 734 |
735 return ppapi::PlatformFileErrorToPepperError(error); | |
730 } | 736 } |
731 | 737 |
732 int32_t PPB_Flash_Proxy::CreateDir(PP_Instance instance, const char* path) { | 738 int32_t PPB_Flash_Proxy::CreateDir(PP_Instance, const char* path) { |
733 if (!g_module_local_thread_adapter) | 739 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; |
734 return PP_ERROR_FAILED; | 740 ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, |
741 FilePath::FromUTF8Unsafe(path)); | |
735 | 742 |
736 int32_t result = PP_ERROR_FAILED; | 743 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
737 g_module_local_thread_adapter->Send(instance, | 744 new PepperFileMsg_CreateDir(pepper_path, &error)); |
738 new PpapiHostMsg_PPBFlash_CreateDir( | 745 |
739 API_ID_PPB_FLASH, instance, path, &result)); | 746 return ppapi::PlatformFileErrorToPepperError(error); |
740 return result; | |
741 } | 747 } |
742 | 748 |
743 int32_t PPB_Flash_Proxy::QueryFile(PP_Instance instance, | 749 int32_t PPB_Flash_Proxy::QueryFile(PP_Instance, |
744 const char* path, | 750 const char* path, |
745 PP_FileInfo* info) { | 751 PP_FileInfo* info) { |
746 if (!g_module_local_thread_adapter) | 752 base::PlatformFileInfo file_info; |
747 return PP_ERROR_FAILED; | 753 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; |
754 ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, | |
755 FilePath::FromUTF8Unsafe(path)); | |
748 | 756 |
749 int32_t result = PP_ERROR_FAILED; | 757 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
750 g_module_local_thread_adapter->Send(instance, | 758 new PepperFileMsg_QueryFile(pepper_path, &file_info, &error)); |
751 new PpapiHostMsg_PPBFlash_QueryFile( | 759 |
752 API_ID_PPB_FLASH, instance, path, info, &result)); | 760 if (error == base::PLATFORM_FILE_OK) { |
753 return result; | 761 info->size = file_info.size; |
762 info->creation_time = TimeToPPTime(file_info.creation_time); | |
763 info->last_access_time = TimeToPPTime(file_info.last_accessed); | |
764 info->last_modified_time = TimeToPPTime(file_info.last_modified); | |
765 info->system_type = PP_FILESYSTEMTYPE_EXTERNAL; | |
766 if (file_info.is_directory) | |
767 info->type = PP_FILETYPE_DIRECTORY; | |
768 else | |
769 info->type = PP_FILETYPE_REGULAR; | |
770 } | |
771 | |
772 return ppapi::PlatformFileErrorToPepperError(error); | |
754 } | 773 } |
755 | 774 |
756 int32_t PPB_Flash_Proxy::GetDirContents(PP_Instance instance, | 775 int32_t PPB_Flash_Proxy::GetDirContents(PP_Instance, |
757 const char* path, | 776 const char* path, |
758 PP_DirContents_Dev** contents) { | 777 PP_DirContents_Dev** contents) { |
759 if (!g_module_local_thread_adapter) | 778 ppapi::DirContents entries; |
760 return PP_ERROR_FAILED; | 779 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; |
780 ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, | |
781 FilePath::FromUTF8Unsafe(path)); | |
761 | 782 |
762 int32_t result = PP_ERROR_FAILED; | 783 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
763 std::vector<SerializedDirEntry> entries; | 784 new PepperFileMsg_GetDirContents(pepper_path, &entries, &error)); |
764 g_module_local_thread_adapter->Send(instance, | |
765 new PpapiHostMsg_PPBFlash_GetDirContents( | |
766 API_ID_PPB_FLASH, instance, path, &entries, &result)); | |
767 | 785 |
768 if (result != PP_OK) | 786 if (error == base::PLATFORM_FILE_OK) { |
769 return result; | 787 // Copy the serialized dir entries to the output struct. |
770 | 788 *contents = new PP_DirContents_Dev; |
771 // Copy the serialized dir entries to the output struct. | 789 (*contents)->count = static_cast<int32_t>(entries.size()); |
772 *contents = new PP_DirContents_Dev; | 790 (*contents)->entries = new PP_DirEntry_Dev[entries.size()]; |
773 (*contents)->count = static_cast<int32_t>(entries.size()); | 791 for (size_t i = 0; i < entries.size(); i++) { |
774 (*contents)->entries = new PP_DirEntry_Dev[entries.size()]; | 792 const ppapi::DirEntry& source = entries[i]; |
775 for (size_t i = 0; i < entries.size(); i++) { | 793 PP_DirEntry_Dev* dest = &(*contents)->entries[i]; |
776 const SerializedDirEntry& source = entries[i]; | 794 std::string name = source.name.AsUTF8Unsafe(); |
777 PP_DirEntry_Dev* dest = &(*contents)->entries[i]; | 795 char* name_copy = new char[name.size() + 1]; |
778 | 796 memcpy(name_copy, name.c_str(), name.size() + 1); |
779 char* name_copy = new char[source.name.size() + 1]; | 797 dest->name = name_copy; |
780 memcpy(name_copy, source.name.c_str(), source.name.size() + 1); | 798 dest->is_dir = PP_FromBool(source.is_dir); |
781 dest->name = name_copy; | 799 } |
782 dest->is_dir = PP_FromBool(source.is_dir); | |
783 } | 800 } |
784 | 801 |
785 return result; | 802 return ppapi::PlatformFileErrorToPepperError(error); |
786 } | 803 } |
787 | 804 |
788 int32_t PPB_Flash_Proxy::OpenFileRef(PP_Instance instance, | 805 int32_t PPB_Flash_Proxy::OpenFileRef(PP_Instance instance, |
789 PP_Resource file_ref_id, | 806 PP_Resource file_ref_id, |
790 int32_t mode, | 807 int32_t mode, |
791 PP_FileHandle* file) { | 808 PP_FileHandle* file) { |
792 EnterResourceNoLock<thunk::PPB_FileRef_API> enter(file_ref_id, true); | 809 EnterResourceNoLock<thunk::PPB_FileRef_API> enter(file_ref_id, true); |
793 if (enter.failed()) | 810 if (enter.failed()) |
794 return PP_ERROR_BADRESOURCE; | 811 return PP_ERROR_BADRESOURCE; |
795 | 812 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1041 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | 1058 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), |
1042 data_item_count, | 1059 data_item_count, |
1043 formats_array.get(), | 1060 formats_array.get(), |
1044 data_items_array); | 1061 data_items_array); |
1045 DLOG_IF(WARNING, result != PP_OK) | 1062 DLOG_IF(WARNING, result != PP_OK) |
1046 << "Write to clipboard failed unexpectedly."; | 1063 << "Write to clipboard failed unexpectedly."; |
1047 (void)result; // Prevent warning in release mode. | 1064 (void)result; // Prevent warning in release mode. |
1048 } | 1065 } |
1049 } | 1066 } |
1050 | 1067 |
1051 void PPB_Flash_Proxy::OnHostMsgOpenFile( | |
1052 PP_Instance instance, | |
1053 const std::string& path, | |
1054 int32_t mode, | |
1055 IPC::PlatformFileForTransit* file_handle, | |
1056 int32_t* result) { | |
1057 EnterInstanceNoLock enter(instance); | |
1058 if (enter.succeeded()) { | |
1059 base::PlatformFile file; | |
1060 *result = enter.functions()->GetFlashAPI()->OpenFile( | |
1061 instance, path.c_str(), mode, &file); | |
1062 *file_handle = PlatformFileToPlatformFileForTransit( | |
1063 dispatcher(), result, file); | |
1064 } else { | |
1065 *result = PP_ERROR_BADARGUMENT; | |
1066 } | |
1067 } | |
1068 | |
1069 void PPB_Flash_Proxy::OnHostMsgRenameFile(PP_Instance instance, | |
1070 const std::string& from_path, | |
1071 const std::string& to_path, | |
1072 int32_t* result) { | |
1073 EnterInstanceNoLock enter(instance); | |
1074 if (enter.succeeded()) { | |
1075 *result = enter.functions()->GetFlashAPI()->RenameFile( | |
1076 instance, from_path.c_str(), to_path.c_str()); | |
1077 } else { | |
1078 *result = PP_ERROR_BADARGUMENT; | |
1079 } | |
1080 } | |
1081 | |
1082 void PPB_Flash_Proxy::OnHostMsgDeleteFileOrDir(PP_Instance instance, | |
1083 const std::string& path, | |
1084 PP_Bool recursive, | |
1085 int32_t* result) { | |
1086 EnterInstanceNoLock enter(instance); | |
1087 if (enter.succeeded()) { | |
1088 *result = enter.functions()->GetFlashAPI()->DeleteFileOrDir( | |
1089 instance, path.c_str(), recursive); | |
1090 } else { | |
1091 *result = PP_ERROR_BADARGUMENT; | |
1092 } | |
1093 } | |
1094 | |
1095 void PPB_Flash_Proxy::OnHostMsgCreateDir(PP_Instance instance, | |
1096 const std::string& path, | |
1097 int32_t* result) { | |
1098 EnterInstanceNoLock enter(instance); | |
1099 if (enter.succeeded()) { | |
1100 *result = enter.functions()->GetFlashAPI()->CreateDir( | |
1101 instance, path.c_str()); | |
1102 } else { | |
1103 *result = PP_ERROR_BADARGUMENT; | |
1104 } | |
1105 } | |
1106 | |
1107 void PPB_Flash_Proxy::OnHostMsgQueryFile(PP_Instance instance, | |
1108 const std::string& path, | |
1109 PP_FileInfo* info, | |
1110 int32_t* result) { | |
1111 EnterInstanceNoLock enter(instance); | |
1112 if (enter.succeeded()) { | |
1113 *result = enter.functions()->GetFlashAPI()->QueryFile( | |
1114 instance, path.c_str(), info); | |
1115 } else { | |
1116 *result = PP_ERROR_BADARGUMENT; | |
1117 } | |
1118 } | |
1119 | |
1120 void PPB_Flash_Proxy::OnHostMsgGetDirContents( | |
1121 PP_Instance instance, | |
1122 const std::string& path, | |
1123 std::vector<SerializedDirEntry>* entries, | |
1124 int32_t* result) { | |
1125 EnterInstanceNoLock enter(instance); | |
1126 if (enter.failed()) { | |
1127 *result = PP_ERROR_BADARGUMENT; | |
1128 return; | |
1129 } | |
1130 | |
1131 PP_DirContents_Dev* contents = NULL; | |
1132 *result = enter.functions()->GetFlashAPI()->GetDirContents( | |
1133 instance, path.c_str(), &contents); | |
1134 if (*result != PP_OK) | |
1135 return; | |
1136 | |
1137 // Convert the list of entries to the serialized version. | |
1138 entries->resize(contents->count); | |
1139 for (int32_t i = 0; i < contents->count; i++) { | |
1140 (*entries)[i].name.assign(contents->entries[i].name); | |
1141 (*entries)[i].is_dir = PP_ToBool(contents->entries[i].is_dir); | |
1142 } | |
1143 enter.functions()->GetFlashAPI()->FreeDirContents(instance, contents); | |
1144 } | |
1145 | |
1146 void PPB_Flash_Proxy::OnHostMsgOpenFileRef( | 1068 void PPB_Flash_Proxy::OnHostMsgOpenFileRef( |
1147 PP_Instance instance, | 1069 PP_Instance instance, |
1148 const HostResource& host_resource, | 1070 const HostResource& host_resource, |
1149 int32_t mode, | 1071 int32_t mode, |
1150 IPC::PlatformFileForTransit* file_handle, | 1072 IPC::PlatformFileForTransit* file_handle, |
1151 int32_t* result) { | 1073 int32_t* result) { |
1152 EnterInstanceNoLock enter(instance); | 1074 EnterInstanceNoLock enter(instance); |
1153 if (enter.failed()) { | 1075 if (enter.failed()) { |
1154 *result = PP_ERROR_BADARGUMENT; | 1076 *result = PP_ERROR_BADARGUMENT; |
1155 return; | 1077 return; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1193 // It's rarely used enough that we just request this interface when needed. | 1115 // It's rarely used enough that we just request this interface when needed. |
1194 const PPB_Flash_Print_1_0* print_interface = | 1116 const PPB_Flash_Print_1_0* print_interface = |
1195 static_cast<const PPB_Flash_Print_1_0*>( | 1117 static_cast<const PPB_Flash_Print_1_0*>( |
1196 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); | 1118 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); |
1197 if (print_interface) | 1119 if (print_interface) |
1198 print_interface->InvokePrinting(instance); | 1120 print_interface->InvokePrinting(instance); |
1199 } | 1121 } |
1200 | 1122 |
1201 } // namespace proxy | 1123 } // namespace proxy |
1202 } // namespace ppapi | 1124 } // namespace ppapi |
OLD | NEW |