| 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 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // mkdir -p does. | 132 // mkdir -p does. |
| 133 virtual void CreateDirectory(const FileSystemURL& path, | 133 virtual void CreateDirectory(const FileSystemURL& path, |
| 134 bool exclusive, | 134 bool exclusive, |
| 135 bool recursive, | 135 bool recursive, |
| 136 const StatusCallback& callback) = 0; | 136 const StatusCallback& callback) = 0; |
| 137 | 137 |
| 138 // Copies a file or directory from |src_path| to |dest_path|. If | 138 // Copies a file or directory from |src_path| to |dest_path|. If |
| 139 // |src_path| is a directory, the contents of |src_path| are copied to | 139 // |src_path| is a directory, the contents of |src_path| are copied to |
| 140 // |dest_path| recursively. A new file or directory is created at | 140 // |dest_path| recursively. A new file or directory is created at |
| 141 // |dest_path| as needed. | 141 // |dest_path| as needed. |
| 142 // |
| 143 // For recursive case this internally creates new FileSystemOperations and |
| 144 // calls: |
| 145 // - ReadDirectory, CopyFileLocal and CreateDirectory |
| 146 // for same-filesystem case, or |
| 147 // - ReadDirectory and CreateSnapshotFile on source filesystem and |
| 148 // CopyInForeignFile and CreateDirectory on dest filesystem |
| 149 // for cross-filesystem case. |
| 150 // |
| 142 virtual void Copy(const FileSystemURL& src_path, | 151 virtual void Copy(const FileSystemURL& src_path, |
| 143 const FileSystemURL& dest_path, | 152 const FileSystemURL& dest_path, |
| 144 const StatusCallback& callback) = 0; | 153 const StatusCallback& callback) = 0; |
| 145 | 154 |
| 146 // Moves a file or directory from |src_path| to |dest_path|. A new file | 155 // Moves a file or directory from |src_path| to |dest_path|. A new file |
| 147 // or directory is created at |dest_path| as needed. | 156 // or directory is created at |dest_path| as needed. |
| 157 // |
| 158 // For recursive case this internally creates new FileSystemOperations and |
| 159 // calls: |
| 160 // - ReadDirectory, MoveFileLocal, CreateDirectory and Remove |
| 161 // for same-filesystem case, or |
| 162 // - ReadDirectory, CreateSnapshotFile and Remove on source filesystem and |
| 163 // CopyInForeignFile and CreateDirectory on dest filesystem |
| 164 // for cross-filesystem case. |
| 165 // |
| 148 virtual void Move(const FileSystemURL& src_path, | 166 virtual void Move(const FileSystemURL& src_path, |
| 149 const FileSystemURL& dest_path, | 167 const FileSystemURL& dest_path, |
| 150 const StatusCallback& callback) = 0; | 168 const StatusCallback& callback) = 0; |
| 151 | 169 |
| 152 // Checks if a directory is present at |path|. | 170 // Checks if a directory is present at |path|. |
| 153 virtual void DirectoryExists(const FileSystemURL& path, | 171 virtual void DirectoryExists(const FileSystemURL& path, |
| 154 const StatusCallback& callback) = 0; | 172 const StatusCallback& callback) = 0; |
| 155 | 173 |
| 156 // Checks if a file is present at |path|. | 174 // Checks if a file is present at |path|. |
| 157 virtual void FileExists(const FileSystemURL& path, | 175 virtual void FileExists(const FileSystemURL& path, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // | 241 // |
| 224 // |peer_handle| is the process handle of a pepper plugin process, which | 242 // |peer_handle| is the process handle of a pepper plugin process, which |
| 225 // is necessary for underlying IPC calls with Pepper plugins. | 243 // is necessary for underlying IPC calls with Pepper plugins. |
| 226 // | 244 // |
| 227 // This function is used only by Pepper as of writing. | 245 // This function is used only by Pepper as of writing. |
| 228 virtual void OpenFile(const FileSystemURL& path, | 246 virtual void OpenFile(const FileSystemURL& path, |
| 229 int file_flags, | 247 int file_flags, |
| 230 base::ProcessHandle peer_handle, | 248 base::ProcessHandle peer_handle, |
| 231 const OpenFileCallback& callback) = 0; | 249 const OpenFileCallback& callback) = 0; |
| 232 | 250 |
| 233 // For downcasting to FileSystemOperationImpl. | |
| 234 // TODO(kinuko): this hack should go away once appropriate upload-stream | |
| 235 // handling based on element types is supported. | |
| 236 virtual FileSystemOperationImpl* AsFileSystemOperationImpl() = 0; | |
| 237 | |
| 238 // Creates a local snapshot file for a given |path| and returns the | 251 // Creates a local snapshot file for a given |path| and returns the |
| 239 // metadata and platform path of the snapshot file via |callback|. | 252 // metadata and platform path of the snapshot file via |callback|. |
| 240 // In local filesystem cases the implementation may simply return | 253 // In local filesystem cases the implementation may simply return |
| 241 // the metadata of the file itself (as well as GetMetadata does), | 254 // the metadata of the file itself (as well as GetMetadata does), |
| 242 // while in remote filesystem case the backend may want to download the file | 255 // while in remote filesystem case the backend may want to download the file |
| 243 // into a temporary snapshot file and return the metadata of the | 256 // into a temporary snapshot file and return the metadata of the |
| 244 // temporary file. Or if the implementaiton already has the local cache | 257 // temporary file. Or if the implementaiton already has the local cache |
| 245 // data for |path| it can simply return the path to the cache. | 258 // data for |path| it can simply return the path to the cache. |
| 246 virtual void CreateSnapshotFile(const FileSystemURL& path, | 259 virtual void CreateSnapshotFile(const FileSystemURL& path, |
| 247 const SnapshotFileCallback& callback) = 0; | 260 const SnapshotFileCallback& callback) = 0; |
| 248 | 261 |
| 262 // Copies in a single file from a different filesystem. |
| 263 // |
| 264 // This returns: |
| 265 // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_file_path| |
| 266 // or the parent directory of |dest_url| does not exist. |
| 267 // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and |
| 268 // is not a file. |
| 269 // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and |
| 270 // its parent path is a file. |
| 271 // |
| 272 virtual void CopyInForeignFile(const base::FilePath& src_local_disk_path, |
| 273 const FileSystemURL& dest_url, |
| 274 const StatusCallback& callback) = 0; |
| 275 |
| 276 // Removes a single file. |
| 277 // |
| 278 // This returns: |
| 279 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. |
| 280 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| is not a file. |
| 281 // |
| 282 virtual void RemoveFile(const FileSystemURL& url, |
| 283 const StatusCallback& callback) = 0; |
| 284 |
| 285 // Removes a single empty directory. |
| 286 // |
| 287 // This returns: |
| 288 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. |
| 289 // - PLATFORM_FILE_ERROR_NOT_A_DIRECTORY if |url| is not a directory. |
| 290 // - PLATFORM_FILE_ERROR_NOT_EMPTY if |url| is not empty. |
| 291 // |
| 292 virtual void RemoveDirectory(const FileSystemURL& url, |
| 293 const StatusCallback& callback) = 0; |
| 294 |
| 295 // Copies a file from |src_url| to |dest_url|. |
| 296 // This must be called for files that belong to the same filesystem |
| 297 // (i.e. type() and origin() of the |src_url| and |dest_url| must match). |
| 298 // |
| 299 // This returns: |
| 300 // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url| |
| 301 // or the parent directory of |dest_url| does not exist. |
| 302 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file. |
| 303 // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and |
| 304 // is not a file. |
| 305 // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and |
| 306 // its parent path is a file. |
| 307 // |
| 308 virtual void CopyFileLocal(const FileSystemURL& src_url, |
| 309 const FileSystemURL& dest_url, |
| 310 const StatusCallback& callback) = 0; |
| 311 |
| 312 // Moves a local file from |src_url| to |dest_url|. |
| 313 // This must be called for files that belong to the same filesystem |
| 314 // (i.e. type() and origin() of the |src_url| and |dest_url| must match). |
| 315 // |
| 316 // This returns: |
| 317 // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url| |
| 318 // or the parent directory of |dest_url| does not exist. |
| 319 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file. |
| 320 // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and |
| 321 // is not a file. |
| 322 // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and |
| 323 // its parent path is a file. |
| 324 // |
| 325 virtual void MoveFileLocal(const FileSystemURL& src_url, |
| 326 const FileSystemURL& dest_url, |
| 327 const StatusCallback& callback) = 0; |
| 328 |
| 329 // Synchronously gets the platform path for the given |url|. |
| 330 // This may fail if |file_system_context| returns NULL on GetFileUtil(). |
| 331 // In such a case, base::PLATFORM_FILE_ERROR_INVALID_OPERATION will be |
| 332 // returned. |
| 333 virtual base::PlatformFileError SyncGetPlatformPath( |
| 334 const FileSystemURL& url, |
| 335 base::FilePath* platform_path) = 0; |
| 336 |
| 249 protected: | 337 protected: |
| 250 // Used only for internal assertions. | 338 // Used only for internal assertions. |
| 251 enum OperationType { | 339 enum OperationType { |
| 252 kOperationNone, | 340 kOperationNone, |
| 253 kOperationCreateFile, | 341 kOperationCreateFile, |
| 254 kOperationCreateDirectory, | 342 kOperationCreateDirectory, |
| 255 kOperationCreateSnapshotFile, | 343 kOperationCreateSnapshotFile, |
| 256 kOperationCopy, | 344 kOperationCopy, |
| 257 kOperationCopyInForeignFile, | 345 kOperationCopyInForeignFile, |
| 258 kOperationMove, | 346 kOperationMove, |
| 259 kOperationDirectoryExists, | 347 kOperationDirectoryExists, |
| 260 kOperationFileExists, | 348 kOperationFileExists, |
| 261 kOperationGetMetadata, | 349 kOperationGetMetadata, |
| 262 kOperationReadDirectory, | 350 kOperationReadDirectory, |
| 263 kOperationRemove, | 351 kOperationRemove, |
| 264 kOperationWrite, | 352 kOperationWrite, |
| 265 kOperationTruncate, | 353 kOperationTruncate, |
| 266 kOperationTouchFile, | 354 kOperationTouchFile, |
| 267 kOperationOpenFile, | 355 kOperationOpenFile, |
| 268 kOperationCloseFile, | 356 kOperationCloseFile, |
| 269 kOperationGetLocalPath, | 357 kOperationGetLocalPath, |
| 270 kOperationCancel, | 358 kOperationCancel, |
| 271 }; | 359 }; |
| 272 }; | 360 }; |
| 273 | 361 |
| 274 } // namespace fileapi | 362 } // namespace fileapi |
| 275 | 363 |
| 276 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 364 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
| OLD | NEW |