| 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 "webkit/plugins/ppapi/ppb_file_ref_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
| 6 | 6 |
| 7 #include "base/files/file_util_proxy.h" |
| 7 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
| 8 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 10 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 11 #include "net/base/escape.h" | 12 #include "net/base/escape.h" |
| 12 #include "ppapi/c/pp_errors.h" | 13 #include "ppapi/c/pp_errors.h" |
| 13 #include "ppapi/shared_impl/file_type_conversion.h" | 14 #include "ppapi/shared_impl/file_type_conversion.h" |
| 14 #include "ppapi/shared_impl/time_conversion.h" | 15 #include "ppapi/shared_impl/time_conversion.h" |
| 15 #include "ppapi/shared_impl/var.h" | 16 #include "ppapi/shared_impl/var.h" |
| 16 #include "ppapi/thunk/enter.h" | 17 #include "ppapi/thunk/enter.h" |
| 17 #include "ppapi/thunk/ppb_file_system_api.h" | 18 #include "ppapi/thunk/ppb_file_system_api.h" |
| 19 #include "webkit/fileapi/directory_entry.h" |
| 18 #include "webkit/fileapi/file_system_util.h" | 20 #include "webkit/fileapi/file_system_util.h" |
| 19 #include "webkit/plugins/ppapi/common.h" | 21 #include "webkit/plugins/ppapi/common.h" |
| 20 #include "webkit/plugins/ppapi/plugin_delegate.h" | 22 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 21 #include "webkit/plugins/ppapi/plugin_module.h" | 23 #include "webkit/plugins/ppapi/plugin_module.h" |
| 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 24 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 23 #include "webkit/plugins/ppapi/resource_helper.h" | 25 #include "webkit/plugins/ppapi/resource_helper.h" |
| 24 | 26 |
| 25 using ppapi::HostResource; | 27 using ppapi::HostResource; |
| 26 using ppapi::PPB_FileRef_CreateInfo; | 28 using ppapi::PPB_FileRef_CreateInfo; |
| 27 using ppapi::PPTimeToTime; | 29 using ppapi::PPTimeToTime; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 176 |
| 175 PlatformFileInfoToPPFileInfo(file_info, file_system_type, info.get()); | 177 PlatformFileInfoToPPFileInfo(file_info, file_system_type, info.get()); |
| 176 callback->Run(PP_OK); | 178 callback->Run(PP_OK); |
| 177 } | 179 } |
| 178 | 180 |
| 179 void DidReadDirectory( | 181 void DidReadDirectory( |
| 180 scoped_refptr< ::ppapi::TrackedCallback> callback, | 182 scoped_refptr< ::ppapi::TrackedCallback> callback, |
| 181 PPB_FileRef_Impl* dir_ref, | 183 PPB_FileRef_Impl* dir_ref, |
| 182 linked_ptr<std::vector< ::ppapi::PPB_FileRef_CreateInfo> > dir_files, | 184 linked_ptr<std::vector< ::ppapi::PPB_FileRef_CreateInfo> > dir_files, |
| 183 linked_ptr<std::vector<PP_FileType> > dir_file_types, | 185 linked_ptr<std::vector<PP_FileType> > dir_file_types, |
| 184 const std::vector<base::FileUtilProxy::Entry>& entries, | 186 const std::vector<fileapi::DirectoryEntry>& entries, |
| 185 bool has_more) { | 187 bool has_more) { |
| 186 if (!TrackedCallback::IsPending(callback)) | 188 if (!TrackedCallback::IsPending(callback)) |
| 187 return; | 189 return; |
| 188 | 190 |
| 189 // The current filesystem backend always returns false. | 191 // The current filesystem backend always returns false. |
| 190 DCHECK(!has_more); | 192 DCHECK(!has_more); |
| 191 | 193 |
| 192 DCHECK(dir_ref); | 194 DCHECK(dir_ref); |
| 193 DCHECK(dir_files.get()); | 195 DCHECK(dir_files.get()); |
| 194 DCHECK(dir_file_types.get()); | 196 DCHECK(dir_file_types.get()); |
| 195 | 197 |
| 196 std::string dir_path = dir_ref->GetCreateInfo().path; | 198 std::string dir_path = dir_ref->GetCreateInfo().path; |
| 197 if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/') | 199 if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/') |
| 198 dir_path += '/'; | 200 dir_path += '/'; |
| 199 | 201 |
| 200 for (size_t i = 0; i < entries.size(); ++i) { | 202 for (size_t i = 0; i < entries.size(); ++i) { |
| 201 const base::FileUtilProxy::Entry& entry = entries[i]; | 203 const fileapi::DirectoryEntry& entry = entries[i]; |
| 202 scoped_refptr<PPB_FileRef_Impl> file_ref(PPB_FileRef_Impl::CreateInternal( | 204 scoped_refptr<PPB_FileRef_Impl> file_ref(PPB_FileRef_Impl::CreateInternal( |
| 203 dir_ref->pp_instance(), | 205 dir_ref->pp_instance(), |
| 204 dir_ref->file_system_resource(), | 206 dir_ref->file_system_resource(), |
| 205 dir_path + fileapi::FilePathToString(base::FilePath(entry.name)))); | 207 dir_path + fileapi::FilePathToString(base::FilePath(entry.name)))); |
| 206 dir_files->push_back(file_ref->GetCreateInfo()); | 208 dir_files->push_back(file_ref->GetCreateInfo()); |
| 207 dir_file_types->push_back( | 209 dir_file_types->push_back( |
| 208 entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR); | 210 entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR); |
| 209 // Add a ref count on behalf of the plugin side. | 211 // Add a ref count on behalf of the plugin side. |
| 210 file_ref->GetReference(); | 212 file_ref->GetReference(); |
| 211 } | 213 } |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 GetFileSystemURL(), | 523 GetFileSystemURL(), |
| 522 base::Bind(&DidReadDirectory, | 524 base::Bind(&DidReadDirectory, |
| 523 callback, base::Unretained(this), files, file_types), | 525 callback, base::Unretained(this), files, file_types), |
| 524 base::Bind(&DidFinishFileOperation, callback))) | 526 base::Bind(&DidFinishFileOperation, callback))) |
| 525 return PP_ERROR_FAILED; | 527 return PP_ERROR_FAILED; |
| 526 return PP_OK_COMPLETIONPENDING; | 528 return PP_OK_COMPLETIONPENDING; |
| 527 } | 529 } |
| 528 | 530 |
| 529 } // namespace ppapi | 531 } // namespace ppapi |
| 530 } // namespace webkit | 532 } // namespace webkit |
| OLD | NEW |