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_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/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 virtual ~AbstractFileEnumerator() {} | 39 virtual ~AbstractFileEnumerator() {} |
40 | 40 |
41 // Returns an empty string if there are no more results. | 41 // Returns an empty string if there are no more results. |
42 virtual FilePath Next() = 0; | 42 virtual FilePath Next() = 0; |
43 | 43 |
44 virtual int64 Size() = 0; | 44 virtual int64 Size() = 0; |
45 virtual base::Time LastModifiedTime() = 0; | 45 virtual base::Time LastModifiedTime() = 0; |
46 virtual bool IsDirectory() = 0; | 46 virtual bool IsDirectory() = 0; |
47 }; | 47 }; |
48 | 48 |
| 49 // A policy flag for CreateSnapshotFile. |
| 50 enum SnapshotFilePolicy { |
| 51 kSnapshotFileUnknown, |
| 52 |
| 53 // The implementation just uses the local file as the snapshot file. |
| 54 // The FileAPI backend does nothing on the returned file. |
| 55 kSnapshotFileLocal, |
| 56 |
| 57 // The implementation returns a temporary file as the snapshot file. |
| 58 // The FileAPI backend takes care of the lifetime of the returned file |
| 59 // and will delete when the last reference of the file is dropped. |
| 60 kSnapshotFileTemporary, |
| 61 }; |
| 62 |
49 class EmptyFileEnumerator : public AbstractFileEnumerator { | 63 class EmptyFileEnumerator : public AbstractFileEnumerator { |
50 virtual FilePath Next() OVERRIDE { return FilePath(); } | 64 virtual FilePath Next() OVERRIDE { return FilePath(); } |
51 virtual int64 Size() OVERRIDE { return 0; } | 65 virtual int64 Size() OVERRIDE { return 0; } |
52 virtual base::Time LastModifiedTime() OVERRIDE { return base::Time(); } | 66 virtual base::Time LastModifiedTime() OVERRIDE { return base::Time(); } |
53 virtual bool IsDirectory() OVERRIDE { return false; } | 67 virtual bool IsDirectory() OVERRIDE { return false; } |
54 }; | 68 }; |
55 | 69 |
56 virtual ~FileSystemFileUtil() {} | 70 virtual ~FileSystemFileUtil() {} |
57 | 71 |
58 // Creates or opens a file with the given flags. | 72 // Creates or opens a file with the given flags. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 const FileSystemURL& url) = 0; | 190 const FileSystemURL& url) = 0; |
177 | 191 |
178 // Creates a local snapshot file for a given |url| and returns the | 192 // Creates a local snapshot file for a given |url| and returns the |
179 // metadata and platform path of the snapshot file via |callback|. | 193 // metadata and platform path of the snapshot file via |callback|. |
180 // In regular filesystem cases the implementation may simply return | 194 // In regular filesystem cases the implementation may simply return |
181 // the metadata of the file itself (as well as GetMetadata does), | 195 // the metadata of the file itself (as well as GetMetadata does), |
182 // while in non-regular filesystem case the backend may create a | 196 // while in non-regular filesystem case the backend may create a |
183 // temporary snapshot file which holds the file data and return | 197 // temporary snapshot file which holds the file data and return |
184 // the metadata of the temporary file. | 198 // the metadata of the temporary file. |
185 // | 199 // |
186 // |result| is the return code of the operation. | |
187 // |file_info| is the metadata of the snapshot file created. | 200 // |file_info| is the metadata of the snapshot file created. |
188 // |platform_path| is the path to the snapshot file created. | 201 // |platform_path| is the path to the snapshot file created. |
189 // | 202 // |policy| should indicate the policy how the fileapi backend |
190 // The implementation can optionally return a file reference | 203 // should handle the returned file. |
191 // to let the fileapi backend manage the lifetime of the returned | 204 virtual base::PlatformFileError CreateSnapshotFile( |
192 // snapshot file. Otherwise it is ok to return NULL. | 205 FileSystemOperationContext* context, |
193 // Please see the comment for ShareableFileReference for details. | 206 const FileSystemURL& url, |
194 virtual scoped_refptr<webkit_blob::ShareableFileReference> | 207 base::PlatformFileInfo* file_info, |
195 CreateSnapshotFile(FileSystemOperationContext* context, | 208 FilePath* platform_path, |
196 const FileSystemURL& url, | 209 SnapshotFilePolicy* policy) = 0; |
197 base::PlatformFileError* result, | |
198 base::PlatformFileInfo* file_info, | |
199 FilePath* platform_path) = 0; | |
200 | 210 |
201 protected: | 211 protected: |
202 FileSystemFileUtil() {} | 212 FileSystemFileUtil() {} |
203 | 213 |
204 private: | 214 private: |
205 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil); | 215 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil); |
206 }; | 216 }; |
207 | 217 |
208 } // namespace fileapi | 218 } // namespace fileapi |
209 | 219 |
210 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ | 220 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ |
OLD | NEW |