Chromium Code Reviews| 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 instance may depend on FileSystemOperationContext instance past as | |
| 243 // context. The context should be valid in the lifetime of the enumerator | |
| 244 // instance. | |
|
ericu
2011/08/26 16:38:24
How about just "The supplied context must remain v
tzik
2011/08/29 02:33:32
Done.
| |
| 237 virtual AbstractFileEnumerator* CreateFileEnumerator( | 245 virtual AbstractFileEnumerator* CreateFileEnumerator( |
| 238 FileSystemOperationContext* unused, | 246 FileSystemOperationContext* context, |
| 239 const FilePath& root_path); | 247 const FilePath& root_path); |
| 240 | 248 |
| 241 protected: | 249 protected: |
| 242 // Deletes a directory and all entries under the directory. | 250 // Deletes a directory and all entries under the directory. |
| 243 // | 251 // |
| 244 // This method is called from Delete. It internally calls two following | 252 // This method is called from Delete. It internally calls two following |
| 245 // virtual methods, | 253 // virtual methods, |
| 246 // - (virtual) DeleteFile to delete files, and | 254 // - (virtual) DeleteFile to delete files, and |
| 247 // - (virtual) DeleteSingleDirectory to delete empty directories after all | 255 // - (virtual) DeleteSingleDirectory to delete empty directories after all |
| 248 // the files are deleted. | 256 // the files are deleted. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 277 const FilePath& src_file_path, | 285 const FilePath& src_file_path, |
| 278 const FilePath& dest_file_path, | 286 const FilePath& dest_file_path, |
| 279 bool copy); | 287 bool copy); |
| 280 | 288 |
| 281 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil); | 289 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil); |
| 282 }; | 290 }; |
| 283 | 291 |
| 284 } // namespace fileapi | 292 } // namespace fileapi |
| 285 | 293 |
| 286 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ | 294 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ |
| OLD | NEW |