Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: webkit/fileapi/local_file_system_operation.h

Issue 12051010: (For-try) Divide recursive Copy/Move into multiple async tasks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 ebf4356b8cf8fbe0e5a1ecfbdb8d7d4d2fce354d..bb41608096db61cc7f2406f533ccd51427d39c32 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 RecursiveOperationDelegate;
// FileSystemOperation implementation for local file systems.
class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation
@@ -78,10 +79,75 @@ 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);
+
+ // Copies a local file from |src_url| to |dest_url|.
+ // This must be called for the files that belong to the same filesystem
+ // (i.e. the type() and the origin() of the |src_url| and |dest_url| must
+ // match).
+ //
+ // This returns:
+ // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
+ // or the parent directory of |dest_url| does not exist.
+ // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
+ // - 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 CopyLocalFile(const FileSystemURL& src_url,
+ const FileSystemURL& dest_url,
+ const StatusCallback& callback);
+
+ // Moves a local file from |src_url| to |dest_url|.
+ // This must be called for the files that belong to the same filesystem
+ // (i.e. the type() and the origin() of the |src_url| and |dest_url| must
+ // match).
+ //
+ // This returns:
+ // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
+ // or the parent directory of |dest_url| does not exist.
+ // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
+ // - 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 MoveLocalFile(const FileSystemURL& src_url,
+ const FileSystemURL& dest_url,
+ const StatusCallback& callback);
+
// Synchronously gets the platform path for the given |url|.
void SyncGetPlatformPath(const FileSystemURL& url, FilePath* platform_path);
@@ -108,6 +174,8 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation
friend class FileSystemQuotaTest;
friend class LocalFileSystemTestOriginHelper;
+ friend class RecursiveOperationDelegate;
+ friend class CrossOperationDelegate;
friend class SyncableFileSystemOperation;
LocalFileSystemOperation(
@@ -115,10 +183,12 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation
scoped_ptr<FileSystemOperationContext> operation_context);
FileSystemContext* file_system_context() const {
- return operation_context_->file_system_context();
+ return operation_context()->file_system_context();
}
FileSystemOperationContext* operation_context() const {
+ if (overriding_operation_context_)
+ return overriding_operation_context_;
return operation_context_.get();
}
@@ -126,8 +196,7 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation
// file_util on their own should call this before performing the actual
// operation. If it is given it will not be overwritten by the class.
void set_override_file_util(FileSystemFileUtil* file_util) {
- src_util_ = file_util;
- dest_util_ = file_util;
+ file_util_ = file_util;
}
// Queries the quota and usage and then runs the given |task|.
@@ -167,15 +236,15 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation
const StatusCallback& callback,
bool exclusive,
bool recursive);
- void DoCopy(const FileSystemURL& src,
- const FileSystemURL& dest,
- const StatusCallback& callback);
+ void DoCopyLocalFile(const FileSystemURL& src,
+ const FileSystemURL& dest,
+ const StatusCallback& callback);
+ void DoMoveLocalFile(const FileSystemURL& src,
+ const FileSystemURL& dest,
+ const StatusCallback& callback);
void DoCopyInForeignFile(const FilePath& src_local_disk_file_path,
const FileSystemURL& dest,
const StatusCallback& callback);
- void DoMove(const FileSystemURL& src,
- const FileSystemURL& dest,
- const StatusCallback& callback);
void DoTruncate(const FileSystemURL& url,
const StatusCallback& callback, int64 length);
void DoOpenFile(const FileSystemURL& url,
@@ -238,13 +307,20 @@ 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;
+ }
+
scoped_ptr<FileSystemOperationContext> operation_context_;
- FileSystemFileUtil* src_util_; // Not owned.
- FileSystemFileUtil* dest_util_; // Not owned.
+ FileSystemFileUtil* file_util_; // Not owned.
- // Indicates if this operation is for cross filesystem operation or not.
- // TODO(kinuko): This should be cleaned up.
- bool is_cross_operation_;
+ FileSystemOperationContext* overriding_operation_context_;
// This is set before any write operations to dispatch
// FileUpdateObserver::StartUpdate and FileUpdateObserver::EndUpdate.
@@ -254,6 +330,8 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation
friend class FileWriterDelegate;
scoped_ptr<FileWriterDelegate> file_writer_delegate_;
+ scoped_ptr<RecursiveOperationDelegate> recursive_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;

Powered by Google App Engine
This is Rietveld 408576698