| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/chromeos/drive/file_system/download_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/download_operation.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // The file's entry should have its file specific info. | 55 // The file's entry should have its file specific info. |
| 56 DCHECK(entry->has_file_specific_info()); | 56 DCHECK(entry->has_file_specific_info()); |
| 57 | 57 |
| 58 // For a hosted document, we create a special JSON file to represent the | 58 // For a hosted document, we create a special JSON file to represent the |
| 59 // document instead of fetching the document content in one of the exported | 59 // document instead of fetching the document content in one of the exported |
| 60 // formats. The JSON file contains the edit URL and resource ID of the | 60 // formats. The JSON file contains the edit URL and resource ID of the |
| 61 // document. | 61 // document. |
| 62 if (entry->file_specific_info().is_hosted_document()) { | 62 if (entry->file_specific_info().is_hosted_document()) { |
| 63 base::FilePath gdoc_file_path; | 63 base::FilePath gdoc_file_path; |
| 64 // TODO(rvargas): Convert this code to use base::File::Info. | 64 // TODO(rvargas): Convert this code to use base::File::Info. |
| 65 base::PlatformFileInfo file_info; | 65 base::File::Info file_info; |
| 66 if (!base::CreateTemporaryFileInDir(temporary_file_directory, | 66 if (!base::CreateTemporaryFileInDir(temporary_file_directory, |
| 67 &gdoc_file_path) || | 67 &gdoc_file_path) || |
| 68 !util::CreateGDocFile(gdoc_file_path, | 68 !util::CreateGDocFile(gdoc_file_path, |
| 69 GURL(entry->file_specific_info().alternate_url()), | 69 GURL(entry->file_specific_info().alternate_url()), |
| 70 entry->resource_id()) || | 70 entry->resource_id()) || |
| 71 !base::GetFileInfo(gdoc_file_path, | 71 !base::GetFileInfo(gdoc_file_path, |
| 72 reinterpret_cast<base::File::Info*>(&file_info))) | 72 reinterpret_cast<base::File::Info*>(&file_info))) |
| 73 return FILE_ERROR_FAILED; | 73 return FILE_ERROR_FAILED; |
| 74 | 74 |
| 75 *cache_file_path = gdoc_file_path; | 75 *cache_file_path = gdoc_file_path; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 92 error = cache->GetFile(local_id, cache_file_path); | 92 error = cache->GetFile(local_id, cache_file_path); |
| 93 if (error != FILE_ERROR_OK) | 93 if (error != FILE_ERROR_OK) |
| 94 return error; | 94 return error; |
| 95 | 95 |
| 96 // If the cache file is dirty, the modified file info needs to be stored in | 96 // If the cache file is dirty, the modified file info needs to be stored in |
| 97 // |entry|. | 97 // |entry|. |
| 98 // TODO(kinaba): crbug.com/246469. The logic below is a duplicate of that in | 98 // TODO(kinaba): crbug.com/246469. The logic below is a duplicate of that in |
| 99 // drive::FileSystem::CheckLocalModificationAndRun. We should merge them once | 99 // drive::FileSystem::CheckLocalModificationAndRun. We should merge them once |
| 100 // the drive::FS side is also converted to run fully on blocking pool. | 100 // the drive::FS side is also converted to run fully on blocking pool. |
| 101 if (cache_entry.is_dirty()) { | 101 if (cache_entry.is_dirty()) { |
| 102 base::PlatformFileInfo file_info; | 102 base::File::Info file_info; |
| 103 if (base::GetFileInfo(*cache_file_path, | 103 if (base::GetFileInfo(*cache_file_path, |
| 104 reinterpret_cast<base::File::Info*>(&file_info))) | 104 reinterpret_cast<base::File::Info*>(&file_info))) |
| 105 SetPlatformFileInfoToResourceEntry(file_info, entry); | 105 SetPlatformFileInfoToResourceEntry(file_info, entry); |
| 106 } | 106 } |
| 107 | 107 |
| 108 return FILE_ERROR_OK; | 108 return FILE_ERROR_OK; |
| 109 } | 109 } |
| 110 | 110 |
| 111 // Calls CheckPreConditionForEnsureFileDownloaded() with the entry specified by | 111 // Calls CheckPreConditionForEnsureFileDownloaded() with the entry specified by |
| 112 // the given ID. Also fills |drive_file_path| with the path of the entry. | 112 // the given ID. Also fills |drive_file_path| with the path of the entry. |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 observer_->OnDirectoryChangedByOperation(file_path.DirName()); | 484 observer_->OnDirectoryChangedByOperation(file_path.DirName()); |
| 485 params->OnComplete(*cache_file_path); | 485 params->OnComplete(*cache_file_path); |
| 486 } | 486 } |
| 487 | 487 |
| 488 void DownloadOperation::CancelJob(JobID job_id) { | 488 void DownloadOperation::CancelJob(JobID job_id) { |
| 489 scheduler_->CancelJob(job_id); | 489 scheduler_->CancelJob(job_id); |
| 490 } | 490 } |
| 491 | 491 |
| 492 } // namespace file_system | 492 } // namespace file_system |
| 493 } // namespace drive | 493 } // namespace drive |
| OLD | NEW |