Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(669)

Side by Side Diff: webkit/fileapi/cross_file_util_helper.h

Issue 9616033: Merge CrossFileUtilHelper to FileUtilHelper as Copy() and Move(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | webkit/fileapi/cross_file_util_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_FILEAPI_CROSS_FILE_UTIL_HELPER_H_
6 #define WEBKIT_FILEAPI_CROSS_FILE_UTIL_HELPER_H_
7
8 #include "base/callback.h"
9 #include "base/platform_file.h"
10
11 namespace fileapi {
12
13 class FileSystemFileUtil;
14 class FileSystemOperationContext;
15 class FileSystemPath;
16
17 // A helper class for cross-FileUtil Copy/Move operations.
18 class CrossFileUtilHelper {
19 public:
20 enum Operation {
21 OPERATION_COPY,
22 OPERATION_MOVE
23 };
24
25 CrossFileUtilHelper(FileSystemOperationContext* context,
26 FileSystemFileUtil* src_util,
27 FileSystemFileUtil* dest_util,
28 const FileSystemPath& src_path,
29 const FileSystemPath& dest_path,
30 Operation operation);
31 ~CrossFileUtilHelper();
32
33 base::PlatformFileError DoWork();
34
35 private:
36 // Performs common pre-operation check and preparation.
37 // This may delete the destination directory if it's empty.
38 base::PlatformFileError PerformErrorCheckAndPreparationForMoveAndCopy();
39
40 // This assumes that the root exists.
41 bool ParentExists(const FileSystemPath& path, FileSystemFileUtil* file_util);
42
43 // Performs recursive copy or move by calling CopyOrMoveFile for individual
44 // files. Operations for recursive traversal are encapsulated in this method.
45 // It assumes src_path and dest_path have passed
46 // PerformErrorCheckAndPreparationForMoveAndCopy().
47 base::PlatformFileError CopyOrMoveDirectory(
48 const FileSystemPath& src_path,
49 const FileSystemPath& dest_path);
50
51 // Determines whether a simple same-filesystem move or copy can be done. If
52 // so, it delegates to CopyOrMoveFile. Otherwise it looks up the true
53 // platform path of the source file, delegates to CopyInForeignFile, and [for
54 // move] calls DeleteFile on the source file.
55 base::PlatformFileError CopyOrMoveFile(
56 const FileSystemPath& src_path,
57 const FileSystemPath& dest_path);
58
59 FileSystemOperationContext* context_;
60 FileSystemFileUtil* src_util_; // Not owned.
61 FileSystemFileUtil* dest_util_; // Not owned.
62 const FileSystemPath& src_root_path_;
63 const FileSystemPath& dest_root_path_;
64 Operation operation_;
65
66 DISALLOW_COPY_AND_ASSIGN(CrossFileUtilHelper);
67 };
68
69 } // namespace fileapi
70
71 #endif // WEBKIT_FILEAPI_CROSS_FILE_UTIL_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/fileapi/cross_file_util_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698