diff options
Diffstat (limited to 'webkit/fileapi/file_system_file_util.h')
-rw-r--r-- | webkit/fileapi/file_system_file_util.h | 98 |
1 files changed, 21 insertions, 77 deletions
diff --git a/webkit/fileapi/file_system_file_util.h b/webkit/fileapi/file_system_file_util.h index 8c05c1d7..5d4b72c 100644 --- a/webkit/fileapi/file_system_file_util.h +++ b/webkit/fileapi/file_system_file_util.h @@ -8,20 +8,17 @@ #include "base/file_path.h" #include "base/memory/scoped_ptr.h" #include "base/platform_file.h" -#include "webkit/fileapi/file_system_url.h" +#include "webkit/fileapi/file_snapshot_policy.h" #include "webkit/storage/webkit_storage_export.h" namespace base { class Time; } -namespace webkit_blob { -class ShareableFileReference; -} - namespace fileapi { class FileSystemOperationContext; +class FileSystemURL; // A file utility interface that provides basic file utility methods for // FileSystem API. @@ -47,20 +44,6 @@ class WEBKIT_STORAGE_EXPORT FileSystemFileUtil { virtual bool IsDirectory() = 0; }; - // A policy flag for CreateSnapshotFile. - enum SnapshotFilePolicy { - kSnapshotFileUnknown, - - // The implementation just uses the local file as the snapshot file. - // The FileAPI backend does nothing on the returned file. - kSnapshotFileLocal, - - // The implementation returns a temporary file as the snapshot file. - // The FileAPI backend takes care of the lifetime of the returned file - // and will delete when the last reference of the file is dropped. - kSnapshotFileTemporary, - }; - class WEBKIT_STORAGE_EXPORT EmptyFileEnumerator : public AbstractFileEnumerator { virtual FilePath Next() OVERRIDE; @@ -72,11 +55,8 @@ class WEBKIT_STORAGE_EXPORT FileSystemFileUtil { virtual ~FileSystemFileUtil() {} // Creates or opens a file with the given flags. - // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create - // a new file at the given |url| and calls back with - // PLATFORM_FILE_ERROR_FILE_EXISTS if the |url| already exists. - // - // This is used only for Pepper/NaCL File API. + // See header comments for AsyncFileUtil::CreateOrOpen() for more details. + // This is used only by Pepper/NaCL File API. virtual base::PlatformFileError CreateOrOpen( FileSystemOperationContext* context, const FileSystemURL& url, @@ -85,7 +65,6 @@ class WEBKIT_STORAGE_EXPORT FileSystemFileUtil { bool* created) = 0; // Closes the given file handle. - // // This is used only for Pepper/NaCL File API. virtual base::PlatformFileError Close( FileSystemOperationContext* context, @@ -93,19 +72,13 @@ class WEBKIT_STORAGE_EXPORT FileSystemFileUtil { // Ensures that the given |url| exist. This creates a empty new file // at |url| if the |url| does not exist. - // If a new file han not existed and is created at the |url|, - // |created| is set true and |error code| - // is set PLATFORM_FILE_OK. - // If the file already exists, |created| is set false and |error code| - // is set PLATFORM_FILE_OK. - // If the file hasn't existed but it couldn't be created for some other - // reasons, |created| is set false and |error code| indicates the error. + // See header comments for AsyncFileUtil::EnsureFileExists() for more details. virtual base::PlatformFileError EnsureFileExists( FileSystemOperationContext* context, const FileSystemURL& url, bool* created) = 0; - // Creates directory at given url. It's an error to create - // if |exclusive| is true and dir already exists. + // Creates directory at given url. + // See header comments for AsyncFileUtil::CreateDirectory() for more details. virtual base::PlatformFileError CreateDirectory( FileSystemOperationContext* context, const FileSystemURL& url, @@ -113,6 +86,7 @@ class WEBKIT_STORAGE_EXPORT FileSystemFileUtil { bool recursive) = 0; // Retrieves the information about a file. + // See header comments for AsyncFileUtil::GetFileInfo() for more details. virtual base::PlatformFileError GetFileInfo( FileSystemOperationContext* context, const FileSystemURL& url, @@ -126,6 +100,9 @@ class WEBKIT_STORAGE_EXPORT FileSystemFileUtil { // // The supplied context must remain valid at least lifetime of the enumerator // instance. + // + // TODO(kinuko): Drop recursive flag so that each FileUtil no longer + // needs to implement recursive logic. virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator( FileSystemOperationContext* context, const FileSystemURL& root_url, @@ -139,17 +116,16 @@ class WEBKIT_STORAGE_EXPORT FileSystemFileUtil { const FileSystemURL& file_system_url, FilePath* local_file_path) = 0; - // Updates the file metadata information. Unlike posix's touch, it does - // not create a file even if |url| does not exist, but instead fails - // with PLATFORM_FILE_ERROR_NOT_FOUND. + // Updates the file metadata information. + // See header comments for AsyncFileUtil::Touch() for more details. virtual base::PlatformFileError Touch( FileSystemOperationContext* context, const FileSystemURL& url, const base::Time& last_access_time, const base::Time& last_modified_time) = 0; - // Truncates a file to the given length. If |length| is greater than the - // current length of the file, the file will be extended with zeroes. + // Truncates a file to the given length. + // See header comments for AsyncFileUtil::Truncate() for more details. virtual base::PlatformFileError Truncate( FileSystemOperationContext* context, const FileSystemURL& url, @@ -174,62 +150,30 @@ class WEBKIT_STORAGE_EXPORT FileSystemFileUtil { bool copy) = 0; // Copies in a single file from a different filesystem. - // - // This returns: - // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_file_path| - // or the parent directory of |dest_url| does not exist. - // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and - // is not a file. - // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and - // its parent path is a file. - // + // See header comments for AsyncFileUtil::CopyInForeignFile() for + // more details. virtual base::PlatformFileError CopyInForeignFile( FileSystemOperationContext* context, const FilePath& src_file_path, const FileSystemURL& dest_url) = 0; // Deletes a single file. - // - // This returns: - // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. - // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| is not a file. - // + // See header comments for AsyncFileUtil::DeleteFile() for more details. virtual base::PlatformFileError DeleteFile( FileSystemOperationContext* context, const FileSystemURL& url) = 0; // Deletes a single empty directory. - // - // This returns: - // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. - // - PLATFORM_FILE_ERROR_NOT_A_DIRECTORY if |url| is not a directory. - // - PLATFORM_FILE_ERROR_NOT_EMPTY if |url| is not empty. - // + // See header comments for AsyncFileUtil::DeleteDirectory() for more details. virtual base::PlatformFileError DeleteDirectory( FileSystemOperationContext* context, const FileSystemURL& url) = 0; // Creates a local snapshot file for a given |url| and returns the // metadata and platform path of the snapshot file via |callback|. - // In regular filesystem cases the implementation may simply return - // the metadata of the file itself (as well as GetMetadata does), - // while in non-regular filesystem case the backend may create a - // temporary snapshot file which holds the file data and return - // the metadata of the temporary file. - // - // |file_info| is the metadata of the snapshot file created. - // |platform_path| is the path to the snapshot file created. - // |policy| should indicate the policy how the fileapi backend - // should handle the returned file. - // - // This returns: - // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. - // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| is not a file. - // - // The field values of |file_info| are undefined (implementation - // dependent) in error cases, and the caller should always - // check the return code. // + // See header comments for AsyncFileUtil::CreateSnapshotFile() for + // more details. virtual base::PlatformFileError CreateSnapshotFile( FileSystemOperationContext* context, const FileSystemURL& url, |