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

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

Issue 6604020: Introduce FileSystemFileUtil and -Proxy to decorate base::file_util in webkit/fileapi. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Made file_system_operation_context_ a simple variable (replaced from not scoped_ptr.) Created 9 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 | « webkit/fileapi/file_system_context.h ('k') | webkit/fileapi/file_system_file_util.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) 2011 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_FILE_SYSTEM_FILE_UTIL_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_
7
8 #include "base/callback.h"
9 #include "base/file_path.h"
10 #include "base/file_util.h"
11 #include "base/file_util_proxy.h"
12 #include "base/platform_file.h"
13 #include "base/ref_counted.h"
14 #include "base/singleton.h"
15 #include "base/tracked_objects.h"
16
17 namespace base {
18 struct PlatformFileInfo;
19 class MessageLoopProxy;
20 class Time;
21 }
22
23 namespace fileapi {
24
25 using base::PlatformFile;
26 using base::PlatformFileError;
27
28 class FileSystemOperationContext;
29
30 // A large part of this implementation is taken from base::FileUtilProxy.
31 // TODO(dmikurube, kinuko): Clean up base::FileUtilProxy to factor out common
32 // routines. It includes dropping FileAPI-specific routines from FileUtilProxy.
33 class FileSystemFileUtil {
34 public:
35 static FileSystemFileUtil* GetInstance();
36
37 // Creates or opens a file with the given flags. It is invalid to pass NULL
38 // for the callback.
39 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create
40 // a new file at the given |file_path| and calls back with
41 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists.
42 virtual PlatformFileError CreateOrOpen(
43 FileSystemOperationContext* context,
44 const FilePath& file_path,
45 int file_flags,
46 PlatformFile* file_handle,
47 bool* created);
48
49 // Close the given file handle.
50 virtual PlatformFileError Close(
51 FileSystemOperationContext* context,
52 PlatformFile);
53
54 // Ensures that the given |file_path| exist. This creates a empty new file
55 // at |file_path| if the |file_path| does not exist.
56 // If a new file han not existed and is created at the |file_path|,
57 // |created| of the callback argument is set true and |error code|
58 // is set PLATFORM_FILE_OK.
59 // If the file already exists, |created| is set false and |error code|
60 // is set PLATFORM_FILE_OK.
61 // If the file hasn't existed but it couldn't be created for some other
62 // reasons, |created| is set false and |error code| indicates the error.
63 virtual PlatformFileError EnsureFileExists(
64 FileSystemOperationContext* context,
65 const FilePath& file_path, bool* created);
66
67 // Retrieves the information about a file. It is invalid to pass NULL for the
68 // callback.
69 virtual PlatformFileError GetFileInfo(
70 FileSystemOperationContext* context,
71 const FilePath& file_, base::PlatformFileInfo* file_info);
72
73 virtual PlatformFileError ReadDirectory(
74 FileSystemOperationContext* context,
75 const FilePath& file_path,
76 std::vector<base::FileUtilProxy::Entry>* entries);
77
78 // Creates directory at given path. It's an error to create
79 // if |exclusive| is true and dir already exists.
80 virtual PlatformFileError CreateDirectory(
81 FileSystemOperationContext* context,
82 const FilePath& file_path,
83 bool exclusive);
84
85 // Copies a file or a directory from |src_file_path| to |dest_file_path|
86 // Error cases:
87 // If destination file doesn't exist or destination's parent
88 // doesn't exists.
89 // If source dir exists but destination path is an existing file.
90 // If source file exists but destination path is an existing directory.
91 // If source is a parent of destination.
92 // If source doesn't exists.
93 virtual PlatformFileError Copy(
94 FileSystemOperationContext* context,
95 const FilePath& src_file_path,
96 const FilePath& dest_file_path);
97
98 // Moves a file or a directory from src_file_path to dest_file_path.
99 // Error cases are similar to Copy method's error cases.
100 virtual PlatformFileError Move(
101 FileSystemOperationContext* context,
102 const FilePath& src_file_path,
103 const FilePath& dest_file_path);
104
105 // Deletes a file or a directory.
106 // It is an error to delete a non-empty directory with recursive=false.
107 virtual PlatformFileError Delete(
108 FileSystemOperationContext* context,
109 const FilePath& file_path,
110 bool recursive);
111
112 // Touches a file. The callback can be NULL.
113 virtual PlatformFileError Touch(
114 FileSystemOperationContext* context,
115 const FilePath& file_path,
116 const base::Time& last_access_time,
117 const base::Time& last_modified_time);
118
119 // Truncates a file to the given length. If |length| is greater than the
120 // current length of the file, the file will be extended with zeroes.
121 // The callback can be NULL.
122 virtual PlatformFileError Truncate(
123 FileSystemOperationContext* context,
124 const FilePath& path,
125 int64 length);
126
127 protected:
128 FileSystemFileUtil() { }
129 friend struct DefaultSingletonTraits<FileSystemFileUtil>;
130 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil);
131 };
132
133 } // namespace fileapi
134
135 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_context.h ('k') | webkit/fileapi/file_system_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698