Chromium Code Reviews| 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/pp_errors.h" | 19 #include "ppapi/c/pp_errors.h" |
| 20 #include "ppapi/c/pp_file_info.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_tracker.h" |
| 24 #include "ppapi/proxy/ppapi_messages.h" | 24 #include "ppapi/proxy/ppapi_messages.h" |
| 25 #include "ppapi/shared_impl/resource.h" | |
| 25 | 26 |
| 26 using ppapi::HostResource; | 27 using ppapi::HostResource; |
| 28 using ppapi::Resource; | |
| 27 | 29 |
| 28 namespace pp { | 30 namespace pp { |
| 29 namespace proxy { | 31 namespace proxy { |
| 30 | 32 |
| 31 namespace { | 33 namespace { |
| 32 | 34 |
| 33 // Given an error code and a handle result from a Pepper API call, converts to a | 35 // 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 | 36 // PlatformFileForTransit by sharing with the other side, closing the original |
| 35 // handle, possibly also updating the error value if an error occurred. | 37 // handle, possibly also updating the error value if an error occurred. |
| 36 IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit( | 38 IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit( |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 ppb_flash_file_module_local_target()->FreeDirContents(instance, contents); | 620 ppb_flash_file_module_local_target()->FreeDirContents(instance, contents); |
| 619 } | 621 } |
| 620 | 622 |
| 621 // PPB_Flash_File_FileRef ------------------------------------------------------ | 623 // PPB_Flash_File_FileRef ------------------------------------------------------ |
| 622 | 624 |
| 623 namespace { | 625 namespace { |
| 624 | 626 |
| 625 int32_t OpenFileRefFile(PP_Resource file_ref_id, | 627 int32_t OpenFileRefFile(PP_Resource file_ref_id, |
| 626 int32_t mode, | 628 int32_t mode, |
| 627 PP_FileHandle* file) { | 629 PP_FileHandle* file) { |
| 628 PluginResource* file_ref = | 630 Resource* file_ref = |
| 629 PluginResourceTracker::GetInstance()->GetResourceObject(file_ref_id); | 631 PluginResourceTracker::GetInstance()->GetResource(file_ref_id); |
| 630 if (!file_ref) | 632 if (!file_ref) |
| 631 return PP_ERROR_BADRESOURCE; | 633 return PP_ERROR_BADRESOURCE; |
| 632 | 634 |
| 633 PluginDispatcher* dispatcher = | 635 PluginDispatcher* dispatcher = |
| 634 PluginDispatcher::GetForInstance(file_ref->instance()); | 636 PluginDispatcher::GetForInstance(file_ref->pp_instance()); |
|
dmichael (off chromium)
2011/08/17 16:28:07
Here's one of those places you could've used GetFo
| |
| 635 if (!dispatcher) | 637 if (!dispatcher) |
| 636 return PP_ERROR_BADARGUMENT; | 638 return PP_ERROR_BADARGUMENT; |
| 637 | 639 |
| 638 int32_t result = PP_ERROR_FAILED; | 640 int32_t result = PP_ERROR_FAILED; |
| 639 IPC::PlatformFileForTransit transit; | 641 IPC::PlatformFileForTransit transit; |
| 640 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_OpenFile( | 642 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_OpenFile( |
| 641 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, | 643 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, |
| 642 file_ref->host_resource(), mode, &transit, &result)); | 644 file_ref->host_resource(), mode, &transit, &result)); |
| 643 *file = IPC::PlatformFileForTransitToPlatformFile(transit); | 645 *file = IPC::PlatformFileForTransitToPlatformFile(transit); |
| 644 return result; | 646 return result; |
| 645 } | 647 } |
| 646 | 648 |
| 647 int32_t QueryFileRefFile(PP_Resource file_ref_id, | 649 int32_t QueryFileRefFile(PP_Resource file_ref_id, |
| 648 PP_FileInfo* info) { | 650 PP_FileInfo* info) { |
| 649 PluginResource* file_ref = | 651 Resource* file_ref = |
| 650 PluginResourceTracker::GetInstance()->GetResourceObject(file_ref_id); | 652 PluginResourceTracker::GetInstance()->GetResource(file_ref_id); |
| 651 if (!file_ref) | 653 if (!file_ref) |
| 652 return PP_ERROR_BADRESOURCE; | 654 return PP_ERROR_BADRESOURCE; |
| 653 | 655 |
| 654 PluginDispatcher* dispatcher = | 656 PluginDispatcher* dispatcher = |
| 655 PluginDispatcher::GetForInstance(file_ref->instance()); | 657 PluginDispatcher::GetForInstance(file_ref->pp_instance()); |
|
dmichael (off chromium)
2011/08/17 16:28:07
ditto
| |
| 656 if (!dispatcher) | 658 if (!dispatcher) |
| 657 return PP_ERROR_BADARGUMENT; | 659 return PP_ERROR_BADARGUMENT; |
| 658 | 660 |
| 659 int32_t result = PP_ERROR_FAILED; | 661 int32_t result = PP_ERROR_FAILED; |
| 660 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_QueryFile( | 662 dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_QueryFile( |
| 661 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, | 663 INTERFACE_ID_PPB_FLASH_FILE_FILEREF, |
| 662 file_ref->host_resource(), info, &result)); | 664 file_ref->host_resource(), info, &result)); |
| 663 return result; | 665 return result; |
| 664 } | 666 } |
| 665 | 667 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( | 727 void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile( |
| 726 const HostResource& host_resource, | 728 const HostResource& host_resource, |
| 727 PP_FileInfo* info, | 729 PP_FileInfo* info, |
| 728 int32_t* result) { | 730 int32_t* result) { |
| 729 *result = ppb_flash_file_module_local_target()-> | 731 *result = ppb_flash_file_module_local_target()-> |
| 730 QueryFile(host_resource.host_resource(), info); | 732 QueryFile(host_resource.host_resource(), info); |
| 731 } | 733 } |
| 732 | 734 |
| 733 } // namespace proxy | 735 } // namespace proxy |
| 734 } // namespace pp | 736 } // namespace pp |
| OLD | NEW |