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

Unified Diff: chrome/browser/chromeos/drive/file_system/move_operation.h

Issue 22920004: Reimplement MoveOperation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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: chrome/browser/chromeos/drive/file_system/move_operation.h
diff --git a/chrome/browser/chromeos/drive/file_system/move_operation.h b/chrome/browser/chromeos/drive/file_system/move_operation.h
index 792aca8fced90733c00bc0ffd3b6f5f11f208e66..e3196d1f1278c6a7f5a5ae05f0dc5c61fdbd5eac 100644
--- a/chrome/browser/chromeos/drive/file_system/move_operation.h
+++ b/chrome/browser/chromeos/drive/file_system/move_operation.h
@@ -29,7 +29,8 @@ class OperationObserver;
// metadata to reflect the new state.
class MoveOperation {
public:
- MoveOperation(OperationObserver* observer,
+ MoveOperation(base::SequencedTaskRunner* blocking_task_runner,
+ OperationObserver* observer,
JobScheduler* scheduler,
internal::ResourceMetadata* metadata);
~MoveOperation();
@@ -40,81 +41,76 @@ class MoveOperation {
void Move(const base::FilePath& src_file_path,
const base::FilePath& dest_file_path,
const FileOperationCallback& callback);
+
private:
- // Step 1 of Move(), called after the resource entry of the source and the
- // destination directory is obtained. It renames the resource in the source
- // directory, before moving between directories.
- void MoveAfterGetResourceEntryPair(
- const base::FilePath& dest_file_path,
- const FileOperationCallback& callback,
- scoped_ptr<EntryInfoPairResult> src_dest_info);
-
- // Step 2 of Move(), called after renaming is completed. It adds the resource
- // to the destination directory.
- void MoveAfterRename(const FileOperationCallback& callback,
- scoped_ptr<EntryInfoPairResult> src_dest_info,
- FileError error,
- const base::FilePath& src_path);
-
- // Step 3 of Move(), called after the resource is added to the new directory.
- // It removes the resource from the old directory in the remote server. While
- // our local metadata assumes tree structure, on the server side a resource
- // can belong to multiple collections (directories). At this point the
- // resource is contained in both the new and the old directories.
- void MoveAfterAddToDirectory(const FileOperationCallback& callback,
- scoped_ptr<EntryInfoPairResult> src_dest_info,
- FileError error,
- const base::FilePath& src_path);
-
- // Step 4 of Move(), called after the resource is removed from the old
- // directory. It calls back to the caller of Move().
- void MoveAfterRemoveFromDirectory(
+ // Part of Move(). Called after local metadata look up.
+ void MoveAfterPrepare(const base::FilePath& src_file_path,
+ const base::FilePath& dest_file_path,
+ const FileOperationCallback& callback,
+ scoped_ptr<ResourceEntry> src_entry,
+ scoped_ptr<ResourceEntry> dest_parent_entry,
+ FileError error);
+
+ // Part of Move(). Called after renaming (without moving the directory)
+ // is completed.
+ void MoveAfterRename(const base::FilePath& src_file_path,
+ const base::FilePath& dest_file_path,
+ const FileOperationCallback& callback,
+ scoped_ptr<ResourceEntry> src_entry,
+ scoped_ptr<ResourceEntry> dest_parent_entry,
+ FileError error);
+
+ // Part of Move(). Called after adding the entry to the parent is done.
+ void MoveAfterAddToDirectory(const base::FilePath& src_file_path,
+ const base::FilePath& dest_file_path,
+ const FileOperationCallback& callback,
+ const std::string& resource_id,
+ const std::string& parent_resource_id,
+ FileError error);
+
+
+ // Renames the |entry| to |new_title|. Upon completion, |callback| will be
+ // called. Note that if |entry|'s title is same as |new_title|, does nothing
+ // and calls |callback|.
+ // |callback| must not be null.
+ void Rename(const ResourceEntry& entry,
+ const std::string& new_title,
+ const FileOperationCallback& callback);
+
+ // Part of Rename(). Called after server side renaming is done.
+ void RenameAfterRenameResource(const std::string& resource_id,
+ const std::string& new_title,
+ const FileOperationCallback& callback,
+ google_apis::GDataErrorCode status);
+
+
+ // Adds the entry with |resource_id| to the directory |parent_resource_id|.
+ // Upon completion, |callback| will be called.
+ void AddToDirectory(const std::string& resource_id,
+ const std::string& parent_resource_id,
+ const FileOperationCallback& callback);
+
+ // Part of AddToDirectory(). Called after server side updating is done.
+ void AddToDirectoryAfterAddResourceToDirectory(
+ const std::string& resource_id,
+ const std::string& parent_resource_id,
const FileOperationCallback& callback,
- scoped_ptr<EntryInfoPairResult> src_dest_info,
google_apis::GDataErrorCode status);
- // Renames a resource |src_id| at |src_path| to |new_name| in the same
- // directory. |callback| will receive the new file path if the operation is
- // successful. If the new name already exists in the same directory, the file
- // name is uniquified by adding a parenthesized serial number like
- // "foo (2).txt".
- void Rename(const std::string& src_id,
- const base::FilePath& src_path,
- const base::FilePath& new_name,
- bool new_name_has_hosted_extension,
- const FileMoveCallback& callback);
-
- // Called in Rename() to reflect the rename on the local metadata.
- void RenameLocally(const base::FilePath& src_path,
- const std::string& new_title,
- const FileMoveCallback& callback,
- google_apis::GDataErrorCode status);
-
-
- // Moves a resource |src_id| at |src_path| to another directory |dest_dir_id|
- // at |dest_dir_path|. |callback| will receive the new file path if the
- // operation is successful.
- void AddToDirectory(const std::string& src_id,
- const std::string& dest_dir_id,
- const base::FilePath& src_path,
- const base::FilePath& dest_dir_path,
- const FileMoveCallback& callback);
-
- // Called in AddToDirectory() to reflect the move on the local metadata.
- void AddToDirectoryLocally(const base::FilePath& src_path,
- const base::FilePath& dest_dir_path,
- const FileMoveCallback& callback,
- google_apis::GDataErrorCode status);
-
- // Removes a resource |resource_id| from |directory_resource_id|.
+
+ // Removes the resource with |resource_id| from the directory with
+ // |directory_resource_id|.
+ // Upon completion, |callback| will be called.
void RemoveFromDirectory(const std::string& resource_id,
const std::string& directory_resource_id,
const FileOperationCallback& callback);
- // Called in RemoveFromDirectory().
- void RemoveFromDirectoryCompleted(const FileOperationCallback& callback,
- google_apis::GDataErrorCode status);
+ // Part of RemoveFromDirectory(). Called after server side updating is done.
+ void RemoveFromDirectoryAfterRemoveResourceFromDirectory(
+ const FileOperationCallback& callback,
+ google_apis::GDataErrorCode status);
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
OperationObserver* observer_;
JobScheduler* scheduler_;
internal::ResourceMetadata* metadata_;

Powered by Google App Engine
This is Rietveld 408576698