| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/browser/fileapi/copy_or_move_operation_delegate.h" | 5 #include "webkit/browser/fileapi/copy_or_move_operation_delegate.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" | 9 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" |
| 10 #include "webkit/browser/fileapi/file_system_context.h" | 10 #include "webkit/browser/fileapi/file_system_context.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 error != base::PLATFORM_FILE_ERROR_NOT_FOUND) { | 103 error != base::PLATFORM_FILE_ERROR_NOT_FOUND) { |
| 104 callback_.Run(error); | 104 callback_.Run(error); |
| 105 return; | 105 return; |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Start to process the source directory recursively. | 108 // Start to process the source directory recursively. |
| 109 // TODO(kinuko): This could be too expensive for same_file_system_==true | 109 // TODO(kinuko): This could be too expensive for same_file_system_==true |
| 110 // and operation==MOVE case, probably we can just rename the root directory. | 110 // and operation==MOVE case, probably we can just rename the root directory. |
| 111 // http://crbug.com/172187 | 111 // http://crbug.com/172187 |
| 112 StartRecursiveOperation( | 112 StartRecursiveOperation( |
| 113 src_root_, base::Bind(&CopyOrMoveOperationDelegate::DidFinishCopyDir, | 113 src_root_, |
| 114 AsWeakPtr(), src_root_, | 114 base::Bind(&CopyOrMoveOperationDelegate::DidFinishRecursiveCopyDir, |
| 115 callback_)); | 115 AsWeakPtr(), src_root_, callback_)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void CopyOrMoveOperationDelegate::CopyOrMoveFile( | 118 void CopyOrMoveOperationDelegate::CopyOrMoveFile( |
| 119 const URLPair& url_pair, | 119 const URLPair& url_pair, |
| 120 const StatusCallback& callback) { | 120 const StatusCallback& callback) { |
| 121 // Same filesystem case. | 121 // Same filesystem case. |
| 122 if (same_file_system_) { | 122 if (same_file_system_) { |
| 123 if (operation_type_ == OPERATION_MOVE) { | 123 if (operation_type_ == OPERATION_MOVE) { |
| 124 operation_runner()->MoveFileLocal(url_pair.src, url_pair.dest, callback); | 124 operation_runner()->MoveFileLocal(url_pair.src, url_pair.dest, callback); |
| 125 } else { | 125 } else { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 const base::FilePath& platform_path, | 183 const base::FilePath& platform_path, |
| 184 base::PlatformFileError error) { | 184 base::PlatformFileError error) { |
| 185 if (error != base::PLATFORM_FILE_OK) { | 185 if (error != base::PLATFORM_FILE_OK) { |
| 186 callback.Run(error); | 186 callback.Run(error); |
| 187 return; | 187 return; |
| 188 } | 188 } |
| 189 | 189 |
| 190 operation_runner()->CopyInForeignFile(platform_path, dest, callback); | 190 operation_runner()->CopyInForeignFile(platform_path, dest, callback); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void CopyOrMoveOperationDelegate::DidFinishCopyDir( | 193 void CopyOrMoveOperationDelegate::DidFinishRecursiveCopyDir( |
| 194 const FileSystemURL& src, | 194 const FileSystemURL& src, |
| 195 const StatusCallback& callback, | 195 const StatusCallback& callback, |
| 196 base::PlatformFileError error) { | 196 base::PlatformFileError error) { |
| 197 if (error != base::PLATFORM_FILE_OK || | 197 if (error != base::PLATFORM_FILE_OK || |
| 198 operation_type_ == OPERATION_COPY) { | 198 operation_type_ == OPERATION_COPY) { |
| 199 callback.Run(error); | 199 callback.Run(error); |
| 200 return; | 200 return; |
| 201 } | 201 } |
| 202 | 202 |
| 203 DCHECK_EQ(operation_type_, OPERATION_MOVE); | 203 DCHECK_EQ(OPERATION_MOVE, operation_type_); |
| 204 | 204 |
| 205 // Remove the source for finalizing move operation. | 205 // Remove the source for finalizing move operation. |
| 206 operation_runner()->Remove( | 206 operation_runner()->Remove( |
| 207 src, true /* recursive */, | 207 src, true /* recursive */, |
| 208 base::Bind(&CopyOrMoveOperationDelegate::DidRemoveSourceForMove, | 208 base::Bind(&CopyOrMoveOperationDelegate::DidRemoveSourceForMove, |
| 209 AsWeakPtr(), callback)); | 209 AsWeakPtr(), callback)); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void CopyOrMoveOperationDelegate::DidFinishCopy( | 212 void CopyOrMoveOperationDelegate::DidFinishCopy( |
| 213 const URLPair& url_pair, | 213 const URLPair& url_pair, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 const StatusCallback& callback, | 314 const StatusCallback& callback, |
| 315 base::PlatformFileError error) { | 315 base::PlatformFileError error) { |
| 316 if (error != base::PLATFORM_FILE_OK) { | 316 if (error != base::PLATFORM_FILE_OK) { |
| 317 VLOG(1) << "Error removing destination file after validation error: " | 317 VLOG(1) << "Error removing destination file after validation error: " |
| 318 << error; | 318 << error; |
| 319 } | 319 } |
| 320 callback.Run(prior_error); | 320 callback.Run(prior_error); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace fileapi | 323 } // namespace fileapi |
| OLD | NEW |