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

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

Issue 14075016: Change some snapshot- or temporary-file related changes to use ScopedFile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 7 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_FILEAPI_ASYNC_FILE_UTIL_H_ 5 #ifndef WEBKIT_FILEAPI_ASYNC_FILE_UTIL_H_
6 #define WEBKIT_FILEAPI_ASYNC_FILE_UTIL_H_ 6 #define WEBKIT_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"
11 #include "base/platform_file.h" 11 #include "base/platform_file.h"
12 #include "webkit/fileapi/file_snapshot_policy.h"
13 #include "webkit/storage/webkit_storage_export.h" 12 #include "webkit/storage/webkit_storage_export.h"
14 13
15 namespace base { 14 namespace base {
16 class Time; 15 class Time;
17 } 16 }
18 17
18 namespace webkit_blob {
19 class ShareableFileReference;
20 }
21
19 namespace fileapi { 22 namespace fileapi {
20 23
21 class FileSystemOperationContext; 24 class FileSystemOperationContext;
22 class FileSystemURL; 25 class FileSystemURL;
23 26
24 // An interface which provides filesystem-specific file operations for 27 // An interface which provides filesystem-specific file operations for
25 // LocalFileSystemOperation. 28 // LocalFileSystemOperation.
26 // 29 //
27 // Each filesystem which needs to be dispatched from LocalFileSystemOperation 30 // Each filesystem which needs to be dispatched from LocalFileSystemOperation
28 // must implement this interface or a synchronous version of interface: 31 // must implement this interface or a synchronous version of interface:
(...skipping 19 matching lines...) Expand all
48 typedef std::vector<base::FileUtilProxy::Entry> EntryList; 51 typedef std::vector<base::FileUtilProxy::Entry> EntryList;
49 typedef base::Callback< 52 typedef base::Callback<
50 void(base::PlatformFileError result, 53 void(base::PlatformFileError result,
51 const EntryList& file_list, 54 const EntryList& file_list,
52 bool has_more)> ReadDirectoryCallback; 55 bool has_more)> ReadDirectoryCallback;
53 56
54 typedef base::Callback< 57 typedef base::Callback<
55 void(base::PlatformFileError result, 58 void(base::PlatformFileError result,
56 const base::PlatformFileInfo& file_info, 59 const base::PlatformFileInfo& file_info,
57 const base::FilePath& platform_path, 60 const base::FilePath& platform_path,
58 SnapshotFilePolicy policy)> CreateSnapshotFileCallback; 61 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref
62 )> CreateSnapshotFileCallback;
59 63
60 AsyncFileUtil() {} 64 AsyncFileUtil() {}
61 virtual ~AsyncFileUtil() {} 65 virtual ~AsyncFileUtil() {}
62 66
63 // Creates or opens a file with the given flags. 67 // Creates or opens a file with the given flags.
64 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create 68 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create
65 // a new file at the given |url| and calls back with 69 // a new file at the given |url| and calls back with
66 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |url| already exists. 70 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |url| already exists.
67 // 71 //
68 // LocalFileSystemOperation::OpenFile calls this. 72 // LocalFileSystemOperation::OpenFile calls this.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 // Creates a local snapshot file for a given |url| and returns the 294 // Creates a local snapshot file for a given |url| and returns the
291 // metadata and platform path of the snapshot file via |callback|. 295 // metadata and platform path of the snapshot file via |callback|.
292 // In regular filesystem cases the implementation may simply return 296 // In regular filesystem cases the implementation may simply return
293 // the metadata of the file itself (as well as GetMetadata does), 297 // the metadata of the file itself (as well as GetMetadata does),
294 // while in non-regular filesystem case the backend may create a 298 // while in non-regular filesystem case the backend may create a
295 // temporary snapshot file which holds the file data and return 299 // temporary snapshot file which holds the file data and return
296 // the metadata of the temporary file. 300 // the metadata of the temporary file.
297 // 301 //
298 // In the callback, it returns: 302 // In the callback, it returns:
299 // |file_info| is the metadata of the snapshot file created. 303 // |file_info| is the metadata of the snapshot file created.
300 // |platform_path| is the path to the snapshot file created. 304 // |platform_path| is the full absolute platform path to the snapshot
301 // |policy| should indicate the policy how the fileapi backend 305 // file created. If a file is not backed by a real local file in
302 // should handle the returned file. 306 // the implementor's FileSystem, the implementor must create a
307 // local snapshot file and return the path of the created file.
308 //
309 // If implementors creates a temporary file for snapshotting and wants
310 // FileAPI backend to take care of the lifetime of the file (so that
311 // it won't get deleted while JS layer has any references to the created
312 // File/Blob object), it should return non-empty |file_ref|.
313 // Via the |file_ref| implementors can schedule a file deletion
314 // or arbitrary callbacks when the last reference of File/Blob is dropped.
303 // 315 //
304 // LocalFileSystemOperation::CreateSnapshotFile calls this. 316 // LocalFileSystemOperation::CreateSnapshotFile calls this.
305 // 317 //
306 // This returns false if it fails to post an async task. 318 // This returns false if it fails to post an async task.
307 // 319 //
308 // This reports following error code via |callback|: 320 // This reports following error code via |callback|:
309 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. 321 // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
310 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| exists but is a directory. 322 // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| exists but is a directory.
311 // 323 //
312 // The field values of |file_info| are undefined (implementation 324 // The field values of |file_info| are undefined (implementation
313 // dependent) in error cases, and the caller should always 325 // dependent) in error cases, and the caller should always
314 // check the return code. 326 // check the return code.
315 virtual bool CreateSnapshotFile( 327 virtual bool CreateSnapshotFile(
316 FileSystemOperationContext* context, 328 FileSystemOperationContext* context,
317 const FileSystemURL& url, 329 const FileSystemURL& url,
318 const CreateSnapshotFileCallback& callback) = 0; 330 const CreateSnapshotFileCallback& callback) = 0;
319 331
320 private: 332 private:
321 DISALLOW_COPY_AND_ASSIGN(AsyncFileUtil); 333 DISALLOW_COPY_AND_ASSIGN(AsyncFileUtil);
322 }; 334 };
323 335
324 } // namespace fileapi 336 } // namespace fileapi
325 337
326 #endif // WEBKIT_FILEAPI_ASYNC_FILE_UTIL_H_ 338 #endif // WEBKIT_FILEAPI_ASYNC_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_file_sync_service.cc ('k') | webkit/fileapi/async_file_util_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698