| 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 16 matching lines...) Expand all Loading... |
| 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 // | 34 // |
| 35 // Some operations (e.g. CopyInForeignFile, RemoveFile, RemoveDirectory, | 35 // Some operations (e.g. CopyInForeignFile, RemoveFile, RemoveDirectory, |
| 36 // CopyFileLocal, MoveFileLocal and SyncGetPlatformPath) are only supported | 36 // CopyFileLocal, MoveFileLocal and SyncGetPlatformPath) are only supported |
| 37 // by filesystems which implement LocalFileSystemOperation. | 37 // by filesystems which implement FileSystemOperationImpl. |
| 38 // If they are called on other filesystems | 38 // If they are called on other filesystems |
| 39 // base::PLATFORM_FILE_ERROR_INVALID_OPERATION is returned via callback. | 39 // base::PLATFORM_FILE_ERROR_INVALID_OPERATION is returned via callback. |
| 40 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner | 40 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner |
| 41 : public base::SupportsWeakPtr<FileSystemOperationRunner> { | 41 : public base::SupportsWeakPtr<FileSystemOperationRunner> { |
| 42 public: | 42 public: |
| 43 typedef FileSystemOperation::GetMetadataCallback GetMetadataCallback; | 43 typedef FileSystemOperation::GetMetadataCallback GetMetadataCallback; |
| 44 typedef FileSystemOperation::ReadDirectoryCallback ReadDirectoryCallback; | 44 typedef FileSystemOperation::ReadDirectoryCallback ReadDirectoryCallback; |
| 45 typedef FileSystemOperation::SnapshotFileCallback SnapshotFileCallback; | 45 typedef FileSystemOperation::SnapshotFileCallback SnapshotFileCallback; |
| 46 typedef FileSystemOperation::StatusCallback StatusCallback; | 46 typedef FileSystemOperation::StatusCallback StatusCallback; |
| 47 typedef FileSystemOperation::WriteCallback WriteCallback; | 47 typedef FileSystemOperation::WriteCallback WriteCallback; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 const base::Closure& on_close_callback, | 256 const base::Closure& on_close_callback, |
| 257 base::ProcessHandle peer_handle); | 257 base::ProcessHandle peer_handle); |
| 258 void DidCreateSnapshot( | 258 void DidCreateSnapshot( |
| 259 OperationID id, | 259 OperationID id, |
| 260 const SnapshotFileCallback& callback, | 260 const SnapshotFileCallback& callback, |
| 261 base::PlatformFileError rv, | 261 base::PlatformFileError rv, |
| 262 const base::PlatformFileInfo& file_info, | 262 const base::PlatformFileInfo& file_info, |
| 263 const base::FilePath& platform_path, | 263 const base::FilePath& platform_path, |
| 264 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); | 264 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); |
| 265 | 265 |
| 266 // A helper method for creating LocalFileSystemOperation for operations | 266 // A helper method for creating FileSystemOperationImpl for operations |
| 267 // that are supported only in LocalFileSystemOperation. | 267 // that are supported only in FileSystemOperationImpl. |
| 268 // Note that this returns FileSystemOperation, so the caller needs to | 268 // Note that this returns FileSystemOperation, so the caller needs to |
| 269 // call AsLocalFileSystemOperation() (which is guaranteed to be non-null | 269 // call AsFileSystemOperationImpl() (which is guaranteed to be non-null |
| 270 // if this method returns without error). | 270 // if this method returns without error). |
| 271 FileSystemOperation* CreateLocalFileSystemOperation( | 271 FileSystemOperation* CreateFileSystemOperationImpl( |
| 272 const FileSystemURL& url, | 272 const FileSystemURL& url, |
| 273 base::PlatformFileError* error); | 273 base::PlatformFileError* error); |
| 274 | 274 |
| 275 void PrepareForWrite(OperationID id, const FileSystemURL& url); | 275 void PrepareForWrite(OperationID id, const FileSystemURL& url); |
| 276 void PrepareForRead(OperationID id, const FileSystemURL& url); | 276 void PrepareForRead(OperationID id, const FileSystemURL& url); |
| 277 | 277 |
| 278 // This must be called at the end of any async operations. | 278 // This must be called at the end of any async operations. |
| 279 void FinishOperation(OperationID id); | 279 void FinishOperation(OperationID id); |
| 280 | 280 |
| 281 // Not owned; file_system_context owns this. | 281 // Not owned; file_system_context owns this. |
| 282 FileSystemContext* file_system_context_; | 282 FileSystemContext* file_system_context_; |
| 283 | 283 |
| 284 // IDMap<FileSystemOperation, IDMapOwnPointer> operations_; | 284 // IDMap<FileSystemOperation, IDMapOwnPointer> operations_; |
| 285 IDMap<FileSystemOperation, IDMapOwnPointer> operations_; | 285 IDMap<FileSystemOperation, IDMapOwnPointer> operations_; |
| 286 | 286 |
| 287 // We keep track of the file to be modified by each operation so that | 287 // We keep track of the file to be modified by each operation so that |
| 288 // we can notify observers when we're done. | 288 // we can notify observers when we're done. |
| 289 typedef std::map<OperationID, FileSystemURLSet> OperationToURLSet; | 289 typedef std::map<OperationID, FileSystemURLSet> OperationToURLSet; |
| 290 OperationToURLSet write_target_urls_; | 290 OperationToURLSet write_target_urls_; |
| 291 | 291 |
| 292 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationRunner); | 292 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationRunner); |
| 293 }; | 293 }; |
| 294 | 294 |
| 295 } // namespace fileapi | 295 } // namespace fileapi |
| 296 | 296 |
| 297 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_RUNNER_H_ | 297 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_RUNNER_H_ |
| OLD | NEW |