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

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

Issue 12049062: Merge 177997 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src/
Patch Set: 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
« no previous file with comments | « chrome/browser/chromeos/drive/file_system/move_operation.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/file_system/move_operation.cc
===================================================================
--- chrome/browser/chromeos/drive/file_system/move_operation.cc (revision 178490)
+++ chrome/browser/chromeos/drive/file_system/move_operation.cc (working copy)
@@ -85,19 +85,23 @@
// 1. Renames the file at |src_file_path| to basename(|dest_file_path|)
// within the same directory. The rename operation is a no-op if
// basename(|src_file_path|) equals to basename(|dest_file_path|).
- // 2. Removes the file from its parent directory (the file is not deleted),
- // which effectively moves the file to the root directory.
- // 3. Adds the file to the parent directory of |dest_file_path|, which
- // effectively moves the file from the root directory to the parent
- // directory of |dest_file_path|.
+ // 2. Removes the file from its parent directory (the file is not deleted, but
+ // just becomes orphaned).
+ // 3. Adds the file to the parent directory of |dest_file_path|.
+ //
+ // TODO(kinaba): After the step 2, the file gets into the state with no parent
+ // node. Our current implementation regards the state as belonging to the root
+ // directory, so below the file is dealt as such. In fact, this is not the
+ // case on the server side. No-parent and in-root is a different concept. We
+ // need to make our implementation consistent to the server: crbug.com/171207.
const FileMoveCallback add_file_to_directory_callback =
- base::Bind(&MoveOperation::MoveEntryFromRootDirectory,
+ base::Bind(&MoveOperation::AddEntryToDirectory,
weak_ptr_factory_.GetWeakPtr(),
dest_parent_path,
callback);
const FileMoveCallback remove_file_from_directory_callback =
- base::Bind(&MoveOperation::RemoveEntryFromNonRootDirectory,
+ base::Bind(&MoveOperation::RemoveEntryFromDirectory,
weak_ptr_factory_.GetWeakPtr(),
add_file_to_directory_callback);
@@ -204,30 +208,23 @@
callback));
}
-void MoveOperation::RemoveEntryFromNonRootDirectory(
+void MoveOperation::RemoveEntryFromDirectory(
const FileMoveCallback& callback,
DriveFileError error,
const FilePath& file_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- const FilePath dir_path = file_path.DirName();
- // Return if there is an error or |dir_path| is the root directory.
- if (error != DRIVE_FILE_OK || dir_path == FilePath(kDriveRootDirectory)) {
- callback.Run(error, file_path);
- return;
- }
-
metadata_->GetEntryInfoPairByPaths(
file_path,
- dir_path,
+ file_path.DirName(),
base::Bind(
- &MoveOperation::RemoveEntryFromNonRootDirectoryAfterEntryInfoPair,
+ &MoveOperation::RemoveEntryFromDirectoryAfterEntryInfoPair,
weak_ptr_factory_.GetWeakPtr(),
callback));
}
-void MoveOperation::RemoveEntryFromNonRootDirectoryAfterEntryInfoPair(
+void MoveOperation::RemoveEntryFromDirectoryAfterEntryInfoPair(
const FileMoveCallback& callback,
scoped_ptr<EntryInfoPairResult> result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -266,34 +263,25 @@
// TODO(zork): Share with CopyOperation.
// See: crbug.com/150050
-void MoveOperation::MoveEntryFromRootDirectory(
- const FilePath& directory_path,
- const FileOperationCallback& callback,
- DriveFileError error,
- const FilePath& file_path) {
+void MoveOperation::AddEntryToDirectory(const FilePath& directory_path,
+ const FileOperationCallback& callback,
+ DriveFileError error,
+ const FilePath& file_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- DCHECK_EQ(kDriveRootDirectory, file_path.DirName().value());
- // Return if there is an error or |dir_path| is the root directory.
- if (error != DRIVE_FILE_OK ||
- directory_path == FilePath(kDriveRootDirectory)) {
- callback.Run(error);
- return;
- }
-
metadata_->GetEntryInfoPairByPaths(
file_path,
directory_path,
base::Bind(
- &MoveOperation::MoveEntryFromRootDirectoryAfterGetEntryInfoPair,
+ &MoveOperation::AddEntryToDirectoryAfterGetEntryInfoPair,
weak_ptr_factory_.GetWeakPtr(),
callback));
}
// TODO(zork): Share with CopyOperation.
// See: crbug.com/150050
-void MoveOperation::MoveEntryFromRootDirectoryAfterGetEntryInfoPair(
+void MoveOperation::AddEntryToDirectoryAfterGetEntryInfoPair(
const FileOperationCallback& callback,
scoped_ptr<EntryInfoPairResult> result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
« no previous file with comments | « chrome/browser/chromeos/drive/file_system/move_operation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698