| 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/file_callbacks.h" | 5 #include "webkit/plugins/ppapi/file_callbacks.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "ppapi/c/pp_file_info.h" | 9 #include "ppapi/c/pp_file_info.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 callback_->Run(PP_OK); | 84 callback_->Run(PP_OK); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void FileCallbacks::DidCreateSnapshotFile( | 87 void FileCallbacks::DidCreateSnapshotFile( |
| 88 const base::PlatformFileInfo& file_info, | 88 const base::PlatformFileInfo& file_info, |
| 89 const base::FilePath& path) { | 89 const base::FilePath& path) { |
| 90 NOTREACHED(); | 90 NOTREACHED(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void FileCallbacks::DidReadDirectory( | 93 void FileCallbacks::DidReadDirectory( |
| 94 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) { | 94 const std::vector<fileapi::FileSystemOperation::Entry>& entries, |
| 95 bool has_more) { |
| 95 if (callback_->completed()) | 96 if (callback_->completed()) |
| 96 return; | 97 return; |
| 97 | 98 |
| 98 // The current filesystem backend always returns false. | 99 // The current filesystem backend always returns false. |
| 99 DCHECK(!has_more); | 100 DCHECK(!has_more); |
| 100 | 101 |
| 101 DCHECK(read_entries_dir_ref_); | 102 DCHECK(read_entries_dir_ref_); |
| 102 DCHECK(read_entries_files_.get()); | 103 DCHECK(read_entries_files_.get()); |
| 103 DCHECK(read_entries_file_types_.get()); | 104 DCHECK(read_entries_file_types_.get()); |
| 104 | 105 |
| 105 std::string dir_path = read_entries_dir_ref_->GetCreateInfo().path; | 106 std::string dir_path = read_entries_dir_ref_->GetCreateInfo().path; |
| 106 if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/') | 107 if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/') |
| 107 dir_path += '/'; | 108 dir_path += '/'; |
| 108 | 109 |
| 109 for (size_t i = 0; i < entries.size(); ++i) { | 110 for (size_t i = 0; i < entries.size(); ++i) { |
| 110 const base::FileUtilProxy::Entry& entry = entries[i]; | 111 const fileapi::FileSystemOperation::Entry& entry = entries[i]; |
| 111 scoped_refptr<PPB_FileRef_Impl> file_ref(PPB_FileRef_Impl::CreateInternal( | 112 scoped_refptr<PPB_FileRef_Impl> file_ref(PPB_FileRef_Impl::CreateInternal( |
| 112 read_entries_dir_ref_->pp_instance(), | 113 read_entries_dir_ref_->pp_instance(), |
| 113 read_entries_dir_ref_->file_system_resource(), | 114 read_entries_dir_ref_->file_system_resource(), |
| 114 dir_path + fileapi::FilePathToString(base::FilePath(entry.name)))); | 115 dir_path + fileapi::FilePathToString(base::FilePath(entry.name)))); |
| 115 read_entries_files_->push_back(file_ref->GetCreateInfo()); | 116 read_entries_files_->push_back(file_ref->GetCreateInfo()); |
| 116 read_entries_file_types_->push_back( | 117 read_entries_file_types_->push_back( |
| 117 entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR); | 118 entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR); |
| 118 // Add a ref count on behalf of the plugin side. | 119 // Add a ref count on behalf of the plugin side. |
| 119 file_ref->GetReference(); | 120 file_ref->GetReference(); |
| 120 } | 121 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 138 | 139 |
| 139 void FileCallbacks::RunCallback(base::PlatformFileError error_code) { | 140 void FileCallbacks::RunCallback(base::PlatformFileError error_code) { |
| 140 if (callback_->completed()) | 141 if (callback_->completed()) |
| 141 return; | 142 return; |
| 142 | 143 |
| 143 callback_->Run(::ppapi::PlatformFileErrorToPepperError(error_code)); | 144 callback_->Run(::ppapi::PlatformFileErrorToPepperError(error_code)); |
| 144 } | 145 } |
| 145 | 146 |
| 146 } // namespace ppapi | 147 } // namespace ppapi |
| 147 } // namespace webkit | 148 } // namespace webkit |
| OLD | NEW |