| 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/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 weak_ptr_factory_.GetWeakPtr(), | 112 weak_ptr_factory_.GetWeakPtr(), |
| 113 local_dest_file_path, | 113 local_dest_file_path, |
| 114 callback)); | 114 callback)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void CopyOperation::OnGetFileCompleteForTransferFile( | 117 void CopyOperation::OnGetFileCompleteForTransferFile( |
| 118 const base::FilePath& local_dest_file_path, | 118 const base::FilePath& local_dest_file_path, |
| 119 const FileOperationCallback& callback, | 119 const FileOperationCallback& callback, |
| 120 FileError error, | 120 FileError error, |
| 121 const base::FilePath& local_file_path, | 121 const base::FilePath& local_file_path, |
| 122 const std::string& unused_mime_type, | 122 scoped_ptr<ResourceEntry> entry) { |
| 123 DriveFileType file_type) { | |
| 124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 125 DCHECK(!callback.is_null()); | 124 DCHECK(!callback.is_null()); |
| 126 | 125 |
| 127 if (error != FILE_ERROR_OK) { | 126 if (error != FILE_ERROR_OK) { |
| 128 callback.Run(error); | 127 callback.Run(error); |
| 129 return; | 128 return; |
| 130 } | 129 } |
| 131 | 130 |
| 132 // GetFileByPath downloads the file from Drive to a local cache, which is then | 131 // 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 | 132 // copied to the actual destination path on the local file system using |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 weak_ptr_factory_.GetWeakPtr(), | 323 weak_ptr_factory_.GetWeakPtr(), |
| 325 dest_file_path, | 324 dest_file_path, |
| 326 callback)); | 325 callback)); |
| 327 } | 326 } |
| 328 | 327 |
| 329 void CopyOperation::OnGetFileCompleteForCopy( | 328 void CopyOperation::OnGetFileCompleteForCopy( |
| 330 const base::FilePath& remote_dest_file_path, | 329 const base::FilePath& remote_dest_file_path, |
| 331 const FileOperationCallback& callback, | 330 const FileOperationCallback& callback, |
| 332 FileError error, | 331 FileError error, |
| 333 const base::FilePath& local_file_path, | 332 const base::FilePath& local_file_path, |
| 334 const std::string& unused_mime_type, | 333 scoped_ptr<ResourceEntry> entry) { |
| 335 DriveFileType file_type) { | |
| 336 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 334 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 337 DCHECK(!callback.is_null()); | 335 DCHECK(!callback.is_null()); |
| 338 | 336 |
| 339 if (error != FILE_ERROR_OK) { | 337 if (error != FILE_ERROR_OK) { |
| 340 callback.Run(error); | 338 callback.Run(error); |
| 341 return; | 339 return; |
| 342 } | 340 } |
| 343 | 341 |
| 344 // This callback is only triggered for a regular file via Copy(). | 342 // This callback is only triggered for a regular file via Copy(). |
| 345 DCHECK_EQ(REGULAR_FILE, file_type); | 343 DCHECK(entry && !entry->file_specific_info().is_hosted_document()); |
| 346 ScheduleTransferRegularFile(local_file_path, remote_dest_file_path, callback); | 344 ScheduleTransferRegularFile(local_file_path, remote_dest_file_path, callback); |
| 347 } | 345 } |
| 348 | 346 |
| 349 void CopyOperation::TransferFileFromLocalToRemoteAfterGetEntryInfo( | 347 void CopyOperation::TransferFileFromLocalToRemoteAfterGetEntryInfo( |
| 350 const base::FilePath& local_src_file_path, | 348 const base::FilePath& local_src_file_path, |
| 351 const base::FilePath& remote_dest_file_path, | 349 const base::FilePath& remote_dest_file_path, |
| 352 const FileOperationCallback& callback, | 350 const FileOperationCallback& callback, |
| 353 FileError error, | 351 FileError error, |
| 354 scoped_ptr<ResourceEntry> entry) { | 352 scoped_ptr<ResourceEntry> entry) { |
| 355 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 remote_dest_file_path.DirName(), | 397 remote_dest_file_path.DirName(), |
| 400 resource_id, | 398 resource_id, |
| 401 // Drop the document extension, which should not be | 399 // Drop the document extension, which should not be |
| 402 // in the document title. | 400 // in the document title. |
| 403 remote_dest_file_path.BaseName().RemoveExtension().value(), | 401 remote_dest_file_path.BaseName().RemoveExtension().value(), |
| 404 callback); | 402 callback); |
| 405 } | 403 } |
| 406 | 404 |
| 407 } // namespace file_system | 405 } // namespace file_system |
| 408 } // namespace drive | 406 } // namespace drive |
| OLD | NEW |