| OLD | NEW |
| 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_CHROMEOS_FILEAPI_FILE_SYSTEM_FILE_UTIL_ASYNC_H_ | 5 #ifndef WEBKIT_CHROMEOS_FILEAPI_FILE_SYSTEM_FILE_UTIL_ASYNC_H_ |
| 6 #define WEBKIT_CHROMEOS_FILEAPI_FILE_SYSTEM_FILE_UTIL_ASYNC_H_ | 6 #define WEBKIT_CHROMEOS_FILEAPI_FILE_SYSTEM_FILE_UTIL_ASYNC_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/files/file_util_proxy.h" | 9 #include "base/files/file_util_proxy.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // true if all files are read. | 44 // true if all files are read. |
| 45 typedef base::Callback<void( | 45 typedef base::Callback<void( |
| 46 PlatformFileError result, | 46 PlatformFileError result, |
| 47 const FileList& file_list, | 47 const FileList& file_list, |
| 48 bool completed)> ReadDirectoryCallback; | 48 bool completed)> ReadDirectoryCallback; |
| 49 | 49 |
| 50 // Opens a file of the given |file_path| with |flags|. On success, | 50 // Opens a file of the given |file_path| with |flags|. On success, |
| 51 // PLATFORM_FILE_OK is passed to |callback| with a pointer to newly | 51 // PLATFORM_FILE_OK is passed to |callback| with a pointer to newly |
| 52 // created AsyncFileStream object. The caller should delete the | 52 // created AsyncFileStream object. The caller should delete the |
| 53 // stream. On failure, an error code is passed instead. | 53 // stream. On failure, an error code is passed instead. |
| 54 virtual void Open(const FilePath& file_path, | 54 virtual void Open(const base::FilePath& file_path, |
| 55 int file_flags, // PlatformFileFlags | 55 int file_flags, // PlatformFileFlags |
| 56 const OpenCallback& callback) = 0; | 56 const OpenCallback& callback) = 0; |
| 57 | 57 |
| 58 // Gets file info of the given |file_path|. On success, | 58 // Gets file info of the given |file_path|. On success, |
| 59 // PLATFORM_FILE_OK is passed to |callback| with the the obtained file | 59 // PLATFORM_FILE_OK is passed to |callback| with the the obtained file |
| 60 // info. On failure, an error code is passed instead. | 60 // info. On failure, an error code is passed instead. |
| 61 virtual void GetFileInfo(const FilePath& file_path, | 61 virtual void GetFileInfo(const base::FilePath& file_path, |
| 62 const GetFileInfoCallback& callback) = 0; | 62 const GetFileInfoCallback& callback) = 0; |
| 63 | 63 |
| 64 // Creates a file of the given |file_path|. On success, | 64 // Creates a file of the given |file_path|. On success, |
| 65 // PLATFORM_FILE_OK is passed to |callback|. On failure, an error code | 65 // PLATFORM_FILE_OK is passed to |callback|. On failure, an error code |
| 66 // is passed instead. | 66 // is passed instead. |
| 67 virtual void Create(const FilePath& file_path, | 67 virtual void Create(const base::FilePath& file_path, |
| 68 const StatusCallback& callback) = 0; | 68 const StatusCallback& callback) = 0; |
| 69 | 69 |
| 70 // Truncates a file of the given |file_path| to |length|. On success, | 70 // Truncates a file of the given |file_path| to |length|. On success, |
| 71 // PLATFORM_FILE_OK is passed to |callback|. On failure, an error code | 71 // PLATFORM_FILE_OK is passed to |callback|. On failure, an error code |
| 72 // is passed instead. | 72 // is passed instead. |
| 73 virtual void Truncate(const FilePath& file_path, | 73 virtual void Truncate(const base::FilePath& file_path, |
| 74 int64 length, | 74 int64 length, |
| 75 const StatusCallback& callback) = 0; | 75 const StatusCallback& callback) = 0; |
| 76 | 76 |
| 77 // Modifies the timestamps of a file of the given |file_path|. On | 77 // Modifies the timestamps of a file of the given |file_path|. On |
| 78 // success, PLATFORM_FILE_OK is passed to |callback|. On failure, an | 78 // success, PLATFORM_FILE_OK is passed to |callback|. On failure, an |
| 79 // error code is passed instead. | 79 // error code is passed instead. |
| 80 virtual void Touch(const FilePath& file_path, | 80 virtual void Touch(const base::FilePath& file_path, |
| 81 const base::Time& last_access_time, | 81 const base::Time& last_access_time, |
| 82 const base::Time& last_modified_time, | 82 const base::Time& last_modified_time, |
| 83 const StatusCallback& callback) = 0; | 83 const StatusCallback& callback) = 0; |
| 84 | 84 |
| 85 // Removes a file or directory of the given |file_path|. If |recursive| | 85 // Removes a file or directory of the given |file_path|. If |recursive| |
| 86 // is true, removes the contents of the given directory recursively. On | 86 // is true, removes the contents of the given directory recursively. On |
| 87 // success, PLATFORM_FILE_OK is passed to |callback|. On failure, an | 87 // success, PLATFORM_FILE_OK is passed to |callback|. On failure, an |
| 88 // error code is passed instead. | 88 // error code is passed instead. |
| 89 virtual void Remove(const FilePath& file_path, | 89 virtual void Remove(const base::FilePath& file_path, |
| 90 bool recursive, | 90 bool recursive, |
| 91 const StatusCallback& callback) = 0; | 91 const StatusCallback& callback) = 0; |
| 92 | 92 |
| 93 // Creates a directory of the given |dir_path|. On success, | 93 // Creates a directory of the given |dir_path|. On success, |
| 94 // PLATFORM_FILE_OK is passed to |callback|. On failure, an error code | 94 // PLATFORM_FILE_OK is passed to |callback|. On failure, an error code |
| 95 // is passed instead. | 95 // is passed instead. |
| 96 virtual void CreateDirectory(const FilePath& dir_path, | 96 virtual void CreateDirectory(const base::FilePath& dir_path, |
| 97 const StatusCallback& callback) = 0; | 97 const StatusCallback& callback) = 0; |
| 98 | 98 |
| 99 // Reads a directory of the given |dir_path|. On success, | 99 // Reads a directory of the given |dir_path|. On success, |
| 100 // PLATFORM_FILE_OK is passed to |callback| with the list of files, and | 100 // PLATFORM_FILE_OK is passed to |callback| with the list of files, and |
| 101 // a boolean value indicating if all files are read. On failure, an | 101 // a boolean value indicating if all files are read. On failure, an |
| 102 // error code is passed instead. | 102 // error code is passed instead. |
| 103 // | 103 // |
| 104 // The ReadDirectoryCallback may be called several times, returning the | 104 // The ReadDirectoryCallback may be called several times, returning the |
| 105 // portions of the whole directory listing. The reference to vector with | 105 // portions of the whole directory listing. The reference to vector with |
| 106 // DirectoryEntry objects, passed to callback is guaranteed to contain the | 106 // DirectoryEntry objects, passed to callback is guaranteed to contain the |
| 107 // results of the operation only while callback is running. | 107 // results of the operation only while callback is running. |
| 108 // | 108 // |
| 109 // The implementations of FileUtilAsync should be careful to populate the | 109 // The implementations of FileUtilAsync should be careful to populate the |
| 110 // vector on the same thread, on which the callback is called. Otherwise, | 110 // vector on the same thread, on which the callback is called. Otherwise, |
| 111 // if callback is called through PostTask, the data might get overwritten | 111 // if callback is called through PostTask, the data might get overwritten |
| 112 // before callback is actually called. | 112 // before callback is actually called. |
| 113 // | 113 // |
| 114 // TODO(olege): Maybe make it possible to read only a part of the directory. | 114 // TODO(olege): Maybe make it possible to read only a part of the directory. |
| 115 virtual void ReadDirectory(const FilePath& dir_path, | 115 virtual void ReadDirectory(const base::FilePath& dir_path, |
| 116 const ReadDirectoryCallback& callback) = 0; | 116 const ReadDirectoryCallback& callback) = 0; |
| 117 | 117 |
| 118 // TODO(olege): Add LocalCopy and LocalMove. | 118 // TODO(olege): Add LocalCopy and LocalMove. |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 } // namespace fileapi | 121 } // namespace fileapi |
| 122 | 122 |
| 123 #endif // WEBKIT_CHROMEOS_FILEAPI_FILE_SYSTEM_FILE_UTIL_ASYNC_H_ | 123 #endif // WEBKIT_CHROMEOS_FILEAPI_FILE_SYSTEM_FILE_UTIL_ASYNC_H_ |
| OLD | NEW |