| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/download/download_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 download_path)); | 417 download_path)); |
| 418 | 418 |
| 419 download->Rename(download_path); | 419 download->Rename(download_path); |
| 420 | 420 |
| 421 delegate_->AddItemToPersistentStore(download); | 421 delegate_->AddItemToPersistentStore(download); |
| 422 } | 422 } |
| 423 | 423 |
| 424 void DownloadManagerImpl::UpdateDownload(int32 download_id, | 424 void DownloadManagerImpl::UpdateDownload(int32 download_id, |
| 425 int64 bytes_so_far, | 425 int64 bytes_so_far, |
| 426 int64 bytes_per_sec, | 426 int64 bytes_per_sec, |
| 427 std::string hash_state) { | 427 const std::string& hash_state) { |
| 428 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 428 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 429 DownloadMap::iterator it = active_downloads_.find(download_id); | 429 DownloadMap::iterator it = active_downloads_.find(download_id); |
| 430 if (it != active_downloads_.end()) { | 430 if (it != active_downloads_.end()) { |
| 431 DownloadItem* download = it->second; | 431 DownloadItem* download = it->second; |
| 432 if (download->IsInProgress()) { | 432 if (download->IsInProgress()) { |
| 433 download->UpdateProgress(bytes_so_far, bytes_per_sec, hash_state); | 433 download->UpdateProgress(bytes_so_far, bytes_per_sec, hash_state); |
| 434 UpdateDownloadProgress(); // Reflect size updates. | 434 UpdateDownloadProgress(); // Reflect size updates. |
| 435 delegate_->UpdateItemInPersistentStore(download); | 435 delegate_->UpdateItemInPersistentStore(download); |
| 436 } | 436 } |
| 437 } | 437 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 // This function is called from the DownloadItem, so DI state | 616 // This function is called from the DownloadItem, so DI state |
| 617 // should already have been updated. | 617 // should already have been updated. |
| 618 AssertStateConsistent(download); | 618 AssertStateConsistent(download); |
| 619 | 619 |
| 620 if (file_manager_) | 620 if (file_manager_) |
| 621 download->OffThreadCancel(file_manager_); | 621 download->OffThreadCancel(file_manager_); |
| 622 } | 622 } |
| 623 | 623 |
| 624 void DownloadManagerImpl::OnDownloadInterrupted(int32 download_id, | 624 void DownloadManagerImpl::OnDownloadInterrupted(int32 download_id, |
| 625 int64 size, | 625 int64 size, |
| 626 std::string hash_state, | 626 const std::string& hash_state, |
| 627 InterruptReason reason) { | 627 InterruptReason reason) { |
| 628 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 628 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 629 | 629 |
| 630 DownloadItem* download = GetActiveDownload(download_id); | 630 DownloadItem* download = GetActiveDownload(download_id); |
| 631 if (!download) | 631 if (!download) |
| 632 return; | 632 return; |
| 633 | 633 |
| 634 VLOG(20) << __FUNCTION__ << "()" | 634 VLOG(20) << __FUNCTION__ << "()" |
| 635 << " reason " << InterruptReasonDebugString(reason) | 635 << " reason " << InterruptReasonDebugString(reason) |
| 636 << " at offset " << download->GetReceivedBytes() | 636 << " at offset " << download->GetReceivedBytes() |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 it != history_downloads_.end(); ++it) { | 1136 it != history_downloads_.end(); ++it) { |
| 1137 if (it->second->IsComplete() && !it->second->GetOpened()) | 1137 if (it->second->IsComplete() && !it->second->GetOpened()) |
| 1138 ++num_unopened; | 1138 ++num_unopened; |
| 1139 } | 1139 } |
| 1140 download_stats::RecordOpensOutstanding(num_unopened); | 1140 download_stats::RecordOpensOutstanding(num_unopened); |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { | 1143 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { |
| 1144 file_manager_ = file_manager; | 1144 file_manager_ = file_manager; |
| 1145 } | 1145 } |
| OLD | NEW |