diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-27 22:28:49 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-27 22:28:49 +0000 |
commit | 45ea0fbbb18f26d72bffbdedb8200a60177e9534 (patch) | |
tree | 004479f634e63a3dd547af7ce81edc438a15482e /webkit/fileapi/file_system_file_util_proxy.h | |
parent | 142dd7564146e19d03fa4a947f9eefeda769727f (diff) | |
download | chromium_src-45ea0fbbb18f26d72bffbdedb8200a60177e9534.zip chromium_src-45ea0fbbb18f26d72bffbdedb8200a60177e9534.tar.gz chromium_src-45ea0fbbb18f26d72bffbdedb8200a60177e9534.tar.bz2 |
Introduce CrossFileUtilHelper for cross-FileUtil Copy/Move
BUG=114732, 110121
TEST=existing tests
Review URL: https://chromiumcodereview.appspot.com/9427004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123815 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_file_util_proxy.h')
-rw-r--r-- | webkit/fileapi/file_system_file_util_proxy.h | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/webkit/fileapi/file_system_file_util_proxy.h b/webkit/fileapi/file_system_file_util_proxy.h index 514c461..e2d2f25 100644 --- a/webkit/fileapi/file_system_file_util_proxy.h +++ b/webkit/fileapi/file_system_file_util_proxy.h @@ -25,20 +25,23 @@ using base::PlatformFile; using base::PlatformFileError; using base::PlatformFileInfo; -// This class provides relay methods for supporting asynchronous access to -// FileSystem API operations. (Most of necessary relay methods are provided -// by base::FileUtilProxy, but there are a few operations that are not -// covered or are slightly different from the version of base::FileUtilProxy. +class FileSystemFileUtil; +class FileSystemOperationContext; +class FileSystemPath; + +// This class provides asynchronous access to FileSystemFileUtil methods for +// FileSystem API operations. This also implements cross-FileUtil copy/move +// operations on top of FileSystemFileUtil methods. class FileSystemFileUtilProxy { public: typedef base::FileUtilProxy::Entry Entry; - - typedef base::Callback<void(PlatformFileError, - bool /* created */ + typedef base::Callback<void(PlatformFileError status)> StatusCallback; + typedef base::Callback<void(PlatformFileError status, + bool created )> EnsureFileExistsCallback; - typedef base::Callback<void(PlatformFileError, - const PlatformFileInfo&, - const FilePath& /* platform_path */ + typedef base::Callback<void(PlatformFileError status, + const PlatformFileInfo& info, + const FilePath& platform_path )> GetFileInfoCallback; typedef base::Callback<void(PlatformFileError, const std::vector<Entry>&, @@ -51,6 +54,42 @@ class FileSystemFileUtilProxy { typedef base::Callback<PlatformFileError(std::vector<Entry>* )> ReadDirectoryTask; + // Copies a file or a directory from |src_path| to |dest_path| by calling + // FileSystemFileUtil's following methods on the given |message_loop_proxy|. + // - CopyOrMoveFile() for same-filesystem operations + // - CopyInForeignFile() for (limited) cross-filesystem operations + // + // Error cases: + // If destination's parent doesn't exist. + // If source dir exists but destination path is an existing file. + // If source file exists but destination path is an existing directory. + // If source is a parent of destination. + // If source doesn't exist. + // If source and dest are the same path in the same filesystem. + static bool Copy( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + FileSystemOperationContext* context, + FileSystemFileUtil* src_util, + FileSystemFileUtil* dest_util, + const FileSystemPath& src_path, + const FileSystemPath& dest_path, + const StatusCallback& callback); + + // Moves a file or a directory from |src_path| to |dest_path| by calling + // FileSystemFileUtil's following methods on the given |message_loop_proxy|. + // - CopyOrMoveFile() for same-filesystem operations + // - CopyInForeignFile() for (limited) cross-filesystem operations + // + // This method returns an error on the same error cases with Copy. + static bool Move( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + FileSystemOperationContext* context, + FileSystemFileUtil* src_util, + FileSystemFileUtil* dest_util, + const FileSystemPath& src_path, + const FileSystemPath& dest_path, + const StatusCallback& callback); + // Calls EnsureFileExistsTask |task| on the given |message_loop_proxy|. static bool RelayEnsureFileExists( scoped_refptr<MessageLoopProxy> message_loop_proxy, |