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

Side by Side Diff: webkit/chromeos/fileapi/file_util_async.h

Issue 8907014: Implement async verision of FileSystemFileUtil and in-memory file system for testing purposes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 9 years 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
« no previous file with comments | « webkit/chromeos/fileapi/async_file_stream.h ('k') | webkit/chromeos/fileapi/memory_file_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 WEBKIT_CHROMEOS_FILEAPI_FILE_SYSTEM_FILE_UTIL_ASYNC_H_
6 #define WEBKIT_CHROMEOS_FILEAPI_FILE_SYSTEM_FILE_UTIL_ASYNC_H_
7
8 #include "base/callback.h"
9 #include "base/file_util_proxy.h"
10 #include "base/platform_file.h"
11 #include "webkit/chromeos/fileapi/async_file_stream.h"
12
13 namespace fileapi {
14
15 using base::PlatformFileError;
16
17 // The interface class of asynchronous file utils. All functions are pure
18 // virtual.
19 class FileUtilAsync {
20 public:
21 virtual ~FileUtilAsync() {}
22
23 typedef base::FileUtilProxy::Entry DirectoryEntry;
24
25 // Used for GetFileInfo(). |result| is the return code of the operation,
26 // and |file_info| is the obtained file info.
27 typedef base::Callback<void(
28 PlatformFileError result,
29 const base::PlatformFileInfo& file_info)> GetFileInfoCallback;
30
31 // Used for Create(), etc. |result| is the return code of the operation.
32 typedef base::Callback<void(PlatformFileError)> StatusCallback;
33
34 // Used for Open(). |result| is the return code of the operation, and
35 // |stream| is the stream of the opened file.
36 typedef base::Callback<void(
37 PlatformFileError result,
38 AsyncFileStream* stream)> OpenCallback;
39
40 typedef std::vector<DirectoryEntry> FileList;
41
42 // Used for ReadDirectoryCallback(). |result| is the return code of the
43 // operation, |file_list| is the list of files read, and |completed| is
44 // true if all files are read.
45 typedef base::Callback<void(
46 PlatformFileError result,
47 const FileList& file_list,
48 bool completed)> ReadDirectoryCallback;
49
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
52 // created AsyncFileStream object. The caller should delete the
53 // stream. On failure, an error code is passed instead.
54 virtual void Open(const FilePath& file_path,
55 int file_flags, // PlatformFileFlags
56 const OpenCallback& callback) = 0;
57
58 // Gets file info of the given |file_path|. On success,
59 // PLATFORM_FILE_OK is passed to |callback| with the the obtained file
60 // info. On failure, an error code is passed instead.
61 virtual void GetFileInfo(const FilePath& file_path,
62 const GetFileInfoCallback& callback) = 0;
63
64 // Creates a file of the given |file_path|. On success,
65 // PLATFORM_FILE_OK is passed to |callback|. On failure, an error code
66 // is passed instead.
67 virtual void Create(const FilePath& file_path,
68 const StatusCallback& callback) = 0;
69
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
72 // is passed instead.
73 virtual void Truncate(const FilePath& file_path,
74 int64 length,
75 const StatusCallback& callback) = 0;
76
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
79 // error code is passed instead.
80 virtual void Touch(const FilePath& file_path,
81 const base::Time& last_access_time,
82 const base::Time& last_modified_time,
83 const StatusCallback& callback) = 0;
84
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
87 // success, PLATFORM_FILE_OK is passed to |callback|. On failure, an
88 // error code is passed instead.
89 virtual void Remove(const FilePath& file_path,
90 bool recursive,
91 const StatusCallback& callback) = 0;
92
93 // Creates a directory of the given |dir_path|. On success,
94 // PLATFORM_FILE_OK is passed to |callback|. On failure, an error code
95 // is passed instead.
96 virtual void CreateDirectory(const FilePath& dir_path,
97 const StatusCallback& callback) = 0;
98
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
101 // a boolean value indicating if all files are read. On failure, an
102 // error code is passed instead.
103 //
104 // The ReadDirectoryCallback may be called several times, returning the
105 // portions of the whole directory listing. The reference to vector with
106 // DirectoryEntry objects, passed to callback is guaranteed to contain the
107 // results of the operation only while callback is running.
108 //
109 // The implementations of FileUtilAsync should be careful to populate the
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
112 // before callback is actually called.
113 //
114 // TODO(olege): Maybe make it possible to read only a part of the directory.
115 virtual void ReadDirectory(const FilePath& dir_path,
116 const ReadDirectoryCallback& callback) = 0;
117
118 // TODO(olege): Add LocalCopy and LocalMove.
119 };
120
121 } // fileapi
122
123 #endif // WEBKIT_CHROMEOS_FILEAPI_FILE_SYSTEM_FILE_UTIL_ASYNC_H_
OLDNEW
« no previous file with comments | « webkit/chromeos/fileapi/async_file_stream.h ('k') | webkit/chromeos/fileapi/memory_file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698