Index: webkit/fileapi/local_file_system_operation.h |
diff --git a/webkit/fileapi/local_file_system_operation.h b/webkit/fileapi/local_file_system_operation.h |
index e80e91f4e68bddedd1845b6ef93b84ddde2a1e41..fafaca642fad18fb96990217e373d252c2ab1592 100644 |
--- a/webkit/fileapi/local_file_system_operation.h |
+++ b/webkit/fileapi/local_file_system_operation.h |
@@ -25,6 +25,7 @@ class CrosMountPointProvider; |
namespace fileapi { |
class FileSystemContext; |
+class RemoveOperationDelegate; |
// FileSystemOperation implementation for local file systems. |
class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation |
@@ -78,10 +79,39 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation |
const FileSystemURL& path, |
const SnapshotFileCallback& callback) OVERRIDE; |
+ // Copies in a single file from a different filesystem. |
+ // |
+ // This returns: |
+ // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_file_path| |
+ // or the parent directory of |dest_url| does not exist. |
+ // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and |
+ // is not a file. |
+ // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and |
+ // its parent path is a file. |
+ // |
void CopyInForeignFile(const FilePath& src_local_disk_path, |
const FileSystemURL& dest_url, |
const StatusCallback& callback); |
+ // Removes a single file. |
+ // |
+ // This returns: |
+ // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. |
+ // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| is not a file. |
+ // |
+ void RemoveFile(const FileSystemURL& url, |
+ const StatusCallback& callback); |
+ |
+ // Removes a single empty directory. |
+ // |
+ // This returns: |
+ // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist. |
+ // - PLATFORM_FILE_ERROR_NOT_A_DIRECTORY if |url| is not a directory. |
+ // - PLATFORM_FILE_ERROR_NOT_EMPTY if |url| is not empty. |
+ // |
+ void RemoveDirectory(const FileSystemURL& url, |
+ const StatusCallback& callback); |
+ |
// Synchronously gets the platform path for the given |url|. |
void SyncGetPlatformPath(const FileSystemURL& url, FilePath* platform_path); |
@@ -108,6 +138,7 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation |
friend class FileSystemQuotaTest; |
friend class LocalFileSystemTestOriginHelper; |
+ friend class RemoveOperationDelegate; |
friend class SyncableFileSystemOperation; |
LocalFileSystemOperation( |
@@ -119,6 +150,8 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation |
} |
FileSystemOperationContext* operation_context() const { |
+ if (overriding_operation_context_) |
+ return overriding_operation_context_; |
return operation_context_.get(); |
} |
@@ -187,6 +220,10 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation |
void DidFinishFileOperation(const StatusCallback& callback, |
base::PlatformFileError rv); |
+ // Generic callback when we delegated the operation. |
+ void DidFinishDelegatedOperation(const StatusCallback& callback, |
+ base::PlatformFileError rv); |
+ |
void DidDirectoryExists(const StatusCallback& callback, |
base::PlatformFileError rv, |
const base::PlatformFileInfo& file_info, |
@@ -230,12 +267,33 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation |
// Returns false if there's another inflight pending operation. |
bool SetPendingOperationType(OperationType type); |
+ // Overrides this operation's operation context by given |context|. |
+ // This operation won't own |context| and the |context| needs to outlive |
+ // this operation. |
+ // |
+ // Called only from operation delegates when they create sub-operations |
+ // for performing a recursive operation. |
+ void set_overriding_operation_context(FileSystemOperationContext* context) { |
+ overriding_operation_context_ = context; |
+ } |
+ |
+ // Sets a termination callback which is called when this instance goes away |
+ // (indicates the operation is finished). |
+ void set_termination_callback(const base::Closure& closure) { |
+ termination_callback_ = closure; |
+ } |
+ |
scoped_refptr<FileSystemContext> file_system_context_; |
scoped_ptr<FileSystemOperationContext> operation_context_; |
FileSystemFileUtil* src_util_; // Not owned. |
FileSystemFileUtil* dest_util_; // Not owned. |
+ FileSystemOperationContext* overriding_operation_context_; |
+ |
+ // A callback that is called when this instance goes away. |
+ base::Closure termination_callback_; |
+ |
// Indicates if this operation is for cross filesystem operation or not. |
// TODO(kinuko): This should be cleaned up. |
bool is_cross_operation_; |
@@ -248,6 +306,8 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation |
friend class FileWriterDelegate; |
scoped_ptr<FileWriterDelegate> file_writer_delegate_; |
+ scoped_ptr<RemoveOperationDelegate> remove_operation_delegate_; |
+ |
// write_callback is kept in this class for so that we can dispatch it when |
// the operation is cancelled. calcel_callback is kept for canceling a |
// Truncate() operation. We can't actually stop Truncate in another thread; |