| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi
le_util.h" | 5 #include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi
le_util.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" | 11 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" |
| 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" | 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "webkit/browser/fileapi/file_system_operation_context.h" | 14 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| 15 #include "webkit/browser/fileapi/file_system_url.h" | 15 #include "webkit/browser/fileapi/file_system_url.h" |
| 16 #include "webkit/common/blob/shareable_file_reference.h" | 16 #include "webkit/common/blob/shareable_file_reference.h" |
| 17 | 17 |
| 18 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 | 19 |
| 20 namespace chromeos { | 20 namespace chromeos { |
| 21 namespace file_system_provider { | 21 namespace file_system_provider { |
| 22 namespace internal { | 22 namespace internal { |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Executes GetFileInfo on the UI thread. | 25 // Executes GetFileInfo on the UI thread. |
| 26 void GetFileInfoOnUIThread( | 26 void GetFileInfoOnUIThread( |
| 27 scoped_ptr<fileapi::FileSystemOperationContext> context, | 27 scoped_ptr<storage::FileSystemOperationContext> context, |
| 28 const fileapi::FileSystemURL& url, | 28 const storage::FileSystemURL& url, |
| 29 const ProvidedFileSystemInterface::GetMetadataCallback& callback) { | 29 const ProvidedFileSystemInterface::GetMetadataCallback& callback) { |
| 30 util::FileSystemURLParser parser(url); | 30 util::FileSystemURLParser parser(url); |
| 31 if (!parser.Parse()) { | 31 if (!parser.Parse()) { |
| 32 callback.Run(EntryMetadata(), base::File::FILE_ERROR_INVALID_OPERATION); | 32 callback.Run(EntryMetadata(), base::File::FILE_ERROR_INVALID_OPERATION); |
| 33 return; | 33 return; |
| 34 } | 34 } |
| 35 | 35 |
| 36 parser.file_system()->GetMetadata(parser.file_path(), callback); | 36 parser.file_system()->GetMetadata(parser.file_path(), callback); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Routes the response of GetFileInfo back to the IO thread with a type | 39 // Routes the response of GetFileInfo back to the IO thread with a type |
| 40 // conversion. | 40 // conversion. |
| 41 void OnGetFileInfo(const fileapi::AsyncFileUtil::GetFileInfoCallback& callback, | 41 void OnGetFileInfo(const storage::AsyncFileUtil::GetFileInfoCallback& callback, |
| 42 const EntryMetadata& metadata, | 42 const EntryMetadata& metadata, |
| 43 base::File::Error result) { | 43 base::File::Error result) { |
| 44 base::File::Info file_info; | 44 base::File::Info file_info; |
| 45 | 45 |
| 46 // TODO(mtomasz): Add support for last modified time and creation time. | 46 // TODO(mtomasz): Add support for last modified time and creation time. |
| 47 // See: crbug.com/388540. | 47 // See: crbug.com/388540. |
| 48 file_info.size = metadata.size; | 48 file_info.size = metadata.size; |
| 49 file_info.is_directory = metadata.is_directory; | 49 file_info.is_directory = metadata.is_directory; |
| 50 file_info.is_symbolic_link = false; // Not supported. | 50 file_info.is_symbolic_link = false; // Not supported. |
| 51 file_info.last_modified = metadata.modification_time; | 51 file_info.last_modified = metadata.modification_time; |
| 52 file_info.last_accessed = metadata.modification_time; // Not supported. | 52 file_info.last_accessed = metadata.modification_time; // Not supported. |
| 53 file_info.creation_time = metadata.modification_time; // Not supported. | 53 file_info.creation_time = metadata.modification_time; // Not supported. |
| 54 | 54 |
| 55 BrowserThread::PostTask( | 55 BrowserThread::PostTask( |
| 56 BrowserThread::IO, FROM_HERE, base::Bind(callback, result, file_info)); | 56 BrowserThread::IO, FROM_HERE, base::Bind(callback, result, file_info)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Executes ReadDirectory on the UI thread. | 59 // Executes ReadDirectory on the UI thread. |
| 60 void ReadDirectoryOnUIThread( | 60 void ReadDirectoryOnUIThread( |
| 61 scoped_ptr<fileapi::FileSystemOperationContext> context, | 61 scoped_ptr<storage::FileSystemOperationContext> context, |
| 62 const fileapi::FileSystemURL& url, | 62 const storage::FileSystemURL& url, |
| 63 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) { | 63 const storage::AsyncFileUtil::ReadDirectoryCallback& callback) { |
| 64 util::FileSystemURLParser parser(url); | 64 util::FileSystemURLParser parser(url); |
| 65 if (!parser.Parse()) { | 65 if (!parser.Parse()) { |
| 66 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, | 66 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, |
| 67 fileapi::AsyncFileUtil::EntryList(), | 67 storage::AsyncFileUtil::EntryList(), |
| 68 false /* has_more */); | 68 false /* has_more */); |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 | 71 |
| 72 parser.file_system()->ReadDirectory(parser.file_path(), callback); | 72 parser.file_system()->ReadDirectory(parser.file_path(), callback); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Routes the response of ReadDirectory back to the IO thread. | 75 // Routes the response of ReadDirectory back to the IO thread. |
| 76 void OnReadDirectory( | 76 void OnReadDirectory( |
| 77 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback, | 77 const storage::AsyncFileUtil::ReadDirectoryCallback& callback, |
| 78 base::File::Error result, | 78 base::File::Error result, |
| 79 const fileapi::AsyncFileUtil::EntryList& entry_list, | 79 const storage::AsyncFileUtil::EntryList& entry_list, |
| 80 bool has_more) { | 80 bool has_more) { |
| 81 BrowserThread::PostTask(BrowserThread::IO, | 81 BrowserThread::PostTask(BrowserThread::IO, |
| 82 FROM_HERE, | 82 FROM_HERE, |
| 83 base::Bind(callback, result, entry_list, has_more)); | 83 base::Bind(callback, result, entry_list, has_more)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Executes CreateDirectory on the UI thread. | 86 // Executes CreateDirectory on the UI thread. |
| 87 void CreateDirectoryOnUIThread( | 87 void CreateDirectoryOnUIThread( |
| 88 scoped_ptr<fileapi::FileSystemOperationContext> context, | 88 scoped_ptr<storage::FileSystemOperationContext> context, |
| 89 const fileapi::FileSystemURL& url, | 89 const storage::FileSystemURL& url, |
| 90 bool exclusive, | 90 bool exclusive, |
| 91 bool recursive, | 91 bool recursive, |
| 92 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 92 const storage::AsyncFileUtil::StatusCallback& callback) { |
| 93 util::FileSystemURLParser parser(url); | 93 util::FileSystemURLParser parser(url); |
| 94 if (!parser.Parse()) { | 94 if (!parser.Parse()) { |
| 95 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 95 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 | 98 |
| 99 parser.file_system()->CreateDirectory( | 99 parser.file_system()->CreateDirectory( |
| 100 parser.file_path(), exclusive, recursive, callback); | 100 parser.file_path(), exclusive, recursive, callback); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Routes the response of CreateDirectory back to the IO thread. | 103 // Routes the response of CreateDirectory back to the IO thread. |
| 104 void OnCreateDirectory(const fileapi::AsyncFileUtil::StatusCallback& callback, | 104 void OnCreateDirectory(const storage::AsyncFileUtil::StatusCallback& callback, |
| 105 base::File::Error result) { | 105 base::File::Error result) { |
| 106 BrowserThread::PostTask( | 106 BrowserThread::PostTask( |
| 107 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); | 107 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Executes DeleteEntry on the UI thread. | 110 // Executes DeleteEntry on the UI thread. |
| 111 void DeleteEntryOnUIThread( | 111 void DeleteEntryOnUIThread( |
| 112 scoped_ptr<fileapi::FileSystemOperationContext> context, | 112 scoped_ptr<storage::FileSystemOperationContext> context, |
| 113 const fileapi::FileSystemURL& url, | 113 const storage::FileSystemURL& url, |
| 114 bool recursive, | 114 bool recursive, |
| 115 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 115 const storage::AsyncFileUtil::StatusCallback& callback) { |
| 116 util::FileSystemURLParser parser(url); | 116 util::FileSystemURLParser parser(url); |
| 117 if (!parser.Parse()) { | 117 if (!parser.Parse()) { |
| 118 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 118 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 119 return; | 119 return; |
| 120 } | 120 } |
| 121 | 121 |
| 122 parser.file_system()->DeleteEntry(parser.file_path(), recursive, callback); | 122 parser.file_system()->DeleteEntry(parser.file_path(), recursive, callback); |
| 123 } | 123 } |
| 124 | 124 |
| 125 // Routes the response of DeleteEntry back to the IO thread. | 125 // Routes the response of DeleteEntry back to the IO thread. |
| 126 void OnDeleteEntry(const fileapi::AsyncFileUtil::StatusCallback& callback, | 126 void OnDeleteEntry(const storage::AsyncFileUtil::StatusCallback& callback, |
| 127 base::File::Error result) { | 127 base::File::Error result) { |
| 128 BrowserThread::PostTask( | 128 BrowserThread::PostTask( |
| 129 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); | 129 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 // Executes CreateFile on the UI thread. | 132 // Executes CreateFile on the UI thread. |
| 133 void CreateFileOnUIThread( | 133 void CreateFileOnUIThread( |
| 134 scoped_ptr<fileapi::FileSystemOperationContext> context, | 134 scoped_ptr<storage::FileSystemOperationContext> context, |
| 135 const fileapi::FileSystemURL& url, | 135 const storage::FileSystemURL& url, |
| 136 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 136 const storage::AsyncFileUtil::StatusCallback& callback) { |
| 137 util::FileSystemURLParser parser(url); | 137 util::FileSystemURLParser parser(url); |
| 138 if (!parser.Parse()) { | 138 if (!parser.Parse()) { |
| 139 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 139 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 | 142 |
| 143 parser.file_system()->CreateFile(parser.file_path(), callback); | 143 parser.file_system()->CreateFile(parser.file_path(), callback); |
| 144 } | 144 } |
| 145 | 145 |
| 146 // Routes the response of CreateFile to a callback of EnsureFileExists() on the | 146 // Routes the response of CreateFile to a callback of EnsureFileExists() on the |
| 147 // IO thread. | 147 // IO thread. |
| 148 void OnCreateFileForEnsureFileExists( | 148 void OnCreateFileForEnsureFileExists( |
| 149 const fileapi::AsyncFileUtil::EnsureFileExistsCallback& callback, | 149 const storage::AsyncFileUtil::EnsureFileExistsCallback& callback, |
| 150 base::File::Error result) { | 150 base::File::Error result) { |
| 151 const bool created = result == base::File::FILE_OK; | 151 const bool created = result == base::File::FILE_OK; |
| 152 | 152 |
| 153 // If the file already existed, then return success anyway, since it is not | 153 // If the file already existed, then return success anyway, since it is not |
| 154 // an error. | 154 // an error. |
| 155 const base::File::Error error = | 155 const base::File::Error error = |
| 156 result == base::File::FILE_ERROR_EXISTS ? base::File::FILE_OK : result; | 156 result == base::File::FILE_ERROR_EXISTS ? base::File::FILE_OK : result; |
| 157 | 157 |
| 158 BrowserThread::PostTask( | 158 BrowserThread::PostTask( |
| 159 BrowserThread::IO, FROM_HERE, base::Bind(callback, error, created)); | 159 BrowserThread::IO, FROM_HERE, base::Bind(callback, error, created)); |
| 160 } | 160 } |
| 161 | 161 |
| 162 // Executes CopyEntry on the UI thread. | 162 // Executes CopyEntry on the UI thread. |
| 163 void CopyEntryOnUIThread( | 163 void CopyEntryOnUIThread( |
| 164 scoped_ptr<fileapi::FileSystemOperationContext> context, | 164 scoped_ptr<storage::FileSystemOperationContext> context, |
| 165 const fileapi::FileSystemURL& source_url, | 165 const storage::FileSystemURL& source_url, |
| 166 const fileapi::FileSystemURL& target_url, | 166 const storage::FileSystemURL& target_url, |
| 167 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 167 const storage::AsyncFileUtil::StatusCallback& callback) { |
| 168 util::FileSystemURLParser source_parser(source_url); | 168 util::FileSystemURLParser source_parser(source_url); |
| 169 util::FileSystemURLParser target_parser(target_url); | 169 util::FileSystemURLParser target_parser(target_url); |
| 170 | 170 |
| 171 if (!source_parser.Parse() || !target_parser.Parse() || | 171 if (!source_parser.Parse() || !target_parser.Parse() || |
| 172 source_parser.file_system() != target_parser.file_system()) { | 172 source_parser.file_system() != target_parser.file_system()) { |
| 173 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 173 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 | 176 |
| 177 target_parser.file_system()->CopyEntry( | 177 target_parser.file_system()->CopyEntry( |
| 178 source_parser.file_path(), target_parser.file_path(), callback); | 178 source_parser.file_path(), target_parser.file_path(), callback); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Routes the response of CopyEntry to a callback of CopyLocalFile() on the | 181 // Routes the response of CopyEntry to a callback of CopyLocalFile() on the |
| 182 // IO thread. | 182 // IO thread. |
| 183 void OnCopyEntry(const fileapi::AsyncFileUtil::StatusCallback& callback, | 183 void OnCopyEntry(const storage::AsyncFileUtil::StatusCallback& callback, |
| 184 base::File::Error result) { | 184 base::File::Error result) { |
| 185 BrowserThread::PostTask( | 185 BrowserThread::PostTask( |
| 186 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); | 186 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); |
| 187 } | 187 } |
| 188 | 188 |
| 189 // Executes MoveEntry on the UI thread. | 189 // Executes MoveEntry on the UI thread. |
| 190 void MoveEntryOnUIThread( | 190 void MoveEntryOnUIThread( |
| 191 scoped_ptr<fileapi::FileSystemOperationContext> context, | 191 scoped_ptr<storage::FileSystemOperationContext> context, |
| 192 const fileapi::FileSystemURL& source_url, | 192 const storage::FileSystemURL& source_url, |
| 193 const fileapi::FileSystemURL& target_url, | 193 const storage::FileSystemURL& target_url, |
| 194 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 194 const storage::AsyncFileUtil::StatusCallback& callback) { |
| 195 util::FileSystemURLParser source_parser(source_url); | 195 util::FileSystemURLParser source_parser(source_url); |
| 196 util::FileSystemURLParser target_parser(target_url); | 196 util::FileSystemURLParser target_parser(target_url); |
| 197 | 197 |
| 198 if (!source_parser.Parse() || !target_parser.Parse() || | 198 if (!source_parser.Parse() || !target_parser.Parse() || |
| 199 source_parser.file_system() != target_parser.file_system()) { | 199 source_parser.file_system() != target_parser.file_system()) { |
| 200 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 200 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 201 return; | 201 return; |
| 202 } | 202 } |
| 203 | 203 |
| 204 target_parser.file_system()->MoveEntry( | 204 target_parser.file_system()->MoveEntry( |
| 205 source_parser.file_path(), target_parser.file_path(), callback); | 205 source_parser.file_path(), target_parser.file_path(), callback); |
| 206 } | 206 } |
| 207 | 207 |
| 208 // Routes the response of CopyEntry to a callback of MoveLocalFile() on the | 208 // Routes the response of CopyEntry to a callback of MoveLocalFile() on the |
| 209 // IO thread. | 209 // IO thread. |
| 210 void OnMoveEntry(const fileapi::AsyncFileUtil::StatusCallback& callback, | 210 void OnMoveEntry(const storage::AsyncFileUtil::StatusCallback& callback, |
| 211 base::File::Error result) { | 211 base::File::Error result) { |
| 212 BrowserThread::PostTask( | 212 BrowserThread::PostTask( |
| 213 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); | 213 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Executes Truncate on the UI thread. | 216 // Executes Truncate on the UI thread. |
| 217 void TruncateOnUIThread( | 217 void TruncateOnUIThread( |
| 218 scoped_ptr<fileapi::FileSystemOperationContext> context, | 218 scoped_ptr<storage::FileSystemOperationContext> context, |
| 219 const fileapi::FileSystemURL& url, | 219 const storage::FileSystemURL& url, |
| 220 int64 length, | 220 int64 length, |
| 221 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 221 const storage::AsyncFileUtil::StatusCallback& callback) { |
| 222 util::FileSystemURLParser parser(url); | 222 util::FileSystemURLParser parser(url); |
| 223 if (!parser.Parse()) { | 223 if (!parser.Parse()) { |
| 224 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 224 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 225 return; | 225 return; |
| 226 } | 226 } |
| 227 | 227 |
| 228 parser.file_system()->Truncate(parser.file_path(), length, callback); | 228 parser.file_system()->Truncate(parser.file_path(), length, callback); |
| 229 } | 229 } |
| 230 | 230 |
| 231 // Routes the response of Truncate back to the IO thread. | 231 // Routes the response of Truncate back to the IO thread. |
| 232 void OnTruncate(const fileapi::AsyncFileUtil::StatusCallback& callback, | 232 void OnTruncate(const storage::AsyncFileUtil::StatusCallback& callback, |
| 233 base::File::Error result) { | 233 base::File::Error result) { |
| 234 BrowserThread::PostTask( | 234 BrowserThread::PostTask( |
| 235 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); | 235 BrowserThread::IO, FROM_HERE, base::Bind(callback, result)); |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace | 238 } // namespace |
| 239 | 239 |
| 240 ProviderAsyncFileUtil::ProviderAsyncFileUtil() {} | 240 ProviderAsyncFileUtil::ProviderAsyncFileUtil() {} |
| 241 | 241 |
| 242 ProviderAsyncFileUtil::~ProviderAsyncFileUtil() {} | 242 ProviderAsyncFileUtil::~ProviderAsyncFileUtil() {} |
| 243 | 243 |
| 244 void ProviderAsyncFileUtil::CreateOrOpen( | 244 void ProviderAsyncFileUtil::CreateOrOpen( |
| 245 scoped_ptr<fileapi::FileSystemOperationContext> context, | 245 scoped_ptr<storage::FileSystemOperationContext> context, |
| 246 const fileapi::FileSystemURL& url, | 246 const storage::FileSystemURL& url, |
| 247 int file_flags, | 247 int file_flags, |
| 248 const CreateOrOpenCallback& callback) { | 248 const CreateOrOpenCallback& callback) { |
| 249 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 249 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 250 if ((file_flags & base::File::FLAG_CREATE) || | 250 if ((file_flags & base::File::FLAG_CREATE) || |
| 251 (file_flags & base::File::FLAG_OPEN_ALWAYS) || | 251 (file_flags & base::File::FLAG_OPEN_ALWAYS) || |
| 252 (file_flags & base::File::FLAG_CREATE_ALWAYS) || | 252 (file_flags & base::File::FLAG_CREATE_ALWAYS) || |
| 253 (file_flags & base::File::FLAG_OPEN_TRUNCATED)) { | 253 (file_flags & base::File::FLAG_OPEN_TRUNCATED)) { |
| 254 callback.Run(base::File(base::File::FILE_ERROR_ACCESS_DENIED), | 254 callback.Run(base::File(base::File::FILE_ERROR_ACCESS_DENIED), |
| 255 base::Closure()); | 255 base::Closure()); |
| 256 return; | 256 return; |
| 257 } | 257 } |
| 258 | 258 |
| 259 NOTIMPLEMENTED(); | 259 NOTIMPLEMENTED(); |
| 260 callback.Run(base::File(base::File::FILE_ERROR_INVALID_OPERATION), | 260 callback.Run(base::File(base::File::FILE_ERROR_INVALID_OPERATION), |
| 261 base::Closure()); | 261 base::Closure()); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void ProviderAsyncFileUtil::EnsureFileExists( | 264 void ProviderAsyncFileUtil::EnsureFileExists( |
| 265 scoped_ptr<fileapi::FileSystemOperationContext> context, | 265 scoped_ptr<storage::FileSystemOperationContext> context, |
| 266 const fileapi::FileSystemURL& url, | 266 const storage::FileSystemURL& url, |
| 267 const EnsureFileExistsCallback& callback) { | 267 const EnsureFileExistsCallback& callback) { |
| 268 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 268 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 269 BrowserThread::PostTask( | 269 BrowserThread::PostTask( |
| 270 BrowserThread::UI, | 270 BrowserThread::UI, |
| 271 FROM_HERE, | 271 FROM_HERE, |
| 272 base::Bind(&CreateFileOnUIThread, | 272 base::Bind(&CreateFileOnUIThread, |
| 273 base::Passed(&context), | 273 base::Passed(&context), |
| 274 url, | 274 url, |
| 275 base::Bind(&OnCreateFileForEnsureFileExists, callback))); | 275 base::Bind(&OnCreateFileForEnsureFileExists, callback))); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void ProviderAsyncFileUtil::CreateDirectory( | 278 void ProviderAsyncFileUtil::CreateDirectory( |
| 279 scoped_ptr<fileapi::FileSystemOperationContext> context, | 279 scoped_ptr<storage::FileSystemOperationContext> context, |
| 280 const fileapi::FileSystemURL& url, | 280 const storage::FileSystemURL& url, |
| 281 bool exclusive, | 281 bool exclusive, |
| 282 bool recursive, | 282 bool recursive, |
| 283 const StatusCallback& callback) { | 283 const StatusCallback& callback) { |
| 284 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 284 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 285 BrowserThread::PostTask(BrowserThread::UI, | 285 BrowserThread::PostTask(BrowserThread::UI, |
| 286 FROM_HERE, | 286 FROM_HERE, |
| 287 base::Bind(&CreateDirectoryOnUIThread, | 287 base::Bind(&CreateDirectoryOnUIThread, |
| 288 base::Passed(&context), | 288 base::Passed(&context), |
| 289 url, | 289 url, |
| 290 exclusive, | 290 exclusive, |
| 291 recursive, | 291 recursive, |
| 292 base::Bind(&OnCreateDirectory, callback))); | 292 base::Bind(&OnCreateDirectory, callback))); |
| 293 } | 293 } |
| 294 | 294 |
| 295 void ProviderAsyncFileUtil::GetFileInfo( | 295 void ProviderAsyncFileUtil::GetFileInfo( |
| 296 scoped_ptr<fileapi::FileSystemOperationContext> context, | 296 scoped_ptr<storage::FileSystemOperationContext> context, |
| 297 const fileapi::FileSystemURL& url, | 297 const storage::FileSystemURL& url, |
| 298 const GetFileInfoCallback& callback) { | 298 const GetFileInfoCallback& callback) { |
| 299 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 299 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 300 BrowserThread::PostTask(BrowserThread::UI, | 300 BrowserThread::PostTask(BrowserThread::UI, |
| 301 FROM_HERE, | 301 FROM_HERE, |
| 302 base::Bind(&GetFileInfoOnUIThread, | 302 base::Bind(&GetFileInfoOnUIThread, |
| 303 base::Passed(&context), | 303 base::Passed(&context), |
| 304 url, | 304 url, |
| 305 base::Bind(&OnGetFileInfo, callback))); | 305 base::Bind(&OnGetFileInfo, callback))); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void ProviderAsyncFileUtil::ReadDirectory( | 308 void ProviderAsyncFileUtil::ReadDirectory( |
| 309 scoped_ptr<fileapi::FileSystemOperationContext> context, | 309 scoped_ptr<storage::FileSystemOperationContext> context, |
| 310 const fileapi::FileSystemURL& url, | 310 const storage::FileSystemURL& url, |
| 311 const ReadDirectoryCallback& callback) { | 311 const ReadDirectoryCallback& callback) { |
| 312 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 312 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 313 BrowserThread::PostTask(BrowserThread::UI, | 313 BrowserThread::PostTask(BrowserThread::UI, |
| 314 FROM_HERE, | 314 FROM_HERE, |
| 315 base::Bind(&ReadDirectoryOnUIThread, | 315 base::Bind(&ReadDirectoryOnUIThread, |
| 316 base::Passed(&context), | 316 base::Passed(&context), |
| 317 url, | 317 url, |
| 318 base::Bind(&OnReadDirectory, callback))); | 318 base::Bind(&OnReadDirectory, callback))); |
| 319 } | 319 } |
| 320 | 320 |
| 321 void ProviderAsyncFileUtil::Touch( | 321 void ProviderAsyncFileUtil::Touch( |
| 322 scoped_ptr<fileapi::FileSystemOperationContext> context, | 322 scoped_ptr<storage::FileSystemOperationContext> context, |
| 323 const fileapi::FileSystemURL& url, | 323 const storage::FileSystemURL& url, |
| 324 const base::Time& last_access_time, | 324 const base::Time& last_access_time, |
| 325 const base::Time& last_modified_time, | 325 const base::Time& last_modified_time, |
| 326 const StatusCallback& callback) { | 326 const StatusCallback& callback) { |
| 327 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 327 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 328 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED); | 328 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED); |
| 329 } | 329 } |
| 330 | 330 |
| 331 void ProviderAsyncFileUtil::Truncate( | 331 void ProviderAsyncFileUtil::Truncate( |
| 332 scoped_ptr<fileapi::FileSystemOperationContext> context, | 332 scoped_ptr<storage::FileSystemOperationContext> context, |
| 333 const fileapi::FileSystemURL& url, | 333 const storage::FileSystemURL& url, |
| 334 int64 length, | 334 int64 length, |
| 335 const StatusCallback& callback) { | 335 const StatusCallback& callback) { |
| 336 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 336 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 337 BrowserThread::PostTask(BrowserThread::UI, | 337 BrowserThread::PostTask(BrowserThread::UI, |
| 338 FROM_HERE, | 338 FROM_HERE, |
| 339 base::Bind(&TruncateOnUIThread, | 339 base::Bind(&TruncateOnUIThread, |
| 340 base::Passed(&context), | 340 base::Passed(&context), |
| 341 url, | 341 url, |
| 342 length, | 342 length, |
| 343 base::Bind(&OnTruncate, callback))); | 343 base::Bind(&OnTruncate, callback))); |
| 344 } | 344 } |
| 345 | 345 |
| 346 void ProviderAsyncFileUtil::CopyFileLocal( | 346 void ProviderAsyncFileUtil::CopyFileLocal( |
| 347 scoped_ptr<fileapi::FileSystemOperationContext> context, | 347 scoped_ptr<storage::FileSystemOperationContext> context, |
| 348 const fileapi::FileSystemURL& src_url, | 348 const storage::FileSystemURL& src_url, |
| 349 const fileapi::FileSystemURL& dest_url, | 349 const storage::FileSystemURL& dest_url, |
| 350 CopyOrMoveOption option, | 350 CopyOrMoveOption option, |
| 351 const CopyFileProgressCallback& progress_callback, | 351 const CopyFileProgressCallback& progress_callback, |
| 352 const StatusCallback& callback) { | 352 const StatusCallback& callback) { |
| 353 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 353 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 354 // TODO(mtomasz): Consier adding support for options (preserving last modified | 354 // TODO(mtomasz): Consier adding support for options (preserving last modified |
| 355 // time) as well as the progress callback. | 355 // time) as well as the progress callback. |
| 356 BrowserThread::PostTask(BrowserThread::UI, | 356 BrowserThread::PostTask(BrowserThread::UI, |
| 357 FROM_HERE, | 357 FROM_HERE, |
| 358 base::Bind(&CopyEntryOnUIThread, | 358 base::Bind(&CopyEntryOnUIThread, |
| 359 base::Passed(&context), | 359 base::Passed(&context), |
| 360 src_url, | 360 src_url, |
| 361 dest_url, | 361 dest_url, |
| 362 base::Bind(&OnCopyEntry, callback))); | 362 base::Bind(&OnCopyEntry, callback))); |
| 363 } | 363 } |
| 364 | 364 |
| 365 void ProviderAsyncFileUtil::MoveFileLocal( | 365 void ProviderAsyncFileUtil::MoveFileLocal( |
| 366 scoped_ptr<fileapi::FileSystemOperationContext> context, | 366 scoped_ptr<storage::FileSystemOperationContext> context, |
| 367 const fileapi::FileSystemURL& src_url, | 367 const storage::FileSystemURL& src_url, |
| 368 const fileapi::FileSystemURL& dest_url, | 368 const storage::FileSystemURL& dest_url, |
| 369 CopyOrMoveOption option, | 369 CopyOrMoveOption option, |
| 370 const StatusCallback& callback) { | 370 const StatusCallback& callback) { |
| 371 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 371 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 372 // TODO(mtomasz): Consier adding support for options (preserving last modified | 372 // TODO(mtomasz): Consier adding support for options (preserving last modified |
| 373 // time) as well as the progress callback. | 373 // time) as well as the progress callback. |
| 374 BrowserThread::PostTask(BrowserThread::UI, | 374 BrowserThread::PostTask(BrowserThread::UI, |
| 375 FROM_HERE, | 375 FROM_HERE, |
| 376 base::Bind(&MoveEntryOnUIThread, | 376 base::Bind(&MoveEntryOnUIThread, |
| 377 base::Passed(&context), | 377 base::Passed(&context), |
| 378 src_url, | 378 src_url, |
| 379 dest_url, | 379 dest_url, |
| 380 base::Bind(&OnMoveEntry, callback))); | 380 base::Bind(&OnMoveEntry, callback))); |
| 381 } | 381 } |
| 382 | 382 |
| 383 void ProviderAsyncFileUtil::CopyInForeignFile( | 383 void ProviderAsyncFileUtil::CopyInForeignFile( |
| 384 scoped_ptr<fileapi::FileSystemOperationContext> context, | 384 scoped_ptr<storage::FileSystemOperationContext> context, |
| 385 const base::FilePath& src_file_path, | 385 const base::FilePath& src_file_path, |
| 386 const fileapi::FileSystemURL& dest_url, | 386 const storage::FileSystemURL& dest_url, |
| 387 const StatusCallback& callback) { | 387 const StatusCallback& callback) { |
| 388 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 388 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 389 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED); | 389 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED); |
| 390 } | 390 } |
| 391 | 391 |
| 392 void ProviderAsyncFileUtil::DeleteFile( | 392 void ProviderAsyncFileUtil::DeleteFile( |
| 393 scoped_ptr<fileapi::FileSystemOperationContext> context, | 393 scoped_ptr<storage::FileSystemOperationContext> context, |
| 394 const fileapi::FileSystemURL& url, | 394 const storage::FileSystemURL& url, |
| 395 const StatusCallback& callback) { | 395 const StatusCallback& callback) { |
| 396 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 396 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 397 BrowserThread::PostTask(BrowserThread::UI, | 397 BrowserThread::PostTask(BrowserThread::UI, |
| 398 FROM_HERE, | 398 FROM_HERE, |
| 399 base::Bind(&DeleteEntryOnUIThread, | 399 base::Bind(&DeleteEntryOnUIThread, |
| 400 base::Passed(&context), | 400 base::Passed(&context), |
| 401 url, | 401 url, |
| 402 false, // recursive | 402 false, // recursive |
| 403 base::Bind(&OnDeleteEntry, callback))); | 403 base::Bind(&OnDeleteEntry, callback))); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void ProviderAsyncFileUtil::DeleteDirectory( | 406 void ProviderAsyncFileUtil::DeleteDirectory( |
| 407 scoped_ptr<fileapi::FileSystemOperationContext> context, | 407 scoped_ptr<storage::FileSystemOperationContext> context, |
| 408 const fileapi::FileSystemURL& url, | 408 const storage::FileSystemURL& url, |
| 409 const StatusCallback& callback) { | 409 const StatusCallback& callback) { |
| 410 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 410 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 411 BrowserThread::PostTask(BrowserThread::UI, | 411 BrowserThread::PostTask(BrowserThread::UI, |
| 412 FROM_HERE, | 412 FROM_HERE, |
| 413 base::Bind(&DeleteEntryOnUIThread, | 413 base::Bind(&DeleteEntryOnUIThread, |
| 414 base::Passed(&context), | 414 base::Passed(&context), |
| 415 url, | 415 url, |
| 416 false, // recursive | 416 false, // recursive |
| 417 base::Bind(&OnDeleteEntry, callback))); | 417 base::Bind(&OnDeleteEntry, callback))); |
| 418 } | 418 } |
| 419 | 419 |
| 420 void ProviderAsyncFileUtil::DeleteRecursively( | 420 void ProviderAsyncFileUtil::DeleteRecursively( |
| 421 scoped_ptr<fileapi::FileSystemOperationContext> context, | 421 scoped_ptr<storage::FileSystemOperationContext> context, |
| 422 const fileapi::FileSystemURL& url, | 422 const storage::FileSystemURL& url, |
| 423 const StatusCallback& callback) { | 423 const StatusCallback& callback) { |
| 424 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 424 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 425 BrowserThread::PostTask(BrowserThread::UI, | 425 BrowserThread::PostTask(BrowserThread::UI, |
| 426 FROM_HERE, | 426 FROM_HERE, |
| 427 base::Bind(&DeleteEntryOnUIThread, | 427 base::Bind(&DeleteEntryOnUIThread, |
| 428 base::Passed(&context), | 428 base::Passed(&context), |
| 429 url, | 429 url, |
| 430 true, // recursive | 430 true, // recursive |
| 431 base::Bind(&OnDeleteEntry, callback))); | 431 base::Bind(&OnDeleteEntry, callback))); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void ProviderAsyncFileUtil::CreateSnapshotFile( | 434 void ProviderAsyncFileUtil::CreateSnapshotFile( |
| 435 scoped_ptr<fileapi::FileSystemOperationContext> context, | 435 scoped_ptr<storage::FileSystemOperationContext> context, |
| 436 const fileapi::FileSystemURL& url, | 436 const storage::FileSystemURL& url, |
| 437 const CreateSnapshotFileCallback& callback) { | 437 const CreateSnapshotFileCallback& callback) { |
| 438 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 438 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 439 NOTIMPLEMENTED(); | 439 NOTIMPLEMENTED(); |
| 440 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, | 440 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, |
| 441 base::File::Info(), | 441 base::File::Info(), |
| 442 base::FilePath(), | 442 base::FilePath(), |
| 443 scoped_refptr<webkit_blob::ShareableFileReference>()); | 443 scoped_refptr<storage::ShareableFileReference>()); |
| 444 } | 444 } |
| 445 | 445 |
| 446 } // namespace internal | 446 } // namespace internal |
| 447 } // namespace file_system_provider | 447 } // namespace file_system_provider |
| 448 } // namespace chromeos | 448 } // namespace chromeos |
| OLD | NEW |