| OLD | NEW |
| (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 BASE_FILES_FILE_UTIL_PROXY_H_ | |
| 6 #define BASE_FILES_FILE_UTIL_PROXY_H_ | |
| 7 | |
| 8 #include "base/base_export.h" | |
| 9 #include "base/callback_forward.h" | |
| 10 #include "base/files/file.h" | |
| 11 #include "base/files/file_path.h" | |
| 12 | |
| 13 namespace base { | |
| 14 | |
| 15 class TaskRunner; | |
| 16 class Time; | |
| 17 | |
| 18 // This class provides asynchronous access to common file routines. | |
| 19 class BASE_EXPORT FileUtilProxy { | |
| 20 public: | |
| 21 // This callback is used by methods that report only an error code. It is | |
| 22 // valid to pass a null callback to any function that takes a StatusCallback, | |
| 23 // in which case the operation will complete silently. | |
| 24 typedef Callback<void(File::Error)> StatusCallback; | |
| 25 | |
| 26 typedef Callback<void(File::Error, | |
| 27 const File::Info&)> GetFileInfoCallback; | |
| 28 | |
| 29 // Retrieves the information about a file. It is invalid to pass a null | |
| 30 // callback. | |
| 31 // This returns false if task posting to |task_runner| has failed. | |
| 32 static bool GetFileInfo( | |
| 33 TaskRunner* task_runner, | |
| 34 const FilePath& file_path, | |
| 35 const GetFileInfoCallback& callback); | |
| 36 | |
| 37 // Deletes a file or a directory. | |
| 38 // It is an error to delete a non-empty directory with recursive=false. | |
| 39 // This returns false if task posting to |task_runner| has failed. | |
| 40 static bool DeleteFile(TaskRunner* task_runner, | |
| 41 const FilePath& file_path, | |
| 42 bool recursive, | |
| 43 const StatusCallback& callback); | |
| 44 | |
| 45 // Touches a file. The callback can be null. | |
| 46 // This returns false if task posting to |task_runner| has failed. | |
| 47 static bool Touch( | |
| 48 TaskRunner* task_runner, | |
| 49 const FilePath& file_path, | |
| 50 const Time& last_access_time, | |
| 51 const Time& last_modified_time, | |
| 52 const StatusCallback& callback); | |
| 53 | |
| 54 private: | |
| 55 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); | |
| 56 }; | |
| 57 | |
| 58 } // namespace base | |
| 59 | |
| 60 #endif // BASE_FILES_FILE_UTIL_PROXY_H_ | |
| OLD | NEW |