OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/download_handler.h" | 5 #include "chrome/browser/chromeos/drive/download_handler.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/macros.h" |
9 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
10 #include "base/supports_user_data.h" | 13 #include "base/supports_user_data.h" |
11 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
12 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
13 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
14 #include "chrome/browser/chromeos/drive/file_system_util.h" | 17 #include "chrome/browser/chromeos/drive/file_system_util.h" |
15 #include "chrome/browser/chromeos/drive/write_on_cache_file.h" | 18 #include "chrome/browser/chromeos/drive/write_on_cache_file.h" |
16 #include "chrome/browser/download/download_history.h" | 19 #include "chrome/browser/download/download_history.h" |
17 #include "chrome/browser/download/download_service.h" | 20 #include "chrome/browser/download/download_service.h" |
18 #include "chrome/browser/download/download_service_factory.h" | 21 #include "chrome/browser/download/download_service_factory.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 util::ExtractDrivePath(GetTargetPath(download)), | 247 util::ExtractDrivePath(GetTargetPath(download)), |
245 base::Bind(&ContinueCheckingForFileExistence, | 248 base::Bind(&ContinueCheckingForFileExistence, |
246 callback)); | 249 callback)); |
247 } | 250 } |
248 | 251 |
249 void DownloadHandler::SetFreeDiskSpaceDelayForTesting( | 252 void DownloadHandler::SetFreeDiskSpaceDelayForTesting( |
250 const base::TimeDelta& delay) { | 253 const base::TimeDelta& delay) { |
251 free_disk_space_delay_ = delay; | 254 free_disk_space_delay_ = delay; |
252 } | 255 } |
253 | 256 |
254 int64 DownloadHandler::CalculateRequestSpace( | 257 int64_t DownloadHandler::CalculateRequestSpace( |
255 const DownloadManager::DownloadVector& downloads) { | 258 const DownloadManager::DownloadVector& downloads) { |
256 int64 request_space = 0; | 259 int64_t request_space = 0; |
257 | 260 |
258 for (const auto* download : downloads) { | 261 for (const auto* download : downloads) { |
259 if (download->IsDone()) | 262 if (download->IsDone()) |
260 continue; | 263 continue; |
261 | 264 |
262 const int64 total_bytes = download->GetTotalBytes(); | 265 const int64_t total_bytes = download->GetTotalBytes(); |
263 // Skip unknown size download. Since drive cache tries to keep | 266 // Skip unknown size download. Since drive cache tries to keep |
264 // drive::internal::kMinFreeSpaceInBytes, we can continue download with | 267 // drive::internal::kMinFreeSpaceInBytes, we can continue download with |
265 // using the space temporally. | 268 // using the space temporally. |
266 if (total_bytes == 0) | 269 if (total_bytes == 0) |
267 continue; | 270 continue; |
268 | 271 |
269 request_space += total_bytes - download->GetReceivedBytes(); | 272 request_space += total_bytes - download->GetReceivedBytes(); |
270 } | 273 } |
271 | 274 |
272 return request_space; | 275 return request_space; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 422 |
420 DownloadManager* DownloadHandler::GetDownloadManager(void* manager_id) { | 423 DownloadManager* DownloadHandler::GetDownloadManager(void* manager_id) { |
421 if (manager_id == notifier_->GetManager()) | 424 if (manager_id == notifier_->GetManager()) |
422 return notifier_->GetManager(); | 425 return notifier_->GetManager(); |
423 if (notifier_incognito_ && manager_id == notifier_incognito_->GetManager()) | 426 if (notifier_incognito_ && manager_id == notifier_incognito_->GetManager()) |
424 return notifier_incognito_->GetManager(); | 427 return notifier_incognito_->GetManager(); |
425 return NULL; | 428 return NULL; |
426 } | 429 } |
427 | 430 |
428 } // namespace drive | 431 } // namespace drive |
OLD | NEW |