| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/drive/file_system/copy_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 if (error != FILE_ERROR_OK) { | 127 if (error != FILE_ERROR_OK) { |
| 128 callback.Run(error); | 128 callback.Run(error); |
| 129 return; | 129 return; |
| 130 } | 130 } |
| 131 | 131 |
| 132 // GetFileByPath downloads the file from Drive to a local cache, which is then | 132 // GetFileByPath downloads the file from Drive to a local cache, which is then |
| 133 // copied to the actual destination path on the local file system using | 133 // copied to the actual destination path on the local file system using |
| 134 // CopyLocalFileOnBlockingPool. | 134 // CopyLocalFileOnBlockingPool. |
| 135 base::PostTaskAndReplyWithResult( | 135 base::PostTaskAndReplyWithResult( |
| 136 blocking_task_runner_, | 136 blocking_task_runner_.get(), |
| 137 FROM_HERE, | 137 FROM_HERE, |
| 138 base::Bind(&CopyLocalFileOnBlockingPool, | 138 base::Bind( |
| 139 local_file_path, | 139 &CopyLocalFileOnBlockingPool, local_file_path, local_dest_file_path), |
| 140 local_dest_file_path), | |
| 141 callback); | 140 callback); |
| 142 } | 141 } |
| 143 | 142 |
| 144 void CopyOperation::TransferFileFromLocalToRemote( | 143 void CopyOperation::TransferFileFromLocalToRemote( |
| 145 const base::FilePath& local_src_file_path, | 144 const base::FilePath& local_src_file_path, |
| 146 const base::FilePath& remote_dest_file_path, | 145 const base::FilePath& remote_dest_file_path, |
| 147 const FileOperationCallback& callback) { | 146 const FileOperationCallback& callback) { |
| 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 149 DCHECK(!callback.is_null()); | 148 DCHECK(!callback.is_null()); |
| 150 | 149 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 const FileOperationCallback& callback, | 200 const FileOperationCallback& callback, |
| 202 FileError error, | 201 FileError error, |
| 203 scoped_ptr<ResourceEntry> entry) { | 202 scoped_ptr<ResourceEntry> entry) { |
| 204 if (error != FILE_ERROR_OK) { | 203 if (error != FILE_ERROR_OK) { |
| 205 callback.Run(error); | 204 callback.Run(error); |
| 206 return; | 205 return; |
| 207 } | 206 } |
| 208 | 207 |
| 209 ResourceEntry* entry_ptr = entry.get(); | 208 ResourceEntry* entry_ptr = entry.get(); |
| 210 base::PostTaskAndReplyWithResult( | 209 base::PostTaskAndReplyWithResult( |
| 211 blocking_task_runner_, | 210 blocking_task_runner_.get(), |
| 212 FROM_HERE, | 211 FROM_HERE, |
| 213 base::Bind(&StoreAndMarkDirty, | 212 base::Bind(&StoreAndMarkDirty, |
| 214 cache_, | 213 cache_, |
| 215 entry_ptr->resource_id(), | 214 entry_ptr->resource_id(), |
| 216 entry_ptr->file_specific_info().md5(), | 215 entry_ptr->file_specific_info().md5(), |
| 217 local_file_path), | 216 local_file_path), |
| 218 base::Bind(&CopyOperation::ScheduleTransferRegularFileAfterStore, | 217 base::Bind(&CopyOperation::ScheduleTransferRegularFileAfterStore, |
| 219 weak_ptr_factory_.GetWeakPtr(), | 218 weak_ptr_factory_.GetWeakPtr(), |
| 220 base::Passed(&entry), | 219 base::Passed(&entry), |
| 221 callback)); | 220 callback)); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 FileError error = util::GDataToFileError(status); | 376 FileError error = util::GDataToFileError(status); |
| 378 if (error != FILE_ERROR_OK) { | 377 if (error != FILE_ERROR_OK) { |
| 379 callback.Run(error); | 378 callback.Run(error); |
| 380 return; | 379 return; |
| 381 } | 380 } |
| 382 DCHECK(resource_entry); | 381 DCHECK(resource_entry); |
| 383 | 382 |
| 384 // The copy on the server side is completed successfully. Update the local | 383 // The copy on the server side is completed successfully. Update the local |
| 385 // metadata. | 384 // metadata. |
| 386 base::PostTaskAndReplyWithResult( | 385 base::PostTaskAndReplyWithResult( |
| 387 blocking_task_runner_, | 386 blocking_task_runner_.get(), |
| 388 FROM_HERE, | 387 FROM_HERE, |
| 389 base::Bind(&internal::ResourceMetadata::AddEntry, | 388 base::Bind(&internal::ResourceMetadata::AddEntry, |
| 390 base::Unretained(metadata_), | 389 base::Unretained(metadata_), |
| 391 ConvertToResourceEntry(*resource_entry)), | 390 ConvertToResourceEntry(*resource_entry)), |
| 392 callback); | 391 callback); |
| 393 } | 392 } |
| 394 | 393 |
| 395 void CopyOperation::OnGetFileCompleteForCopy( | 394 void CopyOperation::OnGetFileCompleteForCopy( |
| 396 const base::FilePath& remote_dest_file_path, | 395 const base::FilePath& remote_dest_file_path, |
| 397 const FileOperationCallback& callback, | 396 const FileOperationCallback& callback, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 427 | 426 |
| 428 DCHECK(entry.get()); | 427 DCHECK(entry.get()); |
| 429 if (!entry->file_info().is_directory()) { | 428 if (!entry->file_info().is_directory()) { |
| 430 // The parent of |remote_dest_file_path| is not a directory. | 429 // The parent of |remote_dest_file_path| is not a directory. |
| 431 callback.Run(FILE_ERROR_NOT_A_DIRECTORY); | 430 callback.Run(FILE_ERROR_NOT_A_DIRECTORY); |
| 432 return; | 431 return; |
| 433 } | 432 } |
| 434 | 433 |
| 435 if (util::HasGDocFileExtension(local_src_file_path)) { | 434 if (util::HasGDocFileExtension(local_src_file_path)) { |
| 436 base::PostTaskAndReplyWithResult( | 435 base::PostTaskAndReplyWithResult( |
| 437 blocking_task_runner_, | 436 blocking_task_runner_.get(), |
| 438 FROM_HERE, | 437 FROM_HERE, |
| 439 base::Bind(&util::ReadResourceIdFromGDocFile, local_src_file_path), | 438 base::Bind(&util::ReadResourceIdFromGDocFile, local_src_file_path), |
| 440 base::Bind(&CopyOperation::TransferFileForResourceId, | 439 base::Bind(&CopyOperation::TransferFileForResourceId, |
| 441 weak_ptr_factory_.GetWeakPtr(), | 440 weak_ptr_factory_.GetWeakPtr(), |
| 442 local_src_file_path, | 441 local_src_file_path, |
| 443 remote_dest_file_path, | 442 remote_dest_file_path, |
| 444 callback)); | 443 callback)); |
| 445 } else { | 444 } else { |
| 446 ScheduleTransferRegularFile(local_src_file_path, remote_dest_file_path, | 445 ScheduleTransferRegularFile(local_src_file_path, remote_dest_file_path, |
| 447 callback); | 446 callback); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 474 canonicalized_resource_id, | 473 canonicalized_resource_id, |
| 475 // Drop the document extension, which should not be | 474 // Drop the document extension, which should not be |
| 476 // in the document title. | 475 // in the document title. |
| 477 // TODO(yoshiki): Remove this code with crbug.com/223304. | 476 // TODO(yoshiki): Remove this code with crbug.com/223304. |
| 478 remote_dest_file_path.BaseName().RemoveExtension().value(), | 477 remote_dest_file_path.BaseName().RemoveExtension().value(), |
| 479 callback); | 478 callback); |
| 480 } | 479 } |
| 481 | 480 |
| 482 } // namespace file_system | 481 } // namespace file_system |
| 483 } // namespace drive | 482 } // namespace drive |
| OLD | NEW |