Commit 8ce03034 authored by hidehiko@chromium.org's avatar hidehiko@chromium.org

Extract CopyOrMoveFile operation into classes.

To prepare implementing ProgressCallbak, Cancel and stream based copy/move
operation, this CL extracts main file-copying logic into classes.

BUG=279287, 278038, 278036
TEST=Ran content_unittests

Review URL: https://chromiumcodereview.appspot.com/23621026

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222083 0039d316-1c4b-4281-b951-d872f2087c98
parent d68db3dc
...@@ -23,6 +23,8 @@ class CopyOrMoveFileValidator; ...@@ -23,6 +23,8 @@ class CopyOrMoveFileValidator;
class CopyOrMoveOperationDelegate class CopyOrMoveOperationDelegate
: public RecursiveOperationDelegate { : public RecursiveOperationDelegate {
public: public:
class CopyOrMoveImpl;
enum OperationType { enum OperationType {
OPERATION_COPY, OPERATION_COPY,
OPERATION_MOVE OPERATION_MOVE
...@@ -45,60 +47,23 @@ class CopyOrMoveOperationDelegate ...@@ -45,60 +47,23 @@ class CopyOrMoveOperationDelegate
const StatusCallback& callback) OVERRIDE; const StatusCallback& callback) OVERRIDE;
private: private:
struct URLPair {
URLPair(const FileSystemURL& src, const FileSystemURL& dest)
: src(src),
dest(dest) {
}
FileSystemURL src;
FileSystemURL dest;
};
void DidTryCopyOrMoveFile(base::PlatformFileError error); void DidTryCopyOrMoveFile(base::PlatformFileError error);
void DidTryRemoveDestRoot(base::PlatformFileError error); void DidTryRemoveDestRoot(base::PlatformFileError error);
void CopyOrMoveFile( void DidFinishRecursiveCopyDir(const FileSystemURL& src,
const URLPair& url_pair, const StatusCallback& callback,
const StatusCallback& callback); base::PlatformFileError error);
void DidCreateSnapshot( void DidRemoveSourceForMove(const StatusCallback& callback,
const URLPair& url_pair, base::PlatformFileError error);
const StatusCallback& callback,
base::PlatformFileError error, // Starts Copy (or Move based on |operation_type_|) from |src_url| to
const base::PlatformFileInfo& file_info, // |dest_url|. Upon completion |callback| is invoked.
const base::FilePath& platform_path, // This can be run for multiple files in parallel.
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); void CopyOrMoveFile(const FileSystemURL& src_url,
void DidValidateFile( const FileSystemURL& dest_url,
const FileSystemURL& dest, const StatusCallback& callback);
const StatusCallback& callback, void DidCopyOrMoveFile(CopyOrMoveImpl* impl,
const base::PlatformFileInfo& file_info, const StatusCallback& callback,
const base::FilePath& platform_path, base::PlatformFileError error);
base::PlatformFileError error);
void DidFinishRecursiveCopyDir(
const FileSystemURL& src,
const StatusCallback& callback,
base::PlatformFileError error);
void DidFinishCopy(
const URLPair& url_pair,
const StatusCallback& callback,
base::PlatformFileError error);
void DoPostWriteValidation(
const URLPair& url_pair,
const StatusCallback& callback,
base::PlatformFileError error,
const base::PlatformFileInfo& file_info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
void DidPostWriteValidation(
const URLPair& url_pair,
const StatusCallback& callback,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref,
base::PlatformFileError error);
void DidRemoveSourceForMove(
const StatusCallback& callback,
base::PlatformFileError error);
void DidRemoveDestForError(
base::PlatformFileError prior_error,
const StatusCallback& callback,
base::PlatformFileError error);
FileSystemURL CreateDestURL(const FileSystemURL& src_url) const; FileSystemURL CreateDestURL(const FileSystemURL& src_url) const;
...@@ -108,10 +73,7 @@ class CopyOrMoveOperationDelegate ...@@ -108,10 +73,7 @@ class CopyOrMoveOperationDelegate
OperationType operation_type_; OperationType operation_type_;
StatusCallback callback_; StatusCallback callback_;
scoped_refptr<webkit_blob::ShareableFileReference> current_file_ref_; std::set<CopyOrMoveImpl*> running_copy_set_;
scoped_ptr<CopyOrMoveFileValidator> validator_;
base::WeakPtrFactory<CopyOrMoveOperationDelegate> weak_factory_; base::WeakPtrFactory<CopyOrMoveOperationDelegate> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationDelegate); DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationDelegate);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment