| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 for (std::set<int>::iterator i = pending_requests_for_filter_.begin(); | 172 for (std::set<int>::iterator i = pending_requests_for_filter_.begin(); |
| 173 i != pending_requests_for_filter_.end(); ++i) { | 173 i != pending_requests_for_filter_.end(); ++i) { |
| 174 g_module_local_thread_adapter->OnModuleLocalMessageFailed(*i); | 174 g_module_local_thread_adapter->OnModuleLocalMessageFailed(*i); |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 bool ModuleLocalThreadAdapter::Filter::OnMessageReceived( | 178 bool ModuleLocalThreadAdapter::Filter::OnMessageReceived( |
| 179 const IPC::Message& message) { | 179 const IPC::Message& message) { |
| 180 if (!message.is_reply() || | 180 if (!message.is_reply() || |
| 181 message.routing_id() != INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL) | 181 message.routing_id() != API_ID_PPB_FLASH_FILE_MODULELOCAL) |
| 182 return false; | 182 return false; |
| 183 | 183 |
| 184 if (g_module_local_thread_adapter->OnModuleLocalMessageReceived(message)) { | 184 if (g_module_local_thread_adapter->OnModuleLocalMessageReceived(message)) { |
| 185 // The message was consumed, this means we can remove the message ID from | 185 // The message was consumed, this means we can remove the message ID from |
| 186 // the list of messages this channel is waiting on. | 186 // the list of messages this channel is waiting on. |
| 187 pending_requests_for_filter_.erase(IPC::SyncMessage::GetMessageId(message)); | 187 pending_requests_for_filter_.erase(IPC::SyncMessage::GetMessageId(message)); |
| 188 return true; | 188 return true; |
| 189 } | 189 } |
| 190 return false; | 190 return false; |
| 191 } | 191 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 const char* path, | 392 const char* path, |
| 393 int32_t mode, | 393 int32_t mode, |
| 394 PP_FileHandle* file) { | 394 PP_FileHandle* file) { |
| 395 if (!g_module_local_thread_adapter) | 395 if (!g_module_local_thread_adapter) |
| 396 return PP_ERROR_FAILED; | 396 return PP_ERROR_FAILED; |
| 397 | 397 |
| 398 int32_t result = PP_ERROR_FAILED; | 398 int32_t result = PP_ERROR_FAILED; |
| 399 IPC::PlatformFileForTransit transit; | 399 IPC::PlatformFileForTransit transit; |
| 400 g_module_local_thread_adapter->Send(instance, | 400 g_module_local_thread_adapter->Send(instance, |
| 401 new PpapiHostMsg_PPBFlashFile_ModuleLocal_OpenFile( | 401 new PpapiHostMsg_PPBFlashFile_ModuleLocal_OpenFile( |
| 402 INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL, | 402 API_ID_PPB_FLASH_FILE_MODULELOCAL, |
| 403 instance, path, mode, &transit, &result)); | 403 instance, path, mode, &transit, &result)); |
| 404 *file = IPC::PlatformFileForTransitToPlatformFile(transit); | 404 *file = IPC::PlatformFileForTransitToPlatformFile(transit); |
| 405 return result; | 405 return result; |
| 406 } | 406 } |
| 407 | 407 |
| 408 int32_t RenameModuleLocalFile(PP_Instance instance, | 408 int32_t RenameModuleLocalFile(PP_Instance instance, |
| 409 const char* from_path, | 409 const char* from_path, |
| 410 const char* to_path) { | 410 const char* to_path) { |
| 411 if (!g_module_local_thread_adapter) | 411 if (!g_module_local_thread_adapter) |
| 412 return PP_ERROR_FAILED; | 412 return PP_ERROR_FAILED; |
| 413 | 413 |
| 414 int32_t result = PP_ERROR_FAILED; | 414 int32_t result = PP_ERROR_FAILED; |
| 415 g_module_local_thread_adapter->Send(instance, | 415 g_module_local_thread_adapter->Send(instance, |
| 416 new PpapiHostMsg_PPBFlashFile_ModuleLocal_RenameFile( | 416 new PpapiHostMsg_PPBFlashFile_ModuleLocal_RenameFile( |
| 417 INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL, | 417 API_ID_PPB_FLASH_FILE_MODULELOCAL, |
| 418 instance, from_path, to_path, &result)); | 418 instance, from_path, to_path, &result)); |
| 419 return result; | 419 return result; |
| 420 } | 420 } |
| 421 | 421 |
| 422 int32_t DeleteModuleLocalFileOrDir(PP_Instance instance, | 422 int32_t DeleteModuleLocalFileOrDir(PP_Instance instance, |
| 423 const char* path, | 423 const char* path, |
| 424 PP_Bool recursive) { | 424 PP_Bool recursive) { |
| 425 if (!g_module_local_thread_adapter) | 425 if (!g_module_local_thread_adapter) |
| 426 return PP_ERROR_FAILED; | 426 return PP_ERROR_FAILED; |
| 427 | 427 |
| 428 int32_t result = PP_ERROR_FAILED; | 428 int32_t result = PP_ERROR_FAILED; |
| 429 g_module_local_thread_adapter->Send(instance, | 429 g_module_local_thread_adapter->Send(instance, |
| 430 new PpapiHostMsg_PPBFlashFile_ModuleLocal_DeleteFileOrDir( | 430 new PpapiHostMsg_PPBFlashFile_ModuleLocal_DeleteFileOrDir( |
| 431 INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL, | 431 API_ID_PPB_FLASH_FILE_MODULELOCAL, |
| 432 instance, path, recursive, &result)); | 432 instance, path, recursive, &result)); |
| 433 return result; | 433 return result; |
| 434 } | 434 } |
| 435 | 435 |
| 436 int32_t CreateModuleLocalDir(PP_Instance instance, const char* path) { | 436 int32_t CreateModuleLocalDir(PP_Instance instance, const char* path) { |
| 437 if (!g_module_local_thread_adapter) | 437 if (!g_module_local_thread_adapter) |
| 438 return PP_ERROR_FAILED; | 438 return PP_ERROR_FAILED; |
| 439 | 439 |
| 440 int32_t result = PP_ERROR_FAILED; | 440 int32_t result = PP_ERROR_FAILED; |
| 441 g_module_local_thread_adapter->Send(instance, | 441 g_module_local_thread_adapter->Send(instance, |
| 442 new PpapiHostMsg_PPBFlashFile_ModuleLocal_CreateDir( | 442 new PpapiHostMsg_PPBFlashFile_ModuleLocal_CreateDir( |
| 443 INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL, instance, path, &result)); | 443 API_ID_PPB_FLASH_FILE_MODULELOCAL, instance, path, &result)); |
| 444 return result; | 444 return result; |
| 445 } | 445 } |
| 446 | 446 |
| 447 int32_t QueryModuleLocalFile(PP_Instance instance, | 447 int32_t QueryModuleLocalFile(PP_Instance instance, |
| 448 const char* path, | 448 const char* path, |
| 449 PP_FileInfo* info) { | 449 PP_FileInfo* info) { |
| 450 if (!g_module_local_thread_adapter) | 450 if (!g_module_local_thread_adapter) |
| 451 return PP_ERROR_FAILED; | 451 return PP_ERROR_FAILED; |
| 452 | 452 |
| 453 int32_t result = PP_ERROR_FAILED; | 453 int32_t result = PP_ERROR_FAILED; |
| 454 g_module_local_thread_adapter->Send(instance, | 454 g_module_local_thread_adapter->Send(instance, |
| 455 new PpapiHostMsg_PPBFlashFile_ModuleLocal_QueryFile( | 455 new PpapiHostMsg_PPBFlashFile_ModuleLocal_QueryFile( |
| 456 INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL, instance, path, | 456 API_ID_PPB_FLASH_FILE_MODULELOCAL, instance, path, |
| 457 info, &result)); | 457 info, &result)); |
| 458 return result; | 458 return result; |
| 459 } | 459 } |
| 460 | 460 |
| 461 int32_t GetModuleLocalDirContents(PP_Instance instance, | 461 int32_t GetModuleLocalDirContents(PP_Instance instance, |
| 462 const char* path, | 462 const char* path, |
| 463 PP_DirContents_Dev** contents) { | 463 PP_DirContents_Dev** contents) { |
| 464 if (!g_module_local_thread_adapter) | 464 if (!g_module_local_thread_adapter) |
| 465 return PP_ERROR_FAILED; | 465 return PP_ERROR_FAILED; |
| 466 | 466 |
| 467 int32_t result = PP_ERROR_FAILED; | 467 int32_t result = PP_ERROR_FAILED; |
| 468 std::vector<SerializedDirEntry> entries; | 468 std::vector<SerializedDirEntry> entries; |
| 469 g_module_local_thread_adapter->Send(instance, | 469 g_module_local_thread_adapter->Send(instance, |
| 470 new PpapiHostMsg_PPBFlashFile_ModuleLocal_GetDirContents( | 470 new PpapiHostMsg_PPBFlashFile_ModuleLocal_GetDirContents( |
| 471 INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL, | 471 API_ID_PPB_FLASH_FILE_MODULELOCAL, |
| 472 instance, path, &entries, &result)); | 472 instance, path, &entries, &result)); |
| 473 | 473 |
| 474 if (result != PP_OK) | 474 if (result != PP_OK) |
| 475 return result; | 475 return result; |
| 476 | 476 |
| 477 // Copy the serialized dir entries to the output struct. | 477 // Copy the serialized dir entries to the output struct. |
| 478 *contents = new PP_DirContents_Dev; | 478 *contents = new PP_DirContents_Dev; |
| 479 (*contents)->count = static_cast<int32_t>(entries.size()); | 479 (*contents)->count = static_cast<int32_t>(entries.size()); |
| 480 (*contents)->entries = new PP_DirEntry_Dev[entries.size()]; | 480 (*contents)->entries = new PP_DirEntry_Dev[entries.size()]; |
| 481 for (size_t i = 0; i < entries.size(); i++) { | 481 for (size_t i = 0; i < entries.size(); i++) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } | 522 } |
| 523 | 523 |
| 524 PPB_Flash_File_ModuleLocal_Proxy::~PPB_Flash_File_ModuleLocal_Proxy() { | 524 PPB_Flash_File_ModuleLocal_Proxy::~PPB_Flash_File_ModuleLocal_Proxy() { |
| 525 } | 525 } |
| 526 | 526 |
| 527 // static | 527 // static |
| 528 const InterfaceProxy::Info* PPB_Flash_File_ModuleLocal_Proxy::GetInfo() { | 528 const InterfaceProxy::Info* PPB_Flash_File_ModuleLocal_Proxy::GetInfo() { |
| 529 static const Info info = { | 529 static const Info info = { |
| 530 &flash_file_modulelocal_interface, | 530 &flash_file_modulelocal_interface, |
| 531 PPB_FLASH_FILE_MODULELOCAL_INTERFACE, | 531 PPB_FLASH_FILE_MODULELOCAL_INTERFACE, |
| 532 INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL, | 532 API_ID_PPB_FLASH_FILE_MODULELOCAL, |
| 533 true, | 533 true, |
| 534 &CreateFlashFileModuleLocalProxy, | 534 &CreateFlashFileModuleLocalProxy, |
| 535 }; | 535 }; |
| 536 return &info; | 536 return &info; |
| 537 } | 537 } |
| 538 | 538 |
| 539 bool PPB_Flash_File_ModuleLocal_Proxy::OnMessageReceived( | 539 bool PPB_Flash_File_ModuleLocal_Proxy::OnMessageReceived( |
| 540 const IPC::Message& msg) { | 540 const IPC::Message& msg) { |
| 541 bool handled = true; | 541 bool handled = true; |
| 542 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_File_ModuleLocal_Proxy, msg) | 542 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_File_ModuleLocal_Proxy, msg) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 if (!file_ref) | 636 if (!file_ref) |
| 637 return PP_ERROR_BADRESOURCE; | 637 return PP_ERROR_BADRESOURCE; |
| 638 | 638 |
| 639 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(file_ref); | 639 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(file_ref); |
| 640 if (!dispatcher) | 640 if (!dispatcher) |
| 641 return PP_ERROR_BADARGUMENT; | 641 return PP_ERROR_BADARGUMENT; |
| 642 | 642 |
| 643 int32_t result = PP_ERROR_FAILED; | 643 int32_t result = PP_ERROR_FAILED; |
| 644 IPC::PlatformFileForTransit transit; | 644 IPC::PlatformFileForTransit transit; |
| 645 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_OpenFile( | 645 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_OpenFile( |
| 646 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, | 646 API_ID_PPB_FLASH_FILE_FILEREF, |
| 647 file_ref->host_resource(), mode, &transit, &result)); | 647 file_ref->host_resource(), mode, &transit, &result)); |
| 648 *file = IPC::PlatformFileForTransitToPlatformFile(transit); | 648 *file = IPC::PlatformFileForTransitToPlatformFile(transit); |
| 649 return result; | 649 return result; |
| 650 } | 650 } |
| 651 | 651 |
| 652 int32_t QueryFileRefFile(PP_Resource file_ref_id, | 652 int32_t QueryFileRefFile(PP_Resource file_ref_id, |
| 653 PP_FileInfo* info) { | 653 PP_FileInfo* info) { |
| 654 Resource* file_ref = | 654 Resource* file_ref = |
| 655 PpapiGlobals::Get()->GetResourceTracker()->GetResource(file_ref_id); | 655 PpapiGlobals::Get()->GetResourceTracker()->GetResource(file_ref_id); |
| 656 if (!file_ref) | 656 if (!file_ref) |
| 657 return PP_ERROR_BADRESOURCE; | 657 return PP_ERROR_BADRESOURCE; |
| 658 | 658 |
| 659 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(file_ref); | 659 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(file_ref); |
| 660 if (!dispatcher) | 660 if (!dispatcher) |
| 661 return PP_ERROR_BADARGUMENT; | 661 return PP_ERROR_BADARGUMENT; |
| 662 | 662 |
| 663 int32_t result = PP_ERROR_FAILED; | 663 int32_t result = PP_ERROR_FAILED; |
| 664 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_QueryFile( | 664 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_QueryFile( |
| 665 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, | 665 API_ID_PPB_FLASH_FILE_FILEREF, |
| 666 file_ref->host_resource(), info, &result)); | 666 file_ref->host_resource(), info, &result)); |
| 667 return result; | 667 return result; |
| 668 } | 668 } |
| 669 | 669 |
| 670 const PPB_Flash_File_FileRef flash_file_fileref_interface = { | 670 const PPB_Flash_File_FileRef flash_file_fileref_interface = { |
| 671 &OpenFileRefFile, | 671 &OpenFileRefFile, |
| 672 &QueryFileRefFile, | 672 &QueryFileRefFile, |
| 673 }; | 673 }; |
| 674 | 674 |
| 675 InterfaceProxy* CreateFlashFileFileRefProxy(Dispatcher* dispatcher) { | 675 InterfaceProxy* CreateFlashFileFileRefProxy(Dispatcher* dispatcher) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 689 } | 689 } |
| 690 | 690 |
| 691 PPB_Flash_File_FileRef_Proxy::~PPB_Flash_File_FileRef_Proxy() { | 691 PPB_Flash_File_FileRef_Proxy::~PPB_Flash_File_FileRef_Proxy() { |
| 692 } | 692 } |
| 693 | 693 |
| 694 // static | 694 // static |
| 695 const InterfaceProxy::Info* PPB_Flash_File_FileRef_Proxy::GetInfo() { | 695 const InterfaceProxy::Info* PPB_Flash_File_FileRef_Proxy::GetInfo() { |
| 696 static const Info info = { | 696 static const Info info = { |
| 697 &flash_file_fileref_interface, | 697 &flash_file_fileref_interface, |
| 698 PPB_FLASH_FILE_FILEREF_INTERFACE, | 698 PPB_FLASH_FILE_FILEREF_INTERFACE, |
| 699 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, | 699 API_ID_PPB_FLASH_FILE_FILEREF, |
| 700 true, | 700 true, |
| 701 &CreateFlashFileFileRefProxy, | 701 &CreateFlashFileFileRefProxy, |
| 702 }; | 702 }; |
| 703 return &info; | 703 return &info; |
| 704 } | 704 } |
| 705 | 705 |
| 706 bool PPB_Flash_File_FileRef_Proxy::OnMessageReceived( | 706 bool PPB_Flash_File_FileRef_Proxy::OnMessageReceived( |
| 707 const IPC::Message& msg) { | 707 const IPC::Message& msg) { |
| 708 bool handled = true; | 708 bool handled = true; |
| 709 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_File_FileRef_Proxy, msg) | 709 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_File_FileRef_Proxy, msg) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 732 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( | 732 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( |
| 733 const HostResource& host_resource, | 733 const HostResource& host_resource, |
| 734 PP_FileInfo* info, | 734 PP_FileInfo* info, |
| 735 int32_t* result) { | 735 int32_t* result) { |
| 736 *result = ppb_flash_file_fileref_impl_->QueryFile( | 736 *result = ppb_flash_file_fileref_impl_->QueryFile( |
| 737 host_resource.host_resource(), info); | 737 host_resource.host_resource(), info); |
| 738 } | 738 } |
| 739 | 739 |
| 740 } // namespace proxy | 740 } // namespace proxy |
| 741 } // namespace ppapi | 741 } // namespace ppapi |
| OLD | NEW |