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

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

Issue 8424007: Bind: Merge FileUtilProxy and FileSystemFileUtilProxy: Delete/Touch/Truncate/Copy/Move (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased2 Created 9 years, 1 month 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 | « base/file_util_proxy.cc ('k') | webkit/fileapi/file_system_file_util_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_PROXY_H_ 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 17 matching lines...) Expand all
28 using base::PlatformFile; 28 using base::PlatformFile;
29 using base::PlatformFileError; 29 using base::PlatformFileError;
30 using base::PlatformFileInfo; 30 using base::PlatformFileInfo;
31 31
32 // This class provides asynchronous access to common file routines for the 32 // This class provides asynchronous access to common file routines for the
33 // FileSystem API. 33 // FileSystem API.
34 class FileSystemFileUtilProxy { 34 class FileSystemFileUtilProxy {
35 public: 35 public:
36 typedef base::FileUtilProxy::Entry Entry; 36 typedef base::FileUtilProxy::Entry Entry;
37 37
38 typedef base::FileUtilProxy::StatusCallback StatusCallback;
39 typedef base::FileUtilProxy::CreateOrOpenCallback CreateOrOpenCallback;
40 typedef base::Callback<void(PlatformFileError, 38 typedef base::Callback<void(PlatformFileError,
41 bool /* created */ 39 bool /* created */
42 )> EnsureFileExistsCallback; 40 )> EnsureFileExistsCallback;
43 typedef base::Callback<void(PlatformFileError, 41 typedef base::Callback<void(PlatformFileError,
44 const PlatformFileInfo&, 42 const PlatformFileInfo&,
45 const FilePath& /* platform_path */ 43 const FilePath& /* platform_path */
46 )> GetFileInfoCallback; 44 )> GetFileInfoCallback;
47 typedef base::Callback<void(PlatformFileError, 45 typedef base::Callback<void(PlatformFileError,
48 const std::vector<Entry>& 46 const std::vector<Entry>&
49 )> ReadDirectoryCallback; 47 )> ReadDirectoryCallback;
50 48
51 typedef Callback2<PlatformFileError /* error code */,
52 const FilePath& /* local_path, where possible */
53 >::Type GetLocalPathCallback;
54
55 // Creates or opens a file with the given flags. It is invalid to pass NULL
56 // for the callback.
57 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create
58 // a new file at the given |file_path| and calls back with
59 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists.
60 static bool CreateOrOpen(const FileSystemOperationContext& context,
61 scoped_refptr<MessageLoopProxy> message_loop_proxy,
62 const FilePath& file_path,
63 int file_flags,
64 const CreateOrOpenCallback& callback);
65
66 // Close the given file handle.
67 static bool Close(const FileSystemOperationContext& context,
68 scoped_refptr<MessageLoopProxy> message_loop_proxy,
69 PlatformFile,
70 const StatusCallback& callback);
71
72 // Ensures that the given |file_path| exist. This creates a empty new file 49 // Ensures that the given |file_path| exist. This creates a empty new file
73 // at |file_path| if the |file_path| does not exist. 50 // at |file_path| if the |file_path| does not exist.
74 // If a new file han not existed and is created at the |file_path|, 51 // If a new file han not existed and is created at the |file_path|,
75 // |created| of the callback argument is set true and |error code| 52 // |created| of the callback argument is set true and |error code|
76 // is set PLATFORM_FILE_OK. 53 // is set PLATFORM_FILE_OK.
77 // If the file already exists, |created| is set false and |error code| 54 // If the file already exists, |created| is set false and |error code|
78 // is set PLATFORM_FILE_OK. 55 // is set PLATFORM_FILE_OK.
79 // If the file hasn't existed but it couldn't be created for some other 56 // If the file hasn't existed but it couldn't be created for some other
80 // reasons, |created| is set false and |error code| indicates the error. 57 // reasons, |created| is set false and |error code| indicates the error.
81 static bool EnsureFileExists( 58 static bool EnsureFileExists(
82 const FileSystemOperationContext& context, 59 const FileSystemOperationContext& context,
83 scoped_refptr<MessageLoopProxy> message_loop_proxy, 60 scoped_refptr<MessageLoopProxy> message_loop_proxy,
84 const FilePath& file_path, 61 const FilePath& file_path,
85 const EnsureFileExistsCallback& callback); 62 const EnsureFileExistsCallback& callback);
86 63
87 // Maps virtual file patch to its local physical location.
88 static bool GetLocalPath(
89 const FileSystemOperationContext& context,
90 scoped_refptr<MessageLoopProxy> message_loop_proxy,
91 const FilePath& virtual_path,
92 GetLocalPathCallback* callback);
93
94 // Retrieves the information about a file. It is invalid to pass NULL for the 64 // Retrieves the information about a file. It is invalid to pass NULL for the
95 // callback. 65 // callback.
96 static bool GetFileInfo( 66 static bool GetFileInfo(
97 const FileSystemOperationContext& context, 67 const FileSystemOperationContext& context,
98 scoped_refptr<MessageLoopProxy> message_loop_proxy, 68 scoped_refptr<MessageLoopProxy> message_loop_proxy,
99 const FilePath& file_path, 69 const FilePath& file_path,
100 const GetFileInfoCallback& callback); 70 const GetFileInfoCallback& callback);
101 71
102 static bool ReadDirectory(const FileSystemOperationContext& context, 72 static bool ReadDirectory(const FileSystemOperationContext& context,
103 scoped_refptr<MessageLoopProxy> message_loop_proxy, 73 scoped_refptr<MessageLoopProxy> message_loop_proxy,
104 const FilePath& file_path, 74 const FilePath& file_path,
105 const ReadDirectoryCallback& callback); 75 const ReadDirectoryCallback& callback);
106 76
107 // Creates directory at given path. It's an error to create
108 // if |exclusive| is true and dir already exists.
109 static bool CreateDirectory(
110 const FileSystemOperationContext& context,
111 scoped_refptr<MessageLoopProxy> message_loop_proxy,
112 const FilePath& file_path,
113 bool exclusive,
114 bool recursive,
115 const StatusCallback& callback);
116
117 // Copies a file or a directory from |src_file_path| to |dest_file_path|
118 // Error cases:
119 // If destination file doesn't exist or destination's parent
120 // doesn't exists.
121 // If source dir exists but destination path is an existing file.
122 // If source file exists but destination path is an existing directory.
123 // If source is a parent of destination.
124 // If source doesn't exists.
125 static bool Copy(const FileSystemOperationContext& context,
126 scoped_refptr<MessageLoopProxy> message_loop_proxy,
127 const FilePath& src_file_path,
128 const FilePath& dest_file_path,
129 const StatusCallback& callback);
130
131 // Moves a file or a directory from src_file_path to dest_file_path.
132 // Error cases are similar to Copy method's error cases.
133 static bool Move(
134 const FileSystemOperationContext& context,
135 scoped_refptr<MessageLoopProxy> message_loop_proxy,
136 const FilePath& src_file_path,
137 const FilePath& dest_file_path,
138 const StatusCallback& callback);
139
140 // Deletes a file or a directory.
141 // It is an error to delete a non-empty directory with recursive=false.
142 static bool Delete(const FileSystemOperationContext& context,
143 scoped_refptr<MessageLoopProxy> message_loop_proxy,
144 const FilePath& file_path,
145 bool recursive,
146 const StatusCallback& callback);
147
148 // Touches a file. The callback can be NULL.
149 static bool Touch(
150 const FileSystemOperationContext& context,
151 scoped_refptr<MessageLoopProxy> message_loop_proxy,
152 const FilePath& file_path,
153 const base::Time& last_access_time,
154 const base::Time& last_modified_time,
155 const StatusCallback& callback);
156
157 // Truncates a file to the given length. If |length| is greater than the
158 // current length of the file, the file will be extended with zeroes.
159 // The callback can be NULL.
160 static bool Truncate(
161 const FileSystemOperationContext& context,
162 scoped_refptr<MessageLoopProxy> message_loop_proxy,
163 const FilePath& path,
164 int64 length,
165 const StatusCallback& callback);
166
167 private: 77 private:
168 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); 78 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy);
169 }; 79 };
170 80
171 } // namespace fileapi 81 } // namespace fileapi
172 82
173 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ 83 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_
OLDNEW
« no previous file with comments | « base/file_util_proxy.cc ('k') | webkit/fileapi/file_system_file_util_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698