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 "components/drive/file_system/download_operation.h" | 5 #include "components/drive/file_system/download_operation.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
8 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" |
11 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
12 #include "components/drive/drive.pb.h" | 15 #include "components/drive/drive.pb.h" |
13 #include "components/drive/file_cache.h" | 16 #include "components/drive/file_cache.h" |
14 #include "components/drive/file_change.h" | 17 #include "components/drive/file_change.h" |
15 #include "components/drive/file_errors.h" | 18 #include "components/drive/file_errors.h" |
16 #include "components/drive/file_system/operation_delegate.h" | 19 #include "components/drive/file_system/operation_delegate.h" |
17 #include "components/drive/file_system_core_util.h" | 20 #include "components/drive/file_system_core_util.h" |
18 #include "components/drive/job_scheduler.h" | 21 #include "components/drive/job_scheduler.h" |
19 #include "components/drive/resource_metadata.h" | 22 #include "components/drive/resource_metadata.h" |
20 #include "google_apis/drive/drive_api_error_codes.h" | 23 #include "google_apis/drive/drive_api_error_codes.h" |
(...skipping 15 matching lines...) Expand all Loading... |
36 } | 39 } |
37 *out_path = subdir.Append(FILE_PATH_LITERAL("tmp") + extension); | 40 *out_path = subdir.Append(FILE_PATH_LITERAL("tmp") + extension); |
38 return true; | 41 return true; |
39 } | 42 } |
40 | 43 |
41 // Prepares for downloading the file. Allocates the enough space for the file | 44 // Prepares for downloading the file. Allocates the enough space for the file |
42 // in the cache. | 45 // in the cache. |
43 // If succeeded, returns FILE_ERROR_OK with |temp_download_file| storing the | 46 // If succeeded, returns FILE_ERROR_OK with |temp_download_file| storing the |
44 // path to the file in the cache. | 47 // path to the file in the cache. |
45 FileError PrepareForDownloadFile(internal::FileCache* cache, | 48 FileError PrepareForDownloadFile(internal::FileCache* cache, |
46 int64 expected_file_size, | 49 int64_t expected_file_size, |
47 const base::FilePath& temporary_file_directory, | 50 const base::FilePath& temporary_file_directory, |
48 base::FilePath* temp_download_file) { | 51 base::FilePath* temp_download_file) { |
49 DCHECK(cache); | 52 DCHECK(cache); |
50 DCHECK(temp_download_file); | 53 DCHECK(temp_download_file); |
51 | 54 |
52 // Ensure enough space in the cache. | 55 // Ensure enough space in the cache. |
53 if (!cache->FreeDiskSpaceIfNeededFor(expected_file_size)) | 56 if (!cache->FreeDiskSpaceIfNeededFor(expected_file_size)) |
54 return FILE_ERROR_NO_LOCAL_SPACE; | 57 return FILE_ERROR_NO_LOCAL_SPACE; |
55 | 58 |
56 return base::CreateTemporaryFileInDir( | 59 return base::CreateTemporaryFileInDir( |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 delegate_->OnFileChangedByOperation(changed_files); | 534 delegate_->OnFileChangedByOperation(changed_files); |
532 params->OnDownloadCompleted(*cache_file_path, entry_after_update.Pass()); | 535 params->OnDownloadCompleted(*cache_file_path, entry_after_update.Pass()); |
533 } | 536 } |
534 | 537 |
535 void DownloadOperation::CancelJob(JobID job_id) { | 538 void DownloadOperation::CancelJob(JobID job_id) { |
536 scheduler_->CancelJob(job_id); | 539 scheduler_->CancelJob(job_id); |
537 } | 540 } |
538 | 541 |
539 } // namespace file_system | 542 } // namespace file_system |
540 } // namespace drive | 543 } // namespace drive |
OLD | NEW |