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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 base::PlatformFileInfo file_info; | 64 base::PlatformFileInfo file_info; |
65 if (!base::CreateTemporaryFileInDir(temporary_file_directory, | 65 if (!base::CreateTemporaryFileInDir(temporary_file_directory, |
66 &gdoc_file_path) || | 66 &gdoc_file_path) || |
67 !util::CreateGDocFile(gdoc_file_path, | 67 !util::CreateGDocFile(gdoc_file_path, |
68 GURL(entry->file_specific_info().alternate_url()), | 68 GURL(entry->file_specific_info().alternate_url()), |
69 entry->resource_id()) || | 69 entry->resource_id()) || |
70 !file_util::GetFileInfo(gdoc_file_path, &file_info)) | 70 !base::GetFileInfo(gdoc_file_path, &file_info)) |
71 return FILE_ERROR_FAILED; | 71 return FILE_ERROR_FAILED; |
72 | 72 |
73 *cache_file_path = gdoc_file_path; | 73 *cache_file_path = gdoc_file_path; |
74 SetPlatformFileInfoToResourceEntry(file_info, entry); | 74 SetPlatformFileInfoToResourceEntry(file_info, entry); |
75 return FILE_ERROR_OK; | 75 return FILE_ERROR_OK; |
76 } | 76 } |
77 | 77 |
78 // Leave |cache_file_path| empty when no cache entry is found. | 78 // Leave |cache_file_path| empty when no cache entry is found. |
79 FileCacheEntry cache_entry; | 79 FileCacheEntry cache_entry; |
80 if (!cache->GetCacheEntry(local_id, &cache_entry)) | 80 if (!cache->GetCacheEntry(local_id, &cache_entry)) |
(...skipping 10 matching lines...) Expand all Loading... |
91 if (error != FILE_ERROR_OK) | 91 if (error != FILE_ERROR_OK) |
92 return error; | 92 return error; |
93 | 93 |
94 // If the cache file is dirty, the modified file info needs to be stored in | 94 // If the cache file is dirty, the modified file info needs to be stored in |
95 // |entry|. | 95 // |entry|. |
96 // TODO(kinaba): crbug.com/246469. The logic below is a duplicate of that in | 96 // TODO(kinaba): crbug.com/246469. The logic below is a duplicate of that in |
97 // drive::FileSystem::CheckLocalModificationAndRun. We should merge them once | 97 // drive::FileSystem::CheckLocalModificationAndRun. We should merge them once |
98 // the drive::FS side is also converted to run fully on blocking pool. | 98 // the drive::FS side is also converted to run fully on blocking pool. |
99 if (cache_entry.is_dirty()) { | 99 if (cache_entry.is_dirty()) { |
100 base::PlatformFileInfo file_info; | 100 base::PlatformFileInfo file_info; |
101 if (file_util::GetFileInfo(*cache_file_path, &file_info)) | 101 if (base::GetFileInfo(*cache_file_path, &file_info)) |
102 SetPlatformFileInfoToResourceEntry(file_info, entry); | 102 SetPlatformFileInfoToResourceEntry(file_info, entry); |
103 } | 103 } |
104 | 104 |
105 return FILE_ERROR_OK; | 105 return FILE_ERROR_OK; |
106 } | 106 } |
107 | 107 |
108 // Calls CheckPreConditionForEnsureFileDownloaded() with the entry specified by | 108 // Calls CheckPreConditionForEnsureFileDownloaded() with the entry specified by |
109 // the given ID. Also fills |drive_file_path| with the path of the entry. | 109 // the given ID. Also fills |drive_file_path| with the path of the entry. |
110 FileError CheckPreConditionForEnsureFileDownloadedByLocalId( | 110 FileError CheckPreConditionForEnsureFileDownloadedByLocalId( |
111 internal::ResourceMetadata* metadata, | 111 internal::ResourceMetadata* metadata, |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 observer_->OnDirectoryChangedByOperation(file_path.DirName()); | 481 observer_->OnDirectoryChangedByOperation(file_path.DirName()); |
482 params->OnComplete(*cache_file_path); | 482 params->OnComplete(*cache_file_path); |
483 } | 483 } |
484 | 484 |
485 void DownloadOperation::CancelJob(JobID job_id) { | 485 void DownloadOperation::CancelJob(JobID job_id) { |
486 scheduler_->CancelJob(job_id); | 486 scheduler_->CancelJob(job_id); |
487 } | 487 } |
488 | 488 |
489 } // namespace file_system | 489 } // namespace file_system |
490 } // namespace drive | 490 } // namespace drive |
OLD | NEW |