Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(766)

Side by Side Diff: webkit/browser/fileapi/async_file_util.h

Issue 18580012: Cleanup: return value and null-callback fixups on AsyncFileUtil interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_BROWSER_FILEAPI_ASYNC_FILE_UTIL_H_ 5 #ifndef WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_UTIL_H_
6 #define WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_UTIL_H_ 6 #define WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_UTIL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback_forward.h" 9 #include "base/callback_forward.h"
10 #include "base/files/file_util_proxy.h" 10 #include "base/files/file_util_proxy.h"
(...skipping 20 matching lines...) Expand all
31 // 31 //
32 // Each filesystem which needs to be dispatched from LocalFileSystemOperation 32 // Each filesystem which needs to be dispatched from LocalFileSystemOperation
33 // must implement this interface or a synchronous version of interface: 33 // must implement this interface or a synchronous version of interface:
34 // FileSystemFileUtil. 34 // FileSystemFileUtil.
35 // 35 //
36 // As far as an instance of this class is owned by a MountPointProvider 36 // As far as an instance of this class is owned by a MountPointProvider
37 // (which is owned by FileSystemContext), it's guaranteed that this instance's 37 // (which is owned by FileSystemContext), it's guaranteed that this instance's
38 // alive while FileSystemOperationContext given to each operation is kept 38 // alive while FileSystemOperationContext given to each operation is kept
39 // alive. (Note that this instance might be freed on different thread 39 // alive. (Note that this instance might be freed on different thread
40 // from the thread it is created.) 40 // from the thread it is created.)
41 //
42 // It is NOT valid to give null callback to this class, and implementors
43 // can assume that they don't get any null callbacks.
44 //
41 class WEBKIT_STORAGE_BROWSER_EXPORT AsyncFileUtil { 45 class WEBKIT_STORAGE_BROWSER_EXPORT AsyncFileUtil {
42 public: 46 public:
43 typedef base::Callback< 47 typedef base::Callback<
44 void(base::PlatformFileError result)> StatusCallback; 48 void(base::PlatformFileError result)> StatusCallback;
45 49
46 typedef base::Callback< 50 typedef base::Callback<
47 void(base::PlatformFileError result, 51 void(base::PlatformFileError result,
48 base::PassPlatformFile file)> CreateOrOpenCallback; 52 base::PassPlatformFile file)> CreateOrOpenCallback;
49 53
50 typedef base::Callback< 54 typedef base::Callback<
(...skipping 21 matching lines...) Expand all
72 virtual ~AsyncFileUtil() {} 76 virtual ~AsyncFileUtil() {}
73 77
74 // Creates or opens a file with the given flags. 78 // Creates or opens a file with the given flags.
75 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create 79 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create
76 // a new file at the given |url| and calls back with 80 // a new file at the given |url| and calls back with
77 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |url| already exists. 81 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |url| already exists.
78 // 82 //
79 // LocalFileSystemOperation::OpenFile calls this. 83 // LocalFileSystemOperation::OpenFile calls this.
80 // This is used only by Pepper/NaCL File API. 84 // This is used only by Pepper/NaCL File API.
81 // 85 //
82 // This returns false if it fails to post an async task. 86 virtual void CreateOrOpen(
83 //
84 virtual bool CreateOrOpen(
85 scoped_ptr<FileSystemOperationContext> context, 87 scoped_ptr<FileSystemOperationContext> context,
86 const FileSystemURL& url, 88 const FileSystemURL& url,
87 int file_flags, 89 int file_flags,
88 const CreateOrOpenCallback& callback) = 0; 90 const CreateOrOpenCallback& callback) = 0;
89 91
90 // Ensures that the given |url| exist. This creates a empty new file 92 // Ensures that the given |url| exist. This creates a empty new file
91 // at |url| if the |url| does not exist. 93 // at |url| if the |url| does not exist.
92 // 94 //
93 // LocalFileSystemOperation::CreateFile calls this. 95 // LocalFileSystemOperation::CreateFile calls this.
94 // 96 //
95 // This returns false if it fails to post an async task.
96 //
97 // This reports following error code via |callback|: 97 // This reports following error code via |callback|:
98 // - PLATFORM_FILE_OK and created==true if a file has not existed and 98 // - PLATFORM_FILE_OK and created==true if a file has not existed and
99 // is created at |url|. 99 // is created at |url|.
100 // - PLATFORM_FILE_OK and created==false if the file already exists. 100 // - PLATFORM_FILE_OK and created==false if the file already exists.
101 // - Other error code (with created=false) if a file hasn't existed yet 101 // - Other error code (with created=false) if a file hasn't existed yet
102 // and there was an error while creating a new file. 102 // and there was an error while creating a new file.
103 // 103 //
104 virtual bool EnsureFileExists( 104 virtual void EnsureFileExists(
105 scoped_ptr<FileSystemOperationContext> context, 105 scoped_ptr<FileSystemOperationContext> context,
106 const FileSystemURL& url, 106 const FileSystemURL& url,
107 const EnsureFileExistsCallback& callback) = 0; 107 const EnsureFileExistsCallback& callback) = 0;
108 108
109 // Creates directory at given url. 109 // Creates directory at given url.
110 // 110 //
111 // LocalFileSystemOperation::CreateDirectory calls this. 111 // LocalFileSystemOperation::CreateDirectory calls this.
112 // 112 //
113 // This returns false if it fails to post an async task.
114 //
115 // This reports following error code via |callback|: 113 // This reports following error code via |callback|:
116 // - PLATFORM_FILE_ERROR_NOT_FOUND if the |url|'s parent directory 114 // - PLATFORM_FILE_ERROR_NOT_FOUND if the |url|'s parent directory
117 // does not exist and |recursive| is false. 115 // does not exist and |recursive| is false.
118 // - PLATFORM_FILE_ERROR_EXISTS if a directory already exists at |url| 116 // - PLATFORM_FILE_ERROR_EXISTS if a directory already exists at |url|
119 // and |exclusive| is true. 117 // and |exclusive| is true.
120 // - PLATFORM_FILE_ERROR_EXISTS if a file already exists at |url| 118 // - PLATFORM_FILE_ERROR_EXISTS if a file already exists at |url|
121 // (regardless of |exclusive| value). 119 // (regardless of |exclusive| value).
122 // - Other error code if it failed to create a directory. 120 // - Other error code if it failed to create a directory.
123 // 121 //
124 virtual bool CreateDirectory( 122 virtual void CreateDirectory(
125 scoped_ptr<FileSystemOperationContext> context, 123 scoped_ptr<FileSystemOperationContext> context,
126 const FileSystemURL& url, 124 const FileSystemURL& url,
127 bool exclusive, 125 bool exclusive,
128 bool recursive, 126 bool recursive,
129 const StatusCallback& callback) = 0; 127 const StatusCallback& callback) = 0;
130 128
131 // Retrieves the information about a file. 129 // Retrieves the information about a file.
132 // 130 //
133 // LocalFileSystemOperation::GetMetadata calls this. 131 // LocalFileSystemOperation::GetMetadata calls this.
134 // 132 //
135 // This returns false if it fails to post an async task.
136 //
137 // This reports following error code via |callback|: 133 // This reports following error code via |callback|:
138 // - PLATFORM_FILE_ERROR_NOT_FOUND if the file doesn't exist. 134 // - PLATFORM_FILE_ERROR_NOT_FOUND if the file doesn't exist.
139 // - Other error code if there was an error while retrieving the file info. 135 // - Other error code if there was an error while retrieving the file info.
140 // 136 //
141 virtual bool GetFileInfo( 137 virtual void GetFileInfo(
142 scoped_ptr<FileSystemOperationContext> context, 138 scoped_ptr<FileSystemOperationContext> context,
143 const FileSystemURL& url, 139 const FileSystemURL& url,
144 const GetFileInfoCallback& callback) = 0; 140 const GetFileInfoCallback& callback) = 0;
145 141
146 // Reads contents of a directory at |path|. 142 // Reads contents of a directory at |path|.
147 // 143 //
148 // LocalFileSystemOperation::ReadDirectory calls this. 144 // LocalFileSystemOperation::ReadDirectory calls this.
149 // 145 //
150 // Note that the |name| field of each entry in |file_list| 146 // Note that the |name| field of each entry in |file_list|
151 // returned by |callback| should have a base file name 147 // returned by |callback| should have a base file name
152 // of the entry relative to the directory, but not an absolute path. 148 // of the entry relative to the directory, but not an absolute path.
153 // 149 //
154 // (E.g. if ReadDirectory is called for a directory 150 // (E.g. if ReadDirectory is called for a directory
155 // 'path/to/dir' and the directory has entries 'a' and 'b', 151 // 'path/to/dir' and the directory has entries 'a' and 'b',
156 // the returned |file_list| should include entries whose names 152 // the returned |file_list| should include entries whose names
157 // are 'a' and 'b', but not '/path/to/dir/a' and '/path/to/dir/b'.) 153 // are 'a' and 'b', but not '/path/to/dir/a' and '/path/to/dir/b'.)
158 // 154 //
159 // This returns false if it fails to post an async task.
160 //
161 // This reports following error code via |callback|: 155 // This reports following error code via |callback|:
162 // - PLATFORM_FILE_ERROR_NOT_FOUND if the target directory doesn't exist. 156 // - PLATFORM_FILE_ERROR_NOT_FOUND if the target directory doesn't exist.
163 // - PLATFORM_FILE_ERROR_NOT_A_DIRECTORY if an entry exists at |url| but 157 // - PLATFORM_FILE_ERROR_NOT_A_DIRECTORY if an entry exists at |url| but
164 // is a file (not a directory). 158 // is a file (not a directory).
165 // 159 //
166 virtual bool ReadDirectory( 160 virtual void ReadDirectory(
167 scoped_ptr<FileSystemOperationContext> context, 161 scoped_ptr<FileSystemOperationContext> context,
168 const FileSystemURL& url, 162 const FileSystemURL& url,
169 const ReadDirectoryCallback& callback) = 0; 163 const ReadDirectoryCallback& callback) = 0;
170 164
171 // Modifies timestamps of a file or directory at |url| with 165 // Modifies timestamps of a file or directory at |url| with
172 // |last_access_time| and |last_modified_time|. The function DOES NOT 166 // |last_access_time| and |last_modified_time|. The function DOES NOT
173 // create a file unlike 'touch' command on Linux. 167 // create a file unlike 'touch' command on Linux.
174 // 168 //
175 // LocalFileSystemOperation::TouchFile calls this. 169 // LocalFileSystemOperation::TouchFile calls this.
176 // This is used only by Pepper/NaCL File API. 170 // This is used only by Pepper/NaCL File API.
177 // 171 //
178 // This returns false if it fails to post an async task. 172 virtual void Touch(
179 virtual bool Touch(
180 scoped_ptr<FileSystemOperationContext> context, 173 scoped_ptr<FileSystemOperationContext> context,
181 const FileSystemURL& url, 174 const FileSystemURL& url,
182 const base::Time& last_access_time, 175 const base::Time& last_access_time,
183 const base::Time& last_modified_time, 176 const base::Time& last_modified_time,
184 const StatusCallback& callback) = 0; 177 const StatusCallback& callback) = 0;
185 178
186 // Truncates a file at |path| to |length|. If |length| is larger than 179 // Truncates a file at |path| to |length|. If |length| is larger than
187 // the original file size, the file will be extended, and the extended 180 // the original file size, the file will be extended, and the extended
188 // part is filled with null bytes. 181 // part is filled with null bytes.
189 // 182 //
190 // LocalFileSystemOperation::Truncate calls this. 183 // LocalFileSystemOperation::Truncate calls this.
191 // 184 //
192 // This returns false if it fails to post an async task.
193 //
194 // This reports following error code via |callback|: 185 // This reports following error code via |callback|:
195 // - PLATFORM_FILE_ERROR_NOT_FOUND if the file doesn't exist. 186 // - PLATFORM_FILE_ERROR_NOT_FOUND if the file doesn't exist.
196 // 187 //
197 virtual bool Truncate( 188 virtual void Truncate(
198 scoped_ptr<FileSystemOperationContext> context, 189 scoped_ptr<FileSystemOperationContext> context,
199 const FileSystemURL& url, 190 const FileSystemURL& url,
200 int64 length, 191 int64 length,
201 const StatusCallback& callback) = 0; 192 const StatusCallback& callback) = 0;
202 193
203 // Copies a file from |src_url| to |dest_url|. 194 // Copies a file from |src_url| to |dest_url|.
204 // This must be called for files that belong to the same filesystem 195 // This must be called for files that belong to the same filesystem
205 // (i.e. type() and origin() of the |src_url| and |dest_url| must match). 196 // (i.e. type() and origin() of the |src_url| and |dest_url| must match).
206 // 197 //
207 // LocalFileSystemOperation::Copy calls this for same-filesystem copy case. 198 // LocalFileSystemOperation::Copy calls this for same-filesystem copy case.
208 // 199 //
209 // This returns false if it fails to post an async task.
210 //
211 // This reports following error code via |callback|: 200 // This reports following error code via |callback|:
212 // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url| 201 // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
213 // or the parent directory of |dest_url| does not exist. 202 // or the parent directory of |dest_url| does not exist.
214 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file. 203 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
215 // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and 204 // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
216 // is not a file. 205 // is not a file.
217 // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and 206 // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
218 // its parent path is a file. 207 // its parent path is a file.
219 // 208 //
220 virtual bool CopyFileLocal( 209 virtual void CopyFileLocal(
221 scoped_ptr<FileSystemOperationContext> context, 210 scoped_ptr<FileSystemOperationContext> context,
222 const FileSystemURL& src_url, 211 const FileSystemURL& src_url,
223 const FileSystemURL& dest_url, 212 const FileSystemURL& dest_url,
224 const StatusCallback& callback) = 0; 213 const StatusCallback& callback) = 0;
225 214
226 // Moves a local file from |src_url| to |dest_url|. 215 // Moves a local file from |src_url| to |dest_url|.
227 // This must be called for files that belong to the same filesystem 216 // This must be called for files that belong to the same filesystem
228 // (i.e. type() and origin() of the |src_url| and |dest_url| must match). 217 // (i.e. type() and origin() of the |src_url| and |dest_url| must match).
229 // 218 //
230 // LocalFileSystemOperation::Move calls this for same-filesystem move case. 219 // LocalFileSystemOperation::Move calls this for same-filesystem move case.
231 // 220 //
232 // This returns false if it fails to post an async task.
233 //
234 // This reports following error code via |callback|: 221 // This reports following error code via |callback|:
235 // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url| 222 // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
236 // or the parent directory of |dest_url| does not exist. 223 // or the parent directory of |dest_url| does not exist.
237 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file. 224 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
238 // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and 225 // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
239 // is not a file. 226 // is not a file.
240 // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and 227 // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
241 // its parent path is a file. 228 // its parent path is a file.
242 // 229 //
243 virtual bool MoveFileLocal( 230 virtual void MoveFileLocal(
244 scoped_ptr<FileSystemOperationContext> context, 231 scoped_ptr<FileSystemOperationContext> context,
245 const FileSystemURL& src_url, 232 const FileSystemURL& src_url,
246 const FileSystemURL& dest_url, 233 const FileSystemURL& dest_url,
247 const StatusCallback& callback) = 0; 234 const StatusCallback& callback) = 0;
248 235
249 // Copies in a single file from a different filesystem. 236 // Copies in a single file from a different filesystem.
250 // 237 //
251 // LocalFileSystemOperation::Copy or Move calls this for cross-filesystem 238 // LocalFileSystemOperation::Copy or Move calls this for cross-filesystem
252 // cases. 239 // cases.
253 // 240 //
254 // This returns false if it fails to post an async task.
255 //
256 // This reports following error code via |callback|: 241 // This reports following error code via |callback|:
257 // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_file_path| 242 // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_file_path|
258 // or the parent directory of |dest_url| does not exist. 243 // or the parent directory of |dest_url| does not exist.
259 // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and 244 // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
260 // is not a file. 245 // is not a file.
261 // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and 246 // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
262 // its parent path is a file. 247 // its parent path is a file.
263 // 248 //
264 virtual bool CopyInForeignFile( 249 virtual void CopyInForeignFile(
265 scoped_ptr<FileSystemOperationContext> context, 250 scoped_ptr<FileSystemOperationContext> context,
266 const base::FilePath& src_file_path, 251 const base::FilePath& src_file_path,
267 const FileSystemURL& dest_url, 252 const FileSystemURL& dest_url,
268 const StatusCallback& callback) = 0; 253 const StatusCallback& callback) = 0;
269 254
270 // Deletes a single file. 255 // Deletes a single file.
271 // 256 //
272 // LocalFileSystemOperation::RemoveFile calls this. 257 // LocalFileSystemOperation::RemoveFile calls this.
273 // 258 //
274 // This returns false if it fails to post an async task.
275 //
276 // This reports following error code via |callback|: 259 // This reports following error code via |callback|:
277 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. 260 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
278 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| is not a file. 261 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| is not a file.
279 // 262 //
280 virtual bool DeleteFile( 263 virtual void DeleteFile(
281 scoped_ptr<FileSystemOperationContext> context, 264 scoped_ptr<FileSystemOperationContext> context,
282 const FileSystemURL& url, 265 const FileSystemURL& url,
283 const StatusCallback& callback) = 0; 266 const StatusCallback& callback) = 0;
284 267
285 // Removes a single empty directory. 268 // Removes a single empty directory.
286 // 269 //
287 // LocalFileSystemOperation::RemoveDirectory calls this. 270 // LocalFileSystemOperation::RemoveDirectory calls this.
288 // 271 //
289 // This returns false if it fails to post an async task.
290 //
291 // This reports following error code via |callback|: 272 // This reports following error code via |callback|:
292 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. 273 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
293 // - PLATFORM_FILE_ERROR_NOT_A_DIRECTORY if |url| is not a directory. 274 // - PLATFORM_FILE_ERROR_NOT_A_DIRECTORY if |url| is not a directory.
294 // - PLATFORM_FILE_ERROR_NOT_EMPTY if |url| is not empty. 275 // - PLATFORM_FILE_ERROR_NOT_EMPTY if |url| is not empty.
295 // 276 //
296 virtual bool DeleteDirectory( 277 virtual void DeleteDirectory(
297 scoped_ptr<FileSystemOperationContext> context, 278 scoped_ptr<FileSystemOperationContext> context,
298 const FileSystemURL& url, 279 const FileSystemURL& url,
299 const StatusCallback& callback) = 0; 280 const StatusCallback& callback) = 0;
300 281
301 // Removes a single file or a single directory with its contents 282 // Removes a single file or a single directory with its contents
302 // (i.e. files/subdirectories under the directory). 283 // (i.e. files/subdirectories under the directory).
303 // 284 //
304 // LocalFileSystemOperation::Remove calls this. 285 // LocalFileSystemOperation::Remove calls this.
305 // On some platforms, such as Chrome OS Drive File System, recursive file 286 // On some platforms, such as Chrome OS Drive File System, recursive file
306 // deletion can be implemented more efficiently than calling DeleteFile() and 287 // deletion can be implemented more efficiently than calling DeleteFile() and
307 // DeleteDirectory() for each files/directories. 288 // DeleteDirectory() for each files/directories.
308 // This method is optional, so if not supported, 289 // This method is optional, so if not supported,
309 // PLATFORM_ERROR_INVALID_OPERATION should be returned via |callback|. 290 // PLATFORM_ERROR_INVALID_OPERATION should be returned via |callback|.
310 // 291 //
311 // This returns false if it fails to post an async task.
312 //
313 // This reports following error code via |callback|: 292 // This reports following error code via |callback|:
314 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. 293 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
315 // - PLATFORM_ERROR_INVALID_OPERATION if this operation is not supported. 294 // - PLATFORM_ERROR_INVALID_OPERATION if this operation is not supported.
316 virtual bool DeleteRecursively( 295 virtual void DeleteRecursively(
317 scoped_ptr<FileSystemOperationContext> context, 296 scoped_ptr<FileSystemOperationContext> context,
318 const FileSystemURL& url, 297 const FileSystemURL& url,
319 const StatusCallback& callback) = 0; 298 const StatusCallback& callback) = 0;
320 299
321 // Creates a local snapshot file for a given |url| and returns the 300 // Creates a local snapshot file for a given |url| and returns the
322 // metadata and platform path of the snapshot file via |callback|. 301 // metadata and platform path of the snapshot file via |callback|.
323 // In regular filesystem cases the implementation may simply return 302 // In regular filesystem cases the implementation may simply return
324 // the metadata of the file itself (as well as GetMetadata does), 303 // the metadata of the file itself (as well as GetMetadata does),
325 // while in non-regular filesystem case the backend may create a 304 // while in non-regular filesystem case the backend may create a
326 // temporary snapshot file which holds the file data and return 305 // temporary snapshot file which holds the file data and return
327 // the metadata of the temporary file. 306 // the metadata of the temporary file.
328 // 307 //
329 // In the callback, it returns: 308 // In the callback, it returns:
330 // |file_info| is the metadata of the snapshot file created. 309 // |file_info| is the metadata of the snapshot file created.
331 // |platform_path| is the full absolute platform path to the snapshot 310 // |platform_path| is the full absolute platform path to the snapshot
332 // file created. If a file is not backed by a real local file in 311 // file created. If a file is not backed by a real local file in
333 // the implementor's FileSystem, the implementor must create a 312 // the implementor's FileSystem, the implementor must create a
334 // local snapshot file and return the path of the created file. 313 // local snapshot file and return the path of the created file.
335 // 314 //
336 // If implementors creates a temporary file for snapshotting and wants 315 // If implementors creates a temporary file for snapshotting and wants
337 // FileAPI backend to take care of the lifetime of the file (so that 316 // FileAPI backend to take care of the lifetime of the file (so that
338 // it won't get deleted while JS layer has any references to the created 317 // it won't get deleted while JS layer has any references to the created
339 // File/Blob object), it should return non-empty |file_ref|. 318 // File/Blob object), it should return non-empty |file_ref|.
340 // Via the |file_ref| implementors can schedule a file deletion 319 // Via the |file_ref| implementors can schedule a file deletion
341 // or arbitrary callbacks when the last reference of File/Blob is dropped. 320 // or arbitrary callbacks when the last reference of File/Blob is dropped.
342 // 321 //
343 // LocalFileSystemOperation::CreateSnapshotFile calls this. 322 // LocalFileSystemOperation::CreateSnapshotFile calls this.
344 // 323 //
345 // This returns false if it fails to post an async task.
346 //
347 // This reports following error code via |callback|: 324 // This reports following error code via |callback|:
348 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. 325 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
349 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| exists but is a directory. 326 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| exists but is a directory.
350 // 327 //
351 // The field values of |file_info| are undefined (implementation 328 // The field values of |file_info| are undefined (implementation
352 // dependent) in error cases, and the caller should always 329 // dependent) in error cases, and the caller should always
353 // check the return code. 330 // check the return code.
354 virtual bool CreateSnapshotFile( 331 virtual void CreateSnapshotFile(
355 scoped_ptr<FileSystemOperationContext> context, 332 scoped_ptr<FileSystemOperationContext> context,
356 const FileSystemURL& url, 333 const FileSystemURL& url,
357 const CreateSnapshotFileCallback& callback) = 0; 334 const CreateSnapshotFileCallback& callback) = 0;
358 335
359 private: 336 private:
360 DISALLOW_COPY_AND_ASSIGN(AsyncFileUtil); 337 DISALLOW_COPY_AND_ASSIGN(AsyncFileUtil);
361 }; 338 };
362 339
363 } // namespace fileapi 340 } // namespace fileapi
364 341
365 #endif // WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_UTIL_H_ 342 #endif // WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698