Chromium Code Reviews| Index: webkit/fileapi/file_system_operation.h |
| diff --git a/webkit/fileapi/file_system_operation.h b/webkit/fileapi/file_system_operation.h |
| index fa3161ce57a0054e4060f9fc0254e0edd7ed77f8..ea9430ca6be32d381f561cb7ae55fbb2096febd5 100644 |
| --- a/webkit/fileapi/file_system_operation.h |
| +++ b/webkit/fileapi/file_system_operation.h |
| @@ -39,7 +39,6 @@ class GURL; |
| namespace fileapi { |
| -class FileSystemCallbackDispatcher; |
| class FileSystemContext; |
| class FileWriterDelegate; |
| class FileSystemOperationTest; |
| @@ -51,33 +50,44 @@ class FileSystemOperation : public FileSystemOperationInterface { |
| // FileSystemOperation overrides. |
| virtual void CreateFile(const GURL& path, |
| - bool exclusive) OVERRIDE; |
| + bool exclusive, |
| + const StatusCallback& callback) OVERRIDE; |
| virtual void CreateDirectory(const GURL& path, |
| bool exclusive, |
| - bool recursive) OVERRIDE; |
| + bool recursive, |
| + const StatusCallback& callback) OVERRIDE; |
| virtual void Copy(const GURL& src_path, |
| - const GURL& dest_path) OVERRIDE; |
| + const GURL& dest_path, |
| + const StatusCallback& callback) OVERRIDE; |
| virtual void Move(const GURL& src_path, |
| - const GURL& dest_path) OVERRIDE; |
| - virtual void DirectoryExists(const GURL& path) OVERRIDE; |
| - virtual void FileExists(const GURL& path) OVERRIDE; |
| - virtual void GetMetadata(const GURL& path) OVERRIDE; |
| - virtual void ReadDirectory(const GURL& path) OVERRIDE; |
| - virtual void Remove(const GURL& path, bool recursive) OVERRIDE; |
| + const GURL& dest_path, |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual void DirectoryExists(const GURL& path, |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual void FileExists(const GURL& path, |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual void GetMetadata(const GURL& path, |
| + const GetMetadataCallback& callback) OVERRIDE; |
| + virtual void ReadDirectory(const GURL& path, |
| + const ReadDirectoryCallback& callback) OVERRIDE; |
| + virtual void Remove(const GURL& path, bool recursive, |
| + const StatusCallback& callback) OVERRIDE; |
| virtual void Write(const net::URLRequestContext* url_request_context, |
| const GURL& path, |
| const GURL& blob_url, |
| - int64 offset) OVERRIDE; |
| - virtual void Truncate(const GURL& path, int64 length) OVERRIDE; |
| + int64 offset, |
| + const WriteCallback& callback) OVERRIDE; |
| + virtual void Truncate(const GURL& path, int64 length, |
| + const StatusCallback& callback) OVERRIDE; |
| virtual void TouchFile(const GURL& path, |
| const base::Time& last_access_time, |
| - const base::Time& last_modified_time) OVERRIDE; |
| - virtual void OpenFile( |
| - const GURL& path, |
| - int file_flags, |
| - base::ProcessHandle peer_handle) OVERRIDE; |
| - virtual void Cancel( |
| - scoped_ptr<FileSystemCallbackDispatcher> cancel_dispatcher) OVERRIDE; |
| + const base::Time& last_modified_time, |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual void OpenFile(const GURL& path, |
| + int file_flags, |
| + base::ProcessHandle peer_handle, |
| + const OpenFileCallback& callback) OVERRIDE; |
| + virtual void Cancel(const StatusCallback& cancel_callback) OVERRIDE; |
| virtual FileSystemOperation* AsFileSystemOperation() OVERRIDE; |
| // Synchronously gets the platform path for the given |path|. |
| @@ -92,8 +102,7 @@ class FileSystemOperation : public FileSystemOperationInterface { |
| friend class FileSystemTestHelper; |
| friend class chromeos::CrosMountPointProvider; |
| - FileSystemOperation(scoped_ptr<FileSystemCallbackDispatcher> dispatcher, |
| - scoped_refptr<base::MessageLoopProxy> proxy, |
| + FileSystemOperation(scoped_refptr<base::MessageLoopProxy> proxy, |
| FileSystemContext* file_system_context); |
| FileSystemContext* file_system_context() const { |
| @@ -122,63 +131,75 @@ class FileSystemOperation : public FileSystemOperationInterface { |
| const GURL& origin_url, |
| const quota::QuotaManager::GetUsageAndQuotaCallback& callback); |
| - void DelayedCreateFileForQuota(bool exclusive, |
| + void DelayedCreateFileForQuota(const StatusCallback& callback, |
| + bool exclusive, |
| quota::QuotaStatusCode status, |
| int64 usage, int64 quota); |
| - void DelayedCreateDirectoryForQuota(bool exclusive, bool recursive, |
| + void DelayedCreateDirectoryForQuota(const StatusCallback& callback, |
| + bool exclusive, bool recursive, |
| quota::QuotaStatusCode status, |
| int64 usage, int64 quota); |
| - void DelayedCopyForQuota(quota::QuotaStatusCode status, |
| + void DelayedCopyForQuota(const StatusCallback& callback, |
| + quota::QuotaStatusCode status, |
| int64 usage, int64 quota); |
| - void DelayedMoveForQuota(quota::QuotaStatusCode status, |
| + void DelayedMoveForQuota(const StatusCallback& callback, |
| + quota::QuotaStatusCode status, |
| int64 usage, int64 quota); |
| void DelayedWriteForQuota(quota::QuotaStatusCode status, |
| int64 usage, int64 quota); |
| - void DelayedTruncateForQuota(int64 length, |
| + void DelayedTruncateForQuota(const StatusCallback& callback, |
| + int64 length, |
| quota::QuotaStatusCode status, |
| int64 usage, int64 quota); |
| - void DelayedOpenFileForQuota(int file_flags, |
| + void DelayedOpenFileForQuota(const OpenFileCallback& callback, |
| + int file_flags, |
| quota::QuotaStatusCode status, |
| int64 usage, int64 quota); |
| // Callback for CreateFile for |exclusive|=true cases. |
| - void DidEnsureFileExistsExclusive(base::PlatformFileError rv, |
| + void DidEnsureFileExistsExclusive(const StatusCallback& callback, |
| + base::PlatformFileError rv, |
| bool created); |
| // Callback for CreateFile for |exclusive|=false cases. |
| - void DidEnsureFileExistsNonExclusive(base::PlatformFileError rv, |
| + void DidEnsureFileExistsNonExclusive(const StatusCallback& callback, |
| + base::PlatformFileError rv, |
| bool created); |
| // Generic callback that translates platform errors to WebKit error codes. |
| - void DidFinishFileOperation(base::PlatformFileError rv); |
| + void DidFinishFileOperation(const StatusCallback& callback, |
| + base::PlatformFileError rv); |
| - void DidDirectoryExists(base::PlatformFileError rv, |
| + void DidDirectoryExists(const StatusCallback& callback, |
| + base::PlatformFileError rv, |
| const base::PlatformFileInfo& file_info, |
| const FilePath& unused); |
| - void DidFileExists(base::PlatformFileError rv, |
| + void DidFileExists(const StatusCallback& callback, |
| + base::PlatformFileError rv, |
| const base::PlatformFileInfo& file_info, |
| const FilePath& unused); |
| - void DidGetMetadata(base::PlatformFileError rv, |
| + void DidGetMetadata(const GetMetadataCallback& callback, |
| + base::PlatformFileError rv, |
| const base::PlatformFileInfo& file_info, |
| const FilePath& platform_path); |
| void DidReadDirectory( |
| + const ReadDirectoryCallback& callback, |
| base::PlatformFileError rv, |
| const std::vector<base::FileUtilProxy::Entry>& entries); |
| - void DidWrite( |
| - base::PlatformFileError rv, |
| - int64 bytes, |
| - bool complete); |
| - void DidTouchFile(base::PlatformFileError rv); |
| - void DidOpenFile( |
| - base::PlatformFileError rv, |
| - base::PassPlatformFile file, |
| - bool created); |
| + void DidWrite(base::PlatformFileError rv, |
| + int64 bytes, |
| + bool complete); |
| + void DidTouchFile(const StatusCallback& callback, |
| + base::PlatformFileError rv); |
| + void DidOpenFile(const OpenFileCallback& callback, |
| + base::PlatformFileError rv, |
| + base::PassPlatformFile file, |
| + bool created); |
| // Helper for Write(). |
| - void OnFileOpenedForWrite( |
| - base::PlatformFileError rv, |
| - base::PassPlatformFile file, |
| - bool created); |
| + void OnFileOpenedForWrite(base::PlatformFileError rv, |
| + base::PassPlatformFile file, |
| + bool created); |
| // Checks the validity of a given |path| for reading, cracks the path into |
| // root URL and virtual path components, and returns the correct |
| @@ -188,11 +209,12 @@ class FileSystemOperation : public FileSystemOperationInterface { |
| // PLATFORM_FILE_ERROR_SECURITY and returns false. |
| // (Note: this doesn't delete this when it calls DidFail and returns false; |
| // it's the caller's responsibility.) |
| - bool VerifyFileSystemPathForRead(const GURL& path, |
| - GURL* root_url, |
| - FileSystemType* type, |
| - FilePath* virtual_path, |
| - FileSystemFileUtil** file_util); |
| + base::PlatformFileError VerifyFileSystemPathForRead( |
| + const GURL& path, |
| + GURL* root_url, |
| + FileSystemType* type, |
| + FilePath* virtual_path, |
| + FileSystemFileUtil** file_util); |
| // Checks the validity of a given |path| for writing, cracks the path into |
| // root URL and virtual path components, and returns the correct |
| @@ -209,27 +231,30 @@ class FileSystemOperation : public FileSystemOperationInterface { |
| // DidFail with PLATFORM_FILE_ERROR_SECURITY and returns false. |
| // (Note: this doesn't delete this when it calls DidFail and returns false; |
| // it's the caller's responsibility.) |
| - bool VerifyFileSystemPathForWrite(const GURL& path, |
| - bool create, |
| - GURL* root_url, |
| - FileSystemType* type, |
| - FilePath* virtual_path, |
| - FileSystemFileUtil** file_util); |
| + base::PlatformFileError VerifyFileSystemPathForWrite( |
| + const GURL& path, |
| + bool create, |
| + GURL* root_url, |
| + FileSystemType* type, |
| + FilePath* virtual_path, |
| + FileSystemFileUtil** file_util); |
| // Common internal routine for VerifyFileSystemPathFor{Read,Write}. |
| - bool VerifyFileSystemPath(const GURL& path, |
| - GURL* root_url, |
| - FileSystemType* type, |
| - FilePath* virtual_path, |
| - FileSystemFileUtil** file_util); |
| + base::PlatformFileError VerifyFileSystemPath(const GURL& path, |
| + GURL* root_url, |
| + FileSystemType* type, |
| + FilePath* virtual_path, |
| + FileSystemFileUtil** file_util); |
| // Setup*Context*() functions will call the appropriate VerifyFileSystem |
| // function and store the results to operation_context_ and |
| // *_virtual_path_. |
| // Return the result of VerifyFileSystem*(). |
| - bool SetupSrcContextForRead(const GURL& path); |
| - bool SetupSrcContextForWrite(const GURL& path, bool create); |
| - bool SetupDestContextForWrite(const GURL& path, bool create); |
| + base::PlatformFileError SetupSrcContextForRead(const GURL& path); |
| + base::PlatformFileError SetupSrcContextForWrite(const GURL& path, |
| + bool create); |
| + base::PlatformFileError SetupDestContextForWrite(const GURL& path, |
| + bool create); |
| #ifndef NDEBUG |
| enum OperationType { |
| @@ -258,9 +283,6 @@ class FileSystemOperation : public FileSystemOperationInterface { |
| // Proxy for calling file_util_proxy methods. |
| scoped_refptr<base::MessageLoopProxy> proxy_; |
| - // This can be NULL if the operation is cancelled on the way. |
| - scoped_ptr<FileSystemCallbackDispatcher> dispatcher_; |
| - |
| FileSystemOperationContext operation_context_; |
| scoped_ptr<ScopedQuotaUtilHelper> quota_util_helper_; |
| @@ -269,7 +291,11 @@ class FileSystemOperation : public FileSystemOperationInterface { |
| friend class FileWriterDelegate; |
| scoped_ptr<FileWriterDelegate> file_writer_delegate_; |
| scoped_ptr<net::URLRequest> blob_request_; |
| - scoped_ptr<FileSystemCallbackDispatcher> cancel_dispatcher_; |
| + WriteCallback write_callback_; |
| + StatusCallback cancel_callback_; |
| + void set_write_callback(const WriteCallback& write_callback) { |
| + write_callback_ = write_callback; |
| + } |
|
kinuko
2012/02/10 05:34:09
Can we add a brief comment for these callbacks?
(E
kinaba
2012/02/10 08:22:58
Done.
|
| // Used only by OpenFile, in order to clone the file handle back to the |
| // requesting process. |