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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 // Creates a file with unique name in |dir| and stores the path to |temp_file|. | 142 // Creates a file with unique name in |dir| and stores the path to |temp_file|. |
143 // Additionally, sets the permission of the file to allow read access from | 143 // Additionally, sets the permission of the file to allow read access from |
144 // others and group member users (i.e, "-rw-r--r--"). | 144 // others and group member users (i.e, "-rw-r--r--"). |
145 // We need this wrapper because Drive cache files may be read from other | 145 // We need this wrapper because Drive cache files may be read from other |
146 // processes (e.g., cros_disks for mounting zip files). | 146 // processes (e.g., cros_disks for mounting zip files). |
147 bool CreateTemporaryReadableFileInDir(const base::FilePath& dir, | 147 bool CreateTemporaryReadableFileInDir(const base::FilePath& dir, |
148 base::FilePath* temp_file) { | 148 base::FilePath* temp_file) { |
149 if (!file_util::CreateTemporaryFileInDir(dir, temp_file)) | 149 if (!file_util::CreateTemporaryFileInDir(dir, temp_file)) |
150 return false; | 150 return false; |
151 return file_util::SetPosixFilePermissions( | 151 return base::SetPosixFilePermissions( |
152 *temp_file, | 152 *temp_file, |
153 file_util::FILE_PERMISSION_READ_BY_USER | | 153 base::FILE_PERMISSION_READ_BY_USER | |
154 file_util::FILE_PERMISSION_WRITE_BY_USER | | 154 base::FILE_PERMISSION_WRITE_BY_USER | |
155 file_util::FILE_PERMISSION_READ_BY_GROUP | | 155 base::FILE_PERMISSION_READ_BY_GROUP | |
156 file_util::FILE_PERMISSION_READ_BY_OTHERS); | 156 base::FILE_PERMISSION_READ_BY_OTHERS); |
157 } | 157 } |
158 | 158 |
159 // Prepares for downloading the file. Allocates the enough space for the file | 159 // Prepares for downloading the file. Allocates the enough space for the file |
160 // in the cache. | 160 // in the cache. |
161 // If succeeded, returns FILE_ERROR_OK with |temp_download_file| storing the | 161 // If succeeded, returns FILE_ERROR_OK with |temp_download_file| storing the |
162 // path to the file in the cache. | 162 // path to the file in the cache. |
163 FileError PrepareForDownloadFile(internal::FileCache* cache, | 163 FileError PrepareForDownloadFile(internal::FileCache* cache, |
164 int64 expected_file_size, | 164 int64 expected_file_size, |
165 const base::FilePath& temporary_file_directory, | 165 const base::FilePath& temporary_file_directory, |
166 base::FilePath* temp_download_file) { | 166 base::FilePath* temp_download_file) { |
(...skipping 314 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 |