| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_FILE_SYSTEM_OPERATION_RUNNER_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_RUNNER_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_RUNNER_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_RUNNER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 class FileSystemURL; | 24 class FileSystemURL; |
| 25 class FileSystemContext; | 25 class FileSystemContext; |
| 26 | 26 |
| 27 // A central interface for running FileSystem API operations. | 27 // A central interface for running FileSystem API operations. |
| 28 // All operation methods take callback and returns OperationID, which is | 28 // All operation methods take callback and returns OperationID, which is |
| 29 // an integer value which can be used for cancelling an operation. | 29 // an integer value which can be used for cancelling an operation. |
| 30 // All operation methods return kErrorOperationID if running (posting) an | 30 // All operation methods return kErrorOperationID if running (posting) an |
| 31 // operation fails, in addition to dispatching the callback with an error | 31 // operation fails, in addition to dispatching the callback with an error |
| 32 // code (therefore in most cases the caller does not need to check the | 32 // code (therefore in most cases the caller does not need to check the |
| 33 // returned operation ID). | 33 // returned operation ID). |
| 34 // | |
| 35 // Some operations (e.g. CopyInForeignFile, RemoveFile, RemoveDirectory, | |
| 36 // CopyFileLocal, MoveFileLocal and SyncGetPlatformPath) are only supported | |
| 37 // by filesystems which implement FileSystemOperationImpl. | |
| 38 // If they are called on other filesystems | |
| 39 // base::PLATFORM_FILE_ERROR_INVALID_OPERATION is returned via callback. | |
| 40 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner | 34 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner |
| 41 : public base::SupportsWeakPtr<FileSystemOperationRunner> { | 35 : public base::SupportsWeakPtr<FileSystemOperationRunner> { |
| 42 public: | 36 public: |
| 43 typedef FileSystemOperation::GetMetadataCallback GetMetadataCallback; | 37 typedef FileSystemOperation::GetMetadataCallback GetMetadataCallback; |
| 44 typedef FileSystemOperation::ReadDirectoryCallback ReadDirectoryCallback; | 38 typedef FileSystemOperation::ReadDirectoryCallback ReadDirectoryCallback; |
| 45 typedef FileSystemOperation::SnapshotFileCallback SnapshotFileCallback; | 39 typedef FileSystemOperation::SnapshotFileCallback SnapshotFileCallback; |
| 46 typedef FileSystemOperation::StatusCallback StatusCallback; | 40 typedef FileSystemOperation::StatusCallback StatusCallback; |
| 47 typedef FileSystemOperation::WriteCallback WriteCallback; | 41 typedef FileSystemOperation::WriteCallback WriteCallback; |
| 48 typedef FileSystemOperation::OpenFileCallback OpenFileCallback; | 42 typedef FileSystemOperation::OpenFileCallback OpenFileCallback; |
| 49 | 43 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 const base::Closure& on_close_callback, | 250 const base::Closure& on_close_callback, |
| 257 base::ProcessHandle peer_handle); | 251 base::ProcessHandle peer_handle); |
| 258 void DidCreateSnapshot( | 252 void DidCreateSnapshot( |
| 259 OperationID id, | 253 OperationID id, |
| 260 const SnapshotFileCallback& callback, | 254 const SnapshotFileCallback& callback, |
| 261 base::PlatformFileError rv, | 255 base::PlatformFileError rv, |
| 262 const base::PlatformFileInfo& file_info, | 256 const base::PlatformFileInfo& file_info, |
| 263 const base::FilePath& platform_path, | 257 const base::FilePath& platform_path, |
| 264 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); | 258 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); |
| 265 | 259 |
| 266 // A helper method for creating FileSystemOperationImpl for operations | |
| 267 // that are supported only in FileSystemOperationImpl. | |
| 268 // Note that this returns FileSystemOperation, so the caller needs to | |
| 269 // call AsFileSystemOperationImpl() (which is guaranteed to be non-null | |
| 270 // if this method returns without error). | |
| 271 FileSystemOperation* CreateFileSystemOperationImpl( | |
| 272 const FileSystemURL& url, | |
| 273 base::PlatformFileError* error); | |
| 274 | |
| 275 void PrepareForWrite(OperationID id, const FileSystemURL& url); | 260 void PrepareForWrite(OperationID id, const FileSystemURL& url); |
| 276 void PrepareForRead(OperationID id, const FileSystemURL& url); | 261 void PrepareForRead(OperationID id, const FileSystemURL& url); |
| 277 | 262 |
| 278 // This must be called at the end of any async operations. | 263 // This must be called at the end of any async operations. |
| 279 void FinishOperation(OperationID id); | 264 void FinishOperation(OperationID id); |
| 280 | 265 |
| 281 // Not owned; file_system_context owns this. | 266 // Not owned; file_system_context owns this. |
| 282 FileSystemContext* file_system_context_; | 267 FileSystemContext* file_system_context_; |
| 283 | 268 |
| 284 // IDMap<FileSystemOperation, IDMapOwnPointer> operations_; | 269 // IDMap<FileSystemOperation, IDMapOwnPointer> operations_; |
| 285 IDMap<FileSystemOperation, IDMapOwnPointer> operations_; | 270 IDMap<FileSystemOperation, IDMapOwnPointer> operations_; |
| 286 | 271 |
| 287 // We keep track of the file to be modified by each operation so that | 272 // We keep track of the file to be modified by each operation so that |
| 288 // we can notify observers when we're done. | 273 // we can notify observers when we're done. |
| 289 typedef std::map<OperationID, FileSystemURLSet> OperationToURLSet; | 274 typedef std::map<OperationID, FileSystemURLSet> OperationToURLSet; |
| 290 OperationToURLSet write_target_urls_; | 275 OperationToURLSet write_target_urls_; |
| 291 | 276 |
| 292 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationRunner); | 277 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationRunner); |
| 293 }; | 278 }; |
| 294 | 279 |
| 295 } // namespace fileapi | 280 } // namespace fileapi |
| 296 | 281 |
| 297 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_RUNNER_H_ | 282 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_RUNNER_H_ |
| OLD | NEW |