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

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

Issue 9564047: Add FileUtileHelper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/DeletePath/Delete/g 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 | « webkit/fileapi/cross_file_util_helper.cc ('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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_
7 7
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util_proxy.h" 9 #include "base/file_util_proxy.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
(...skipping 29 matching lines...) Expand all
40 }; 40 };
41 41
42 class EmptyFileEnumerator : public AbstractFileEnumerator { 42 class EmptyFileEnumerator : public AbstractFileEnumerator {
43 virtual FilePath Next() OVERRIDE { return FilePath(); } 43 virtual FilePath Next() OVERRIDE { return FilePath(); }
44 virtual int64 Size() OVERRIDE { return 0; } 44 virtual int64 Size() OVERRIDE { return 0; }
45 virtual bool IsDirectory() OVERRIDE { return false; } 45 virtual bool IsDirectory() OVERRIDE { return false; }
46 }; 46 };
47 47
48 virtual ~FileSystemFileUtil(); 48 virtual ~FileSystemFileUtil();
49 49
50 // Deletes a file or a directory.
51 // It is an error to delete a non-empty directory with recursive=false.
52 //
53 // This method calls one of the following methods depending on whether the
54 // target is a directory or not, and whether the |recursive| flag is given or
55 // not.
56 // - (virtual) DeleteFile,
57 // - (virtual) DeleteSingleDirectory or
58 // - (non-virtual) DeleteDirectoryRecursive which calls two methods above.
59 //
60 // TODO(kinuko): Move this implementation outside FileSystemFileUtil.
61 PlatformFileError Delete(
62 FileSystemOperationContext* context,
63 const FileSystemPath& path,
64 bool recursive);
65
66 // Creates or opens a file with the given flags. 50 // Creates or opens a file with the given flags.
67 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create 51 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create
68 // a new file at the given |path| and calls back with 52 // a new file at the given |path| and calls back with
69 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |path| already exists. 53 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |path| already exists.
70 virtual PlatformFileError CreateOrOpen( 54 virtual PlatformFileError CreateOrOpen(
71 FileSystemOperationContext* context, 55 FileSystemOperationContext* context,
72 const FileSystemPath& path, 56 const FileSystemPath& path,
73 int file_flags, 57 int file_flags,
74 PlatformFile* file_handle, 58 PlatformFile* file_handle,
75 bool* created); 59 bool* created);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // Deletes a single empty directory. 171 // Deletes a single empty directory.
188 // It assumes the given path points an empty directory. 172 // It assumes the given path points an empty directory.
189 virtual PlatformFileError DeleteSingleDirectory( 173 virtual PlatformFileError DeleteSingleDirectory(
190 FileSystemOperationContext* context, 174 FileSystemOperationContext* context,
191 const FileSystemPath& path); 175 const FileSystemPath& path);
192 176
193 protected: 177 protected:
194 FileSystemFileUtil(); 178 FileSystemFileUtil();
195 explicit FileSystemFileUtil(FileSystemFileUtil* underlying_file_util); 179 explicit FileSystemFileUtil(FileSystemFileUtil* underlying_file_util);
196 180
197 // Deletes a directory and all entries under the directory.
198 //
199 // This method is called from Delete. It internally calls two following
200 // virtual methods,
201 // - (virtual) DeleteFile to delete files, and
202 // - (virtual) DeleteSingleDirectory to delete empty directories after all
203 // the files are deleted.
204 //
205 // TODO(kinuko): Move this method out of this class.
206 PlatformFileError DeleteDirectoryRecursive(
207 FileSystemOperationContext* context,
208 const FileSystemPath& path);
209
210 // TODO(kinuko): We should stop FileUtil layering. 181 // TODO(kinuko): We should stop FileUtil layering.
211 FileSystemFileUtil* underlying_file_util() const { 182 FileSystemFileUtil* underlying_file_util() const {
212 return underlying_file_util_.get(); 183 return underlying_file_util_.get();
213 } 184 }
214 185
215 private: 186 private:
216 scoped_ptr<FileSystemFileUtil> underlying_file_util_; 187 scoped_ptr<FileSystemFileUtil> underlying_file_util_;
217 188
218 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil); 189 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil);
219 }; 190 };
220 191
221 } // namespace fileapi 192 } // namespace fileapi
222 193
223 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ 194 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/cross_file_util_helper.cc ('k') | webkit/fileapi/file_system_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698