| 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 |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 &ClearThreadAdapterForInstance, | 494 &ClearThreadAdapterForInstance, |
| 495 &OpenModuleLocalFile, | 495 &OpenModuleLocalFile, |
| 496 &RenameModuleLocalFile, | 496 &RenameModuleLocalFile, |
| 497 &DeleteModuleLocalFileOrDir, | 497 &DeleteModuleLocalFileOrDir, |
| 498 &CreateModuleLocalDir, | 498 &CreateModuleLocalDir, |
| 499 &QueryModuleLocalFile, | 499 &QueryModuleLocalFile, |
| 500 &GetModuleLocalDirContents, | 500 &GetModuleLocalDirContents, |
| 501 &FreeDirContents, | 501 &FreeDirContents, |
| 502 }; | 502 }; |
| 503 | 503 |
| 504 InterfaceProxy* CreateFlashFileModuleLocalProxy(Dispatcher* dispatcher, | 504 InterfaceProxy* CreateFlashFileModuleLocalProxy(Dispatcher* dispatcher) { |
| 505 const void* target_interface) { | 505 return new PPB_Flash_File_ModuleLocal_Proxy(dispatcher); |
| 506 return new PPB_Flash_File_ModuleLocal_Proxy(dispatcher, target_interface); | |
| 507 } | 506 } |
| 508 | 507 |
| 509 } // namespace | 508 } // namespace |
| 510 | 509 |
| 511 PPB_Flash_File_ModuleLocal_Proxy::PPB_Flash_File_ModuleLocal_Proxy( | 510 PPB_Flash_File_ModuleLocal_Proxy::PPB_Flash_File_ModuleLocal_Proxy( |
| 512 Dispatcher* dispatcher, | 511 Dispatcher* dispatcher) |
| 513 const void* target_interface) | 512 : InterfaceProxy(dispatcher), |
| 514 : InterfaceProxy(dispatcher, target_interface) { | 513 ppb_flash_file_module_local_impl_(NULL) { |
| 514 if (!dispatcher->IsPlugin()) { |
| 515 ppb_flash_file_module_local_impl_ = |
| 516 static_cast<const PPB_Flash_File_ModuleLocal*>( |
| 517 dispatcher->local_get_interface()( |
| 518 PPB_FLASH_FILE_MODULELOCAL_INTERFACE)); |
| 519 } |
| 515 } | 520 } |
| 516 | 521 |
| 517 PPB_Flash_File_ModuleLocal_Proxy::~PPB_Flash_File_ModuleLocal_Proxy() { | 522 PPB_Flash_File_ModuleLocal_Proxy::~PPB_Flash_File_ModuleLocal_Proxy() { |
| 518 } | 523 } |
| 519 | 524 |
| 520 // static | 525 // static |
| 521 const InterfaceProxy::Info* PPB_Flash_File_ModuleLocal_Proxy::GetInfo() { | 526 const InterfaceProxy::Info* PPB_Flash_File_ModuleLocal_Proxy::GetInfo() { |
| 522 static const Info info = { | 527 static const Info info = { |
| 523 &flash_file_modulelocal_interface, | 528 &flash_file_modulelocal_interface, |
| 524 PPB_FLASH_FILE_MODULELOCAL_INTERFACE, | 529 PPB_FLASH_FILE_MODULELOCAL_INTERFACE, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 551 return handled; | 556 return handled; |
| 552 } | 557 } |
| 553 | 558 |
| 554 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgOpenFile( | 559 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgOpenFile( |
| 555 PP_Instance instance, | 560 PP_Instance instance, |
| 556 const std::string& path, | 561 const std::string& path, |
| 557 int32_t mode, | 562 int32_t mode, |
| 558 IPC::PlatformFileForTransit* file_handle, | 563 IPC::PlatformFileForTransit* file_handle, |
| 559 int32_t* result) { | 564 int32_t* result) { |
| 560 base::PlatformFile file; | 565 base::PlatformFile file; |
| 561 *result = ppb_flash_file_module_local_target()-> | 566 *result = ppb_flash_file_module_local_impl_->OpenFile( |
| 562 OpenFile(instance, path.c_str(), mode, &file); | 567 instance, path.c_str(), mode, &file); |
| 563 *file_handle = PlatformFileToPlatformFileForTransit( | 568 *file_handle = PlatformFileToPlatformFileForTransit( |
| 564 dispatcher(), result, file); | 569 dispatcher(), result, file); |
| 565 } | 570 } |
| 566 | 571 |
| 567 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgRenameFile( | 572 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgRenameFile( |
| 568 PP_Instance instance, | 573 PP_Instance instance, |
| 569 const std::string& from_path, | 574 const std::string& from_path, |
| 570 const std::string& to_path, | 575 const std::string& to_path, |
| 571 int32_t* result) { | 576 int32_t* result) { |
| 572 *result = ppb_flash_file_module_local_target()-> | 577 *result = ppb_flash_file_module_local_impl_->RenameFile( |
| 573 RenameFile(instance, from_path.c_str(), to_path.c_str()); | 578 instance, from_path.c_str(), to_path.c_str()); |
| 574 } | 579 } |
| 575 | 580 |
| 576 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgDeleteFileOrDir( | 581 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgDeleteFileOrDir( |
| 577 PP_Instance instance, | 582 PP_Instance instance, |
| 578 const std::string& path, | 583 const std::string& path, |
| 579 PP_Bool recursive, | 584 PP_Bool recursive, |
| 580 int32_t* result) { | 585 int32_t* result) { |
| 581 *result = ppb_flash_file_module_local_target()-> | 586 *result = ppb_flash_file_module_local_impl_->DeleteFileOrDir( |
| 582 DeleteFileOrDir(instance, path.c_str(), recursive); | 587 instance, path.c_str(), recursive); |
| 583 } | 588 } |
| 584 | 589 |
| 585 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgCreateDir(PP_Instance instance, | 590 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgCreateDir(PP_Instance instance, |
| 586 const std::string& path, | 591 const std::string& path, |
| 587 int32_t* result) { | 592 int32_t* result) { |
| 588 *result = ppb_flash_file_module_local_target()-> | 593 *result = ppb_flash_file_module_local_impl_->CreateDir( |
| 589 CreateDir(instance, path.c_str()); | 594 instance, path.c_str()); |
| 590 } | 595 } |
| 591 | 596 |
| 592 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgQueryFile(PP_Instance instance, | 597 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgQueryFile(PP_Instance instance, |
| 593 const std::string& path, | 598 const std::string& path, |
| 594 PP_FileInfo* info, | 599 PP_FileInfo* info, |
| 595 int32_t* result) { | 600 int32_t* result) { |
| 596 *result = ppb_flash_file_module_local_target()-> | 601 *result = ppb_flash_file_module_local_impl_->QueryFile( |
| 597 QueryFile(instance, path.c_str(), info); | 602 instance, path.c_str(), info); |
| 598 } | 603 } |
| 599 | 604 |
| 600 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgGetDirContents( | 605 void PPB_Flash_File_ModuleLocal_Proxy::OnMsgGetDirContents( |
| 601 PP_Instance instance, | 606 PP_Instance instance, |
| 602 const std::string& path, | 607 const std::string& path, |
| 603 std::vector<SerializedDirEntry>* entries, | 608 std::vector<SerializedDirEntry>* entries, |
| 604 int32_t* result) { | 609 int32_t* result) { |
| 605 PP_DirContents_Dev* contents = NULL; | 610 PP_DirContents_Dev* contents = NULL; |
| 606 *result = ppb_flash_file_module_local_target()-> | 611 *result = ppb_flash_file_module_local_impl_->GetDirContents( |
| 607 GetDirContents(instance, path.c_str(), &contents); | 612 instance, path.c_str(), &contents); |
| 608 if (*result != PP_OK) | 613 if (*result != PP_OK) |
| 609 return; | 614 return; |
| 610 | 615 |
| 611 // Convert the list of entries to the serialized version. | 616 // Convert the list of entries to the serialized version. |
| 612 entries->resize(contents->count); | 617 entries->resize(contents->count); |
| 613 for (int32_t i = 0; i < contents->count; i++) { | 618 for (int32_t i = 0; i < contents->count; i++) { |
| 614 (*entries)[i].name.assign(contents->entries[i].name); | 619 (*entries)[i].name.assign(contents->entries[i].name); |
| 615 (*entries)[i].is_dir = PP_ToBool(contents->entries[i].is_dir); | 620 (*entries)[i].is_dir = PP_ToBool(contents->entries[i].is_dir); |
| 616 } | 621 } |
| 617 ppb_flash_file_module_local_target()->FreeDirContents(instance, contents); | 622 ppb_flash_file_module_local_impl_->FreeDirContents(instance, contents); |
| 618 } | 623 } |
| 619 | 624 |
| 620 // PPB_Flash_File_FileRef ------------------------------------------------------ | 625 // PPB_Flash_File_FileRef ------------------------------------------------------ |
| 621 | 626 |
| 622 namespace { | 627 namespace { |
| 623 | 628 |
| 624 int32_t OpenFileRefFile(PP_Resource file_ref_id, | 629 int32_t OpenFileRefFile(PP_Resource file_ref_id, |
| 625 int32_t mode, | 630 int32_t mode, |
| 626 PP_FileHandle* file) { | 631 PP_FileHandle* file) { |
| 627 Resource* file_ref = | 632 Resource* file_ref = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 658 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, | 663 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, |
| 659 file_ref->host_resource(), info, &result)); | 664 file_ref->host_resource(), info, &result)); |
| 660 return result; | 665 return result; |
| 661 } | 666 } |
| 662 | 667 |
| 663 const PPB_Flash_File_FileRef flash_file_fileref_interface = { | 668 const PPB_Flash_File_FileRef flash_file_fileref_interface = { |
| 664 &OpenFileRefFile, | 669 &OpenFileRefFile, |
| 665 &QueryFileRefFile, | 670 &QueryFileRefFile, |
| 666 }; | 671 }; |
| 667 | 672 |
| 668 InterfaceProxy* CreateFlashFileFileRefProxy(Dispatcher* dispatcher, | 673 InterfaceProxy* CreateFlashFileFileRefProxy(Dispatcher* dispatcher) { |
| 669 const void* target_interface) { | 674 return new PPB_Flash_File_FileRef_Proxy(dispatcher); |
| 670 return new PPB_Flash_File_FileRef_Proxy(dispatcher, target_interface); | |
| 671 } | 675 } |
| 672 | 676 |
| 673 } // namespace | 677 } // namespace |
| 674 | 678 |
| 675 PPB_Flash_File_FileRef_Proxy::PPB_Flash_File_FileRef_Proxy( | 679 PPB_Flash_File_FileRef_Proxy::PPB_Flash_File_FileRef_Proxy( |
| 676 Dispatcher* dispatcher, | 680 Dispatcher* dispatcher) |
| 677 const void* target_interface) | 681 : InterfaceProxy(dispatcher), |
| 678 : InterfaceProxy(dispatcher, target_interface) { | 682 ppb_flash_file_fileref_impl_(NULL) { |
| 683 if (!dispatcher->IsPlugin()) { |
| 684 ppb_flash_file_fileref_impl_ = static_cast<const PPB_Flash_File_FileRef*>( |
| 685 dispatcher->local_get_interface()(PPB_FLASH_FILE_FILEREF_INTERFACE)); |
| 686 } |
| 679 } | 687 } |
| 680 | 688 |
| 681 PPB_Flash_File_FileRef_Proxy::~PPB_Flash_File_FileRef_Proxy() { | 689 PPB_Flash_File_FileRef_Proxy::~PPB_Flash_File_FileRef_Proxy() { |
| 682 } | 690 } |
| 683 | 691 |
| 684 // static | 692 // static |
| 685 const InterfaceProxy::Info* PPB_Flash_File_FileRef_Proxy::GetInfo() { | 693 const InterfaceProxy::Info* PPB_Flash_File_FileRef_Proxy::GetInfo() { |
| 686 static const Info info = { | 694 static const Info info = { |
| 687 &flash_file_fileref_interface, | 695 &flash_file_fileref_interface, |
| 688 PPB_FLASH_FILE_FILEREF_INTERFACE, | 696 PPB_FLASH_FILE_FILEREF_INTERFACE, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 706 // TODO(brettw) handle bad messages! | 714 // TODO(brettw) handle bad messages! |
| 707 return handled; | 715 return handled; |
| 708 } | 716 } |
| 709 | 717 |
| 710 void PPB_Flash_File_FileRef_Proxy::OnMsgOpenFile( | 718 void PPB_Flash_File_FileRef_Proxy::OnMsgOpenFile( |
| 711 const HostResource& host_resource, | 719 const HostResource& host_resource, |
| 712 int32_t mode, | 720 int32_t mode, |
| 713 IPC::PlatformFileForTransit* file_handle, | 721 IPC::PlatformFileForTransit* file_handle, |
| 714 int32_t* result) { | 722 int32_t* result) { |
| 715 base::PlatformFile file; | 723 base::PlatformFile file; |
| 716 *result = ppb_flash_file_module_local_target()-> | 724 *result = ppb_flash_file_fileref_impl_->OpenFile( |
| 717 OpenFile(host_resource.host_resource(), mode, &file); | 725 host_resource.host_resource(), mode, &file); |
| 718 *file_handle = PlatformFileToPlatformFileForTransit( | 726 *file_handle = PlatformFileToPlatformFileForTransit( |
| 719 dispatcher(), result, file); | 727 dispatcher(), result, file); |
| 720 } | 728 } |
| 721 | 729 |
| 722 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( | 730 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( |
| 723 const HostResource& host_resource, | 731 const HostResource& host_resource, |
| 724 PP_FileInfo* info, | 732 PP_FileInfo* info, |
| 725 int32_t* result) { | 733 int32_t* result) { |
| 726 *result = ppb_flash_file_module_local_target()-> | 734 *result = ppb_flash_file_fileref_impl_->QueryFile( |
| 727 QueryFile(host_resource.host_resource(), info); | 735 host_resource.host_resource(), info); |
| 728 } | 736 } |
| 729 | 737 |
| 730 } // namespace proxy | 738 } // namespace proxy |
| 731 } // namespace ppapi | 739 } // namespace ppapi |
| OLD | NEW |