| 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/callback_helpers.h" | |
| 10 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 11 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
| 12 #include "chrome/browser/chromeos/drive/drive.pb.h" | 11 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 13 #include "chrome/browser/chromeos/drive/file_cache.h" | 12 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 14 #include "chrome/browser/chromeos/drive/file_system/create_file_operation.h" | 13 #include "chrome/browser/chromeos/drive/file_system/create_file_operation.h" |
| 15 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" | 14 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" |
| 16 #include "chrome/browser/chromeos/drive/file_system_util.h" | 15 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 17 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 16 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
| 18 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 17 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
| 19 #include "chrome/browser/chromeos/drive/resource_metadata.h" | 18 #include "chrome/browser/chromeos/drive/resource_metadata.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 std::string* local_id) { | 102 std::string* local_id) { |
| 104 FileError error = metadata->GetIdByPath(remote_dest_path, local_id); | 103 FileError error = metadata->GetIdByPath(remote_dest_path, local_id); |
| 105 if (error != FILE_ERROR_OK) | 104 if (error != FILE_ERROR_OK) |
| 106 return error; | 105 return error; |
| 107 | 106 |
| 108 ResourceEntry entry; | 107 ResourceEntry entry; |
| 109 error = metadata->GetResourceEntryById(*local_id, &entry); | 108 error = metadata->GetResourceEntryById(*local_id, &entry); |
| 110 if (error != FILE_ERROR_OK) | 109 if (error != FILE_ERROR_OK) |
| 111 return error; | 110 return error; |
| 112 | 111 |
| 113 error = cache->Store( | 112 return cache->Store(*local_id, std::string(), local_src_path, |
| 114 *local_id, entry.file_specific_info().md5(), local_src_path, | 113 internal::FileCache::FILE_OPERATION_COPY); |
| 115 internal::FileCache::FILE_OPERATION_COPY); | |
| 116 if (error != FILE_ERROR_OK) | |
| 117 return error; | |
| 118 | |
| 119 scoped_ptr<base::ScopedClosureRunner> file_closer; | |
| 120 error = cache->OpenForWrite(*local_id, &file_closer); | |
| 121 if (error != FILE_ERROR_OK) | |
| 122 return error; | |
| 123 | |
| 124 return FILE_ERROR_OK; | |
| 125 } | 114 } |
| 126 | 115 |
| 127 // Gets the file size of the |local_path|, and the ResourceEntry for the parent | 116 // Gets the file size of the |local_path|, and the ResourceEntry for the parent |
| 128 // of |remote_path| to prepare the necessary information for transfer. | 117 // of |remote_path| to prepare the necessary information for transfer. |
| 129 FileError PrepareTransferFileFromLocalToRemote( | 118 FileError PrepareTransferFileFromLocalToRemote( |
| 130 internal::ResourceMetadata* metadata, | 119 internal::ResourceMetadata* metadata, |
| 131 const base::FilePath& local_src_path, | 120 const base::FilePath& local_src_path, |
| 132 const base::FilePath& remote_dest_path, | 121 const base::FilePath& remote_dest_path, |
| 133 std::string* gdoc_resource_id, | 122 std::string* gdoc_resource_id, |
| 134 std::string* parent_resource_id) { | 123 std::string* parent_resource_id) { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 445 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 457 DCHECK(!callback.is_null()); | 446 DCHECK(!callback.is_null()); |
| 458 | 447 |
| 459 if (error == FILE_ERROR_OK) | 448 if (error == FILE_ERROR_OK) |
| 460 observer_->OnEntryUpdatedByOperation(*local_id); | 449 observer_->OnEntryUpdatedByOperation(*local_id); |
| 461 callback.Run(error); | 450 callback.Run(error); |
| 462 } | 451 } |
| 463 | 452 |
| 464 } // namespace file_system | 453 } // namespace file_system |
| 465 } // namespace drive | 454 } // namespace drive |
| OLD | NEW |