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_OPERATION_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 int64 usage, int64 quota); | 166 int64 usage, int64 quota); |
167 | 167 |
168 // The 'body' methods that perform the actual work (i.e. posting the | 168 // The 'body' methods that perform the actual work (i.e. posting the |
169 // file task on proxy_) after the quota check. | 169 // file task on proxy_) after the quota check. |
170 void DoCreateFile(const StatusCallback& callback, bool exclusive); | 170 void DoCreateFile(const StatusCallback& callback, bool exclusive); |
171 void DoCreateDirectory(const StatusCallback& callback, | 171 void DoCreateDirectory(const StatusCallback& callback, |
172 bool exclusive, | 172 bool exclusive, |
173 bool recursive); | 173 bool recursive); |
174 void DoCopy(const StatusCallback& callback); | 174 void DoCopy(const StatusCallback& callback); |
175 void DoMove(const StatusCallback& callback); | 175 void DoMove(const StatusCallback& callback); |
176 void DoWrite(); | 176 void DoWrite(scoped_ptr<net::URLRequest> blob_request); |
177 void DoTruncate(const StatusCallback& callback, int64 length); | 177 void DoTruncate(const StatusCallback& callback, int64 length); |
178 void DoOpenFile(const OpenFileCallback& callback, int file_flags); | 178 void DoOpenFile(const OpenFileCallback& callback, int file_flags); |
179 | 179 |
180 // Callback for CreateFile for |exclusive|=true cases. | 180 // Callback for CreateFile for |exclusive|=true cases. |
181 void DidEnsureFileExistsExclusive(const StatusCallback& callback, | 181 void DidEnsureFileExistsExclusive(const StatusCallback& callback, |
182 base::PlatformFileError rv, | 182 base::PlatformFileError rv, |
183 bool created); | 183 bool created); |
184 | 184 |
185 // Callback for CreateFile for |exclusive|=false cases. | 185 // Callback for CreateFile for |exclusive|=false cases. |
186 void DidEnsureFileExistsNonExclusive(const StatusCallback& callback, | 186 void DidEnsureFileExistsNonExclusive(const StatusCallback& callback, |
(...skipping 24 matching lines...) Expand all Loading... |
211 int64 bytes, | 211 int64 bytes, |
212 bool complete); | 212 bool complete); |
213 void DidTouchFile(const StatusCallback& callback, | 213 void DidTouchFile(const StatusCallback& callback, |
214 base::PlatformFileError rv); | 214 base::PlatformFileError rv); |
215 void DidOpenFile(const OpenFileCallback& callback, | 215 void DidOpenFile(const OpenFileCallback& callback, |
216 base::PlatformFileError rv, | 216 base::PlatformFileError rv, |
217 base::PassPlatformFile file, | 217 base::PassPlatformFile file, |
218 bool created); | 218 bool created); |
219 | 219 |
220 // Helper for Write(). | 220 // Helper for Write(). |
221 void OnFileOpenedForWrite(base::PlatformFileError rv, | 221 void OnFileOpenedForWrite(scoped_ptr<net::URLRequest> blob_request, |
| 222 FileSystemOperationContext* context_unused, |
| 223 base::PlatformFileError rv, |
222 base::PassPlatformFile file, | 224 base::PassPlatformFile file, |
223 bool created); | 225 bool created); |
224 | 226 |
225 // Checks the validity of a given |path_url| and and populates | 227 // Checks the validity of a given |path_url| and and populates |
226 // |path| and |file_util| for |mode|. | 228 // |path| and |file_util| for |mode|. |
227 base::PlatformFileError SetUpFileSystemPath( | 229 base::PlatformFileError SetUpFileSystemPath( |
228 const GURL& path_url, | 230 const GURL& path_url, |
229 FileSystemPath* file_system_path, | 231 FileSystemPath* file_system_path, |
230 FileSystemFileUtil** file_util, | 232 FileSystemFileUtil** file_util, |
231 SetUpPathMode mode); | 233 SetUpPathMode mode); |
(...skipping 10 matching lines...) Expand all Loading... |
242 | 244 |
243 // This is set before any write operations. The destructor of | 245 // This is set before any write operations. The destructor of |
244 // ScopedQuotaNotifier sends notification to the QuotaManager | 246 // ScopedQuotaNotifier sends notification to the QuotaManager |
245 // to tell the update is done; so that we can make sure notify | 247 // to tell the update is done; so that we can make sure notify |
246 // the manager after any write operations are done. | 248 // the manager after any write operations are done. |
247 scoped_ptr<ScopedQuotaNotifier> scoped_quota_notifier_; | 249 scoped_ptr<ScopedQuotaNotifier> scoped_quota_notifier_; |
248 | 250 |
249 // These are all used only by Write(). | 251 // These are all used only by Write(). |
250 friend class FileWriterDelegate; | 252 friend class FileWriterDelegate; |
251 scoped_ptr<FileWriterDelegate> file_writer_delegate_; | 253 scoped_ptr<FileWriterDelegate> file_writer_delegate_; |
252 scoped_ptr<net::URLRequest> blob_request_; | |
253 | 254 |
254 // write_callback is kept in this class for so that we can dispatch it when | 255 // write_callback is kept in this class for so that we can dispatch it when |
255 // the operation is cancelled. calcel_callback is kept for canceling a | 256 // the operation is cancelled. calcel_callback is kept for canceling a |
256 // Truncate() operation. We can't actually stop Truncate in another thread; | 257 // Truncate() operation. We can't actually stop Truncate in another thread; |
257 // after it resumed from the working thread, cancellation takes place. | 258 // after it resumed from the working thread, cancellation takes place. |
258 WriteCallback write_callback_; | 259 WriteCallback write_callback_; |
259 StatusCallback cancel_callback_; | 260 StatusCallback cancel_callback_; |
260 void set_write_callback(const WriteCallback& write_callback) { | 261 void set_write_callback(const WriteCallback& write_callback) { |
261 write_callback_ = write_callback; | 262 write_callback_ = write_callback; |
262 } | 263 } |
263 | 264 |
264 // Used only by OpenFile, in order to clone the file handle back to the | 265 // Used only by OpenFile, in order to clone the file handle back to the |
265 // requesting process. | 266 // requesting process. |
266 base::ProcessHandle peer_handle_; | 267 base::ProcessHandle peer_handle_; |
267 | 268 |
268 // A flag to make sure we call operation only once per instance. | 269 // A flag to make sure we call operation only once per instance. |
269 OperationType pending_operation_; | 270 OperationType pending_operation_; |
270 | 271 |
| 272 // FileSystemOperation instance is usually deleted upon completion but |
| 273 // could be deleted while it has inflight callbacks when Cancel is called. |
| 274 base::WeakPtrFactory<FileSystemOperation> weak_factory_; |
| 275 |
271 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); | 276 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); |
272 }; | 277 }; |
273 | 278 |
274 } // namespace fileapi | 279 } // namespace fileapi |
275 | 280 |
276 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 281 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
OLD | NEW |