| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/directory_reader_resource.h" | 5 #include "ppapi/proxy/directory_reader_resource.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ipc/ipc_message.h" | 8 #include "ipc/ipc_message.h" |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/proxy/dispatch_reply_message.h" | 10 #include "ppapi/proxy/dispatch_reply_message.h" |
| 11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
| 12 #include "ppapi/proxy/ppb_file_ref_proxy.h" | 12 #include "ppapi/proxy/ppb_file_ref_proxy.h" |
| 13 #include "ppapi/shared_impl/ppapi_globals.h" | 13 #include "ppapi/shared_impl/ppapi_globals.h" |
| 14 #include "ppapi/shared_impl/resource_tracker.h" | 14 #include "ppapi/shared_impl/resource_tracker.h" |
| 15 #include "ppapi/shared_impl/tracked_callback.h" | 15 #include "ppapi/shared_impl/tracked_callback.h" |
| 16 #include "ppapi/thunk/enter.h" | 16 #include "ppapi/thunk/enter.h" |
| 17 #include "ppapi/thunk/ppb_file_ref_api.h" | 17 #include "ppapi/thunk/ppb_file_ref_api.h" |
| 18 | 18 |
| 19 using ppapi::proxy::PPB_FileRef_Proxy; | 19 using ppapi::proxy::PPB_FileRef_Proxy; |
| 20 | 20 |
| 21 namespace ppapi { | 21 namespace ppapi { |
| 22 namespace proxy { | 22 namespace proxy { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 void ReleaseEntries(const std::vector<PP_DirectoryEntry_Dev>& entries) { | 26 void ReleaseEntries(const std::vector<PP_DirectoryEntry>& entries) { |
| 27 ResourceTracker* tracker = PpapiGlobals::Get()->GetResourceTracker(); | 27 ResourceTracker* tracker = PpapiGlobals::Get()->GetResourceTracker(); |
| 28 for (std::vector<PP_DirectoryEntry_Dev>::const_iterator it = entries.begin(); | 28 for (std::vector<PP_DirectoryEntry>::const_iterator it = entries.begin(); |
| 29 it != entries.end(); ++it) | 29 it != entries.end(); ++it) |
| 30 tracker->ReleaseResource(it->file_ref); | 30 tracker->ReleaseResource(it->file_ref); |
| 31 } | 31 } |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 DirectoryReaderResource::DirectoryReaderResource( | 35 DirectoryReaderResource::DirectoryReaderResource( |
| 36 Connection connection, | 36 Connection connection, |
| 37 PP_Instance instance, | 37 PP_Instance instance, |
| 38 PP_Resource directory_ref) | 38 PP_Resource directory_ref) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 69 return PP_OK_COMPLETIONPENDING; | 69 return PP_OK_COMPLETIONPENDING; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void DirectoryReaderResource::OnPluginMsgGetEntriesReply( | 72 void DirectoryReaderResource::OnPluginMsgGetEntriesReply( |
| 73 const PP_ArrayOutput& output, | 73 const PP_ArrayOutput& output, |
| 74 const ResourceMessageReplyParams& params, | 74 const ResourceMessageReplyParams& params, |
| 75 const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos, | 75 const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos, |
| 76 const std::vector<PP_FileType>& file_types) { | 76 const std::vector<PP_FileType>& file_types) { |
| 77 CHECK_EQ(infos.size(), file_types.size()); | 77 CHECK_EQ(infos.size(), file_types.size()); |
| 78 | 78 |
| 79 std::vector<PP_DirectoryEntry_Dev> entries; | 79 std::vector<PP_DirectoryEntry> entries; |
| 80 for (std::vector<ppapi::PPB_FileRef_CreateInfo>::size_type i = 0; | 80 for (std::vector<ppapi::PPB_FileRef_CreateInfo>::size_type i = 0; |
| 81 i < infos.size(); ++i) { | 81 i < infos.size(); ++i) { |
| 82 PP_DirectoryEntry_Dev entry; | 82 PP_DirectoryEntry entry; |
| 83 entry.file_ref = PPB_FileRef_Proxy::DeserializeFileRef(infos[i]); | 83 entry.file_ref = PPB_FileRef_Proxy::DeserializeFileRef(infos[i]); |
| 84 entry.file_type = file_types[i]; | 84 entry.file_type = file_types[i]; |
| 85 entries.push_back(entry); | 85 entries.push_back(entry); |
| 86 } | 86 } |
| 87 | 87 |
| 88 if (!TrackedCallback::IsPending(callback_)) { | 88 if (!TrackedCallback::IsPending(callback_)) { |
| 89 ReleaseEntries(entries); | 89 ReleaseEntries(entries); |
| 90 entries.clear(); | 90 entries.clear(); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 ArrayWriter writer(output); | 94 ArrayWriter writer(output); |
| 95 if (!writer.is_valid()) { | 95 if (!writer.is_valid()) { |
| 96 ReleaseEntries(entries); | 96 ReleaseEntries(entries); |
| 97 entries.clear(); | 97 entries.clear(); |
| 98 callback_->Run(PP_ERROR_FAILED); | 98 callback_->Run(PP_ERROR_FAILED); |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 writer.StoreVector(entries); | 102 writer.StoreVector(entries); |
| 103 entries.clear(); | 103 entries.clear(); |
| 104 callback_->Run(params.result()); | 104 callback_->Run(params.result()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace proxy | 107 } // namespace proxy |
| 108 } // namespace ppapi | 108 } // namespace ppapi |
| OLD | NEW |