| 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.h" | 5 #include "content/browser/download/download_manager.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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 | 730 |
| 731 void DownloadManager::AddObserver(Observer* observer) { | 731 void DownloadManager::AddObserver(Observer* observer) { |
| 732 observers_.AddObserver(observer); | 732 observers_.AddObserver(observer); |
| 733 observer->ModelChanged(); | 733 observer->ModelChanged(); |
| 734 } | 734 } |
| 735 | 735 |
| 736 void DownloadManager::RemoveObserver(Observer* observer) { | 736 void DownloadManager::RemoveObserver(Observer* observer) { |
| 737 observers_.RemoveObserver(observer); | 737 observers_.RemoveObserver(observer); |
| 738 } | 738 } |
| 739 | 739 |
| 740 bool DownloadManager::IsDownloadProgressKnown() { | 740 bool DownloadManager::IsDownloadProgressKnown() const { |
| 741 for (DownloadMap::iterator i = in_progress_.begin(); | 741 for (DownloadMap::const_iterator i = in_progress_.begin(); |
| 742 i != in_progress_.end(); ++i) { | 742 i != in_progress_.end(); ++i) { |
| 743 if (i->second->total_bytes() <= 0) | 743 if (i->second->total_bytes() <= 0) |
| 744 return false; | 744 return false; |
| 745 } | 745 } |
| 746 | 746 |
| 747 return true; | 747 return true; |
| 748 } | 748 } |
| 749 | 749 |
| 750 int64 DownloadManager::GetInProgressDownloadCount() { | 750 int64 DownloadManager::GetInProgressDownloadCount() const { |
| 751 return in_progress_.size(); | 751 return in_progress_.size(); |
| 752 } | 752 } |
| 753 | 753 |
| 754 int64 DownloadManager::GetReceivedDownloadBytes() { | 754 int64 DownloadManager::GetReceivedDownloadBytes() const { |
| 755 DCHECK(IsDownloadProgressKnown()); | 755 DCHECK(IsDownloadProgressKnown()); |
| 756 int64 received_bytes = 0; | 756 int64 received_bytes = 0; |
| 757 for (DownloadMap::iterator i = in_progress_.begin(); | 757 for (DownloadMap::const_iterator i = in_progress_.begin(); |
| 758 i != in_progress_.end(); ++i) { | 758 i != in_progress_.end(); ++i) { |
| 759 received_bytes += i->second->received_bytes(); | 759 received_bytes += i->second->received_bytes(); |
| 760 } | 760 } |
| 761 return received_bytes; | 761 return received_bytes; |
| 762 } | 762 } |
| 763 | 763 |
| 764 int64 DownloadManager::GetTotalDownloadBytes() { | 764 int64 DownloadManager::GetTotalDownloadBytes() const { |
| 765 DCHECK(IsDownloadProgressKnown()); | 765 DCHECK(IsDownloadProgressKnown()); |
| 766 int64 total_bytes = 0; | 766 int64 total_bytes = 0; |
| 767 for (DownloadMap::iterator i = in_progress_.begin(); | 767 for (DownloadMap::const_iterator i = in_progress_.begin(); |
| 768 i != in_progress_.end(); ++i) { | 768 i != in_progress_.end(); ++i) { |
| 769 total_bytes += i->second->total_bytes(); | 769 total_bytes += i->second->total_bytes(); |
| 770 } | 770 } |
| 771 return total_bytes; | 771 return total_bytes; |
| 772 } | 772 } |
| 773 | 773 |
| 774 void DownloadManager::FileSelected(const FilePath& path, void* params) { | 774 void DownloadManager::FileSelected(const FilePath& path, void* params) { |
| 775 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 775 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 776 | 776 |
| 777 int32* id_ptr = reinterpret_cast<int32*>(params); | 777 int32* id_ptr = reinterpret_cast<int32*>(params); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 void DownloadManager::MarkDownloadOpened(DownloadItem* download) { | 1083 void DownloadManager::MarkDownloadOpened(DownloadItem* download) { |
| 1084 delegate_->UpdateItemInPersistentStore(download); | 1084 delegate_->UpdateItemInPersistentStore(download); |
| 1085 int num_unopened = 0; | 1085 int num_unopened = 0; |
| 1086 for (DownloadMap::iterator it = history_downloads_.begin(); | 1086 for (DownloadMap::iterator it = history_downloads_.begin(); |
| 1087 it != history_downloads_.end(); ++it) { | 1087 it != history_downloads_.end(); ++it) { |
| 1088 if (it->second->IsComplete() && !it->second->opened()) | 1088 if (it->second->IsComplete() && !it->second->opened()) |
| 1089 ++num_unopened; | 1089 ++num_unopened; |
| 1090 } | 1090 } |
| 1091 download_stats::RecordOpensOutstanding(num_unopened); | 1091 download_stats::RecordOpensOutstanding(num_unopened); |
| 1092 } | 1092 } |
| OLD | NEW |