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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 internal::FileCache* cache, | 189 internal::FileCache* cache, |
190 const std::string& resource_id, | 190 const std::string& resource_id, |
191 const std::string& md5, | 191 const std::string& md5, |
192 google_apis::GDataErrorCode gdata_error, | 192 google_apis::GDataErrorCode gdata_error, |
193 const base::FilePath& downloaded_file_path, | 193 const base::FilePath& downloaded_file_path, |
194 base::FilePath* cache_file_path) { | 194 base::FilePath* cache_file_path) { |
195 DCHECK(cache); | 195 DCHECK(cache); |
196 | 196 |
197 FileError error = util::GDataToFileError(gdata_error); | 197 FileError error = util::GDataToFileError(gdata_error); |
198 if (error != FILE_ERROR_OK) { | 198 if (error != FILE_ERROR_OK) { |
199 file_util::Delete(downloaded_file_path, false /* recursive */); | 199 base::Delete(downloaded_file_path, false /* recursive */); |
200 return error; | 200 return error; |
201 } | 201 } |
202 | 202 |
203 // Here the download is completed successfully, so store it into the cache. | 203 // Here the download is completed successfully, so store it into the cache. |
204 error = cache->Store(resource_id, md5, downloaded_file_path, | 204 error = cache->Store(resource_id, md5, downloaded_file_path, |
205 internal::FileCache::FILE_OPERATION_MOVE); | 205 internal::FileCache::FILE_OPERATION_MOVE); |
206 if (error != FILE_ERROR_OK) { | 206 if (error != FILE_ERROR_OK) { |
207 file_util::Delete(downloaded_file_path, false /* recursive */); | 207 base::Delete(downloaded_file_path, false /* recursive */); |
208 return error; | 208 return error; |
209 } | 209 } |
210 | 210 |
211 return cache->GetFile(resource_id, md5, cache_file_path); | 211 return cache->GetFile(resource_id, md5, cache_file_path); |
212 } | 212 } |
213 | 213 |
214 } // namespace | 214 } // namespace |
215 | 215 |
216 class DownloadOperation::DownloadCallback { | 216 class DownloadOperation::DownloadCallback { |
217 public: | 217 public: |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 observer_->OnDirectoryChangedByOperation(file_path.DirName()); | 533 observer_->OnDirectoryChangedByOperation(file_path.DirName()); |
534 callback.OnComplete(*cache_file_path, entry.Pass()); | 534 callback.OnComplete(*cache_file_path, entry.Pass()); |
535 } | 535 } |
536 | 536 |
537 void DownloadOperation::CancelJob(JobID job_id) { | 537 void DownloadOperation::CancelJob(JobID job_id) { |
538 scheduler_->CancelJob(job_id); | 538 scheduler_->CancelJob(job_id); |
539 } | 539 } |
540 | 540 |
541 } // namespace file_system | 541 } // namespace file_system |
542 } // namespace drive | 542 } // namespace drive |
OLD | NEW |