OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 <vector> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/file_path.h" | 11 #include "base/file_path.h" |
10 #include "base/file_util.h" | 12 #include "base/file_util.h" |
11 #include "base/file_util_proxy.h" | 13 #include "base/file_util_proxy.h" |
12 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
13 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
14 #include "base/tracked_objects.h" | 16 #include "base/tracked_objects.h" |
15 #include "webkit/fileapi/file_system_types.h" | 17 #include "webkit/fileapi/file_system_types.h" |
16 | 18 |
17 namespace base { | 19 namespace base { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 const FilePath& file_path); | 217 const FilePath& file_path); |
216 | 218 |
217 // It will be implemented by each subclass such as FileSystemFileEnumerator. | 219 // It will be implemented by each subclass such as FileSystemFileEnumerator. |
218 class AbstractFileEnumerator { | 220 class AbstractFileEnumerator { |
219 public: | 221 public: |
220 virtual ~AbstractFileEnumerator() {} | 222 virtual ~AbstractFileEnumerator() {} |
221 | 223 |
222 // Returns an empty string if there are no more results. | 224 // Returns an empty string if there are no more results. |
223 virtual FilePath Next() = 0; | 225 virtual FilePath Next() = 0; |
224 | 226 |
| 227 virtual int64 Size() = 0; |
225 virtual bool IsDirectory() = 0; | 228 virtual bool IsDirectory() = 0; |
226 }; | 229 }; |
227 | 230 |
228 class EmptyFileEnumerator : public AbstractFileEnumerator { | 231 class EmptyFileEnumerator : public AbstractFileEnumerator { |
229 virtual FilePath Next() { return FilePath(); } | 232 virtual FilePath Next() OVERRIDE { return FilePath(); } |
230 virtual bool IsDirectory() { return false; } | 233 virtual int64 Size() OVERRIDE { return 0; } |
| 234 virtual bool IsDirectory() OVERRIDE { return false; } |
231 }; | 235 }; |
232 | 236 |
233 // Returns a pointer to a new instance of AbstractFileEnumerator which is | 237 // Returns a pointer to a new instance of AbstractFileEnumerator which is |
234 // implemented for each FileUtil subclass. The instance needs to be freed | 238 // implemented for each FileUtil subclass. The instance needs to be freed |
235 // by the caller, and its lifetime should not extend past when the current | 239 // by the caller, and its lifetime should not extend past when the current |
236 // call returns to the main FILE message loop. | 240 // call returns to the main FILE message loop. |
| 241 // |
| 242 // The supplied context must remain valid at least lifetime of the enumerator |
| 243 // instance. |
237 virtual AbstractFileEnumerator* CreateFileEnumerator( | 244 virtual AbstractFileEnumerator* CreateFileEnumerator( |
238 FileSystemOperationContext* unused, | 245 FileSystemOperationContext* context, |
239 const FilePath& root_path); | 246 const FilePath& root_path); |
240 | 247 |
241 protected: | 248 protected: |
242 // Deletes a directory and all entries under the directory. | 249 // Deletes a directory and all entries under the directory. |
243 // | 250 // |
244 // This method is called from Delete. It internally calls two following | 251 // This method is called from Delete. It internally calls two following |
245 // virtual methods, | 252 // virtual methods, |
246 // - (virtual) DeleteFile to delete files, and | 253 // - (virtual) DeleteFile to delete files, and |
247 // - (virtual) DeleteSingleDirectory to delete empty directories after all | 254 // - (virtual) DeleteSingleDirectory to delete empty directories after all |
248 // the files are deleted. | 255 // the files are deleted. |
(...skipping 28 matching lines...) Expand all Loading... |
277 const FilePath& src_file_path, | 284 const FilePath& src_file_path, |
278 const FilePath& dest_file_path, | 285 const FilePath& dest_file_path, |
279 bool copy); | 286 bool copy); |
280 | 287 |
281 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil); | 288 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil); |
282 }; | 289 }; |
283 | 290 |
284 } // namespace fileapi | 291 } // namespace fileapi |
285 | 292 |
286 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ | 293 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ |
OLD | NEW |