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 "chrome/browser/download/download_manager.h" | 5 #include "chrome/browser/download/download_manager.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 // The user hasn't accepted it, so we need to remove it | 99 // The user hasn't accepted it, so we need to remove it |
100 // from the disk. This may or may not result in it being | 100 // from the disk. This may or may not result in it being |
101 // removed from the DownloadManager queues and deleted | 101 // removed from the DownloadManager queues and deleted |
102 // (specifically, DownloadManager::RemoveDownload only | 102 // (specifically, DownloadManager::RemoveDownload only |
103 // removes and deletes it if it's known to the history service) | 103 // removes and deletes it if it's known to the history service) |
104 // so the only thing we know after calling this function is that | 104 // so the only thing we know after calling this function is that |
105 // the download was deleted if-and-only-if it was removed | 105 // the download was deleted if-and-only-if it was removed |
106 // from all queues. | 106 // from all queues. |
107 download->Delete(DownloadItem::DELETE_DUE_TO_BROWSER_SHUTDOWN); | 107 download->Delete(DownloadItem::DELETE_DUE_TO_BROWSER_SHUTDOWN); |
108 } else if (download->IsPartialDownload()) { | 108 } else if (download->IsPartialDownload()) { |
109 download->Cancel(false); | 109 download->Cancel(); |
110 download_history_->UpdateEntry(download); | |
111 } | 110 } |
112 } | 111 } |
113 | 112 |
114 // At this point, all dangerous downloads have had their files removed | 113 // At this point, all dangerous downloads have had their files removed |
115 // and all in progress downloads have been cancelled. We can now delete | 114 // and all in progress downloads have been cancelled. We can now delete |
116 // anything left. | 115 // anything left. |
117 | 116 |
118 // Copy downloads_ to separate container so as not to set off checks | 117 // Copy downloads_ to separate container so as not to set off checks |
119 // in DownloadItem destruction. | 118 // in DownloadItem destruction. |
120 DownloadSet downloads_to_delete; | 119 DownloadSet downloads_to_delete; |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 // body, and then close the connection. Other browsers - IE8, Firefox 4.0.1, | 636 // body, and then close the connection. Other browsers - IE8, Firefox 4.0.1, |
638 // and Safari 5.0.4 - treat the download as complete in this case, so we | 637 // and Safari 5.0.4 - treat the download as complete in this case, so we |
639 // follow their lead. | 638 // follow their lead. |
640 if (os_error == 0 || os_error == net::ERR_CONNECTION_CLOSED) { | 639 if (os_error == 0 || os_error == net::ERR_CONNECTION_CLOSED) { |
641 OnAllDataSaved(download_id, size, hash); | 640 OnAllDataSaved(download_id, size, hash); |
642 } else { | 641 } else { |
643 OnDownloadError(download_id, size, os_error); | 642 OnDownloadError(download_id, size, os_error); |
644 } | 643 } |
645 } | 644 } |
646 | 645 |
646 void DownloadManager::CancelDownload(int32 download_id) { | |
647 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
648 DownloadMap::iterator it = active_downloads_.find(download_id); | |
649 if (it == active_downloads_.end()) | |
650 return; | |
651 | |
652 it->second->Cancel(); | |
653 } | |
654 | |
647 void DownloadManager::OnAllDataSaved(int32 download_id, | 655 void DownloadManager::OnAllDataSaved(int32 download_id, |
648 int64 size, | 656 int64 size, |
649 const std::string& hash) { | 657 const std::string& hash) { |
650 VLOG(20) << __FUNCTION__ << "()" << " download_id = " << download_id | 658 VLOG(20) << __FUNCTION__ << "()" << " download_id = " << download_id |
651 << " size = " << size; | 659 << " size = " << size; |
652 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 660 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
653 | 661 |
654 // If it's not in active_downloads_, that means it was cancelled; just | 662 // If it's not in active_downloads_, that means it was cancelled; just |
655 // ignore the notification. | 663 // ignore the notification. |
656 if (active_downloads_.count(download_id) == 0) | 664 if (active_downloads_.count(download_id) == 0) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 // TODO(rdsmith): Somewhat painful; make sure to disable in | 719 // TODO(rdsmith): Somewhat painful; make sure to disable in |
712 // release builds after resolution of http://crbug.com/85408. | 720 // release builds after resolution of http://crbug.com/85408. |
713 for (DownloadMap::iterator it = history_downloads_.begin(); | 721 for (DownloadMap::iterator it = history_downloads_.begin(); |
714 it != history_downloads_.end(); ++it) { | 722 it != history_downloads_.end(); ++it) { |
715 CHECK(it->second != download); | 723 CHECK(it->second != download); |
716 } | 724 } |
717 } | 725 } |
718 | 726 |
719 CHECK(ContainsKey(active_downloads_, download->id()) == | 727 CHECK(ContainsKey(active_downloads_, download->id()) == |
720 (download->state() == DownloadItem::IN_PROGRESS)); | 728 (download->state() == DownloadItem::IN_PROGRESS)); |
721 CHECK(ContainsKey(in_progress_, download->id()) == | 729 // Would check in_progress_, but removal from that queue happens |
722 (download->state() == DownloadItem::IN_PROGRESS)); | 730 // before transition from IN_PROGRESS for legacy reasons, so skipping. |
723 } | 731 } |
724 | 732 |
725 bool DownloadManager::IsDownloadReadyForCompletion(DownloadItem* download) { | 733 bool DownloadManager::IsDownloadReadyForCompletion(DownloadItem* download) { |
726 // If we don't have all the data, the download is not ready for | 734 // If we don't have all the data, the download is not ready for |
727 // completion. | 735 // completion. |
728 if (!download->all_data_saved()) | 736 if (!download->all_data_saved()) |
729 return false; | 737 return false; |
730 | 738 |
731 // If the download is dangerous, but not yet validated, it's not ready for | 739 // If the download is dangerous, but not yet validated, it's not ready for |
732 // completion. | 740 // completion. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
809 NewRunnableMethod( | 817 NewRunnableMethod( |
810 file_manager_, &DownloadFileManager::CompleteDownload, download_id)); | 818 file_manager_, &DownloadFileManager::CompleteDownload, download_id)); |
811 | 819 |
812 if (uniquifier) | 820 if (uniquifier) |
813 item->set_path_uniquifier(uniquifier); | 821 item->set_path_uniquifier(uniquifier); |
814 | 822 |
815 item->OnDownloadRenamedToFinalName(full_path); | 823 item->OnDownloadRenamedToFinalName(full_path); |
816 download_history_->UpdateDownloadPath(item, full_path); | 824 download_history_->UpdateDownloadPath(item, full_path); |
817 } | 825 } |
818 | 826 |
819 void DownloadManager::DownloadCancelled(int32 download_id) { | 827 void DownloadManager::DownloadStopped(int32 download_id) { |
820 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 828 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
821 DownloadMap::iterator it = in_progress_.find(download_id); | 829 DownloadMap::iterator it = active_downloads_.find(download_id); |
822 if (it == in_progress_.end()) | 830 if (it == active_downloads_.end()) |
823 return; | 831 return; |
824 DownloadItem* download = it->second; | 832 DownloadItem* download = it->second; |
825 | 833 |
826 VLOG(20) << __FUNCTION__ << "()" << " download_id = " << download_id | 834 VLOG(20) << __FUNCTION__ << "()" << " download_id = " << download_id |
827 << " download = " << download->DebugString(true); | 835 << " download = " << download->DebugString(true); |
828 | 836 |
829 // Clean up will happen when the history system create callback runs if we | 837 in_progress_.erase(download_id); |
830 // don't have a valid db_handle yet. | 838 active_downloads_.erase(download_id); |
831 if (download->db_handle() != DownloadHistory::kUninitializedHandle) { | 839 UpdateAppIcon(); // Reflect removal from in_progress_. |
832 in_progress_.erase(it); | |
833 active_downloads_.erase(download_id); | |
834 UpdateAppIcon(); // Reflect removal from in_progress_. | |
835 download_history_->UpdateEntry(download); | |
836 } | |
837 | 840 |
838 DownloadCancelledInternal(download_id, download->request_handle()); | 841 // The history service should always outlive the DownloadManager. |
839 } | 842 download_history_->UpdateEntry(download); |
840 | 843 |
841 void DownloadManager::DownloadCancelledInternal( | 844 download->request_handle().CancelRequest(); |
842 int download_id, DownloadRequestHandle request_handle) { | |
843 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
844 request_handle.CancelRequest(); | |
845 | 845 |
846 // TODO(ahendrickson) - Remove this when we add resuming of interrupted | |
847 // downloads, as we will keep the download item around in that case. | |
846 BrowserThread::PostTask( | 848 BrowserThread::PostTask( |
847 BrowserThread::FILE, FROM_HERE, | 849 BrowserThread::FILE, FROM_HERE, |
848 NewRunnableMethod( | 850 NewRunnableMethod( |
849 file_manager_, &DownloadFileManager::CancelDownload, download_id)); | 851 file_manager_, &DownloadFileManager::CancelDownload, download_id)); |
850 } | 852 } |
851 | 853 |
852 void DownloadManager::OnDownloadError(int32 download_id, | 854 void DownloadManager::OnDownloadError(int32 download_id, |
853 int64 size, | 855 int64 size, |
854 int os_error) { | 856 int os_error) { |
855 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 857 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
856 DownloadMap::iterator it = active_downloads_.find(download_id); | 858 DownloadMap::iterator it = active_downloads_.find(download_id); |
857 // A cancel at the right time could remove the download from the | 859 // A cancel at the right time could remove the download from the |
858 // |active_downloads_| map before we get here. | 860 // |active_downloads_| map before we get here. |
859 if (it == active_downloads_.end()) | 861 if (it == active_downloads_.end()) |
860 return; | 862 return; |
861 | 863 |
862 DownloadItem* download = it->second; | 864 DownloadItem* download = it->second; |
863 | 865 |
864 VLOG(20) << __FUNCTION__ << "()" << " Error " << os_error | 866 VLOG(20) << __FUNCTION__ << "()" << " Error " << os_error |
865 << " at offset " << download->received_bytes() | 867 << " at offset " << download->received_bytes() |
866 << " for download = " << download->DebugString(true); | 868 << " for download = " << download->DebugString(true); |
867 | 869 |
868 download->Interrupted(size, os_error); | 870 download->Interrupt(size, os_error); |
869 | |
870 // TODO(ahendrickson) - Remove this when we add resuming of interrupted | |
871 // downloads, as we will keep the download item around in that case. | |
872 // | |
873 // Clean up will happen when the history system create callback runs if we | |
874 // don't have a valid db_handle yet. | |
875 if (download->db_handle() != DownloadHistory::kUninitializedHandle) { | |
876 in_progress_.erase(download_id); | |
877 active_downloads_.erase(download_id); | |
878 UpdateAppIcon(); // Reflect removal from in_progress_. | |
879 download_history_->UpdateEntry(download); | |
880 } | |
881 | |
882 BrowserThread::PostTask( | |
883 BrowserThread::FILE, FROM_HERE, | |
884 NewRunnableMethod( | |
885 file_manager_, &DownloadFileManager::CancelDownload, download_id)); | |
886 } | 871 } |
887 | 872 |
888 void DownloadManager::UpdateAppIcon() { | 873 void DownloadManager::UpdateAppIcon() { |
889 if (status_updater_) | 874 if (status_updater_) |
890 status_updater_->Update(); | 875 status_updater_->Update(); |
891 } | 876 } |
892 | 877 |
893 void DownloadManager::RemoveDownload(int64 download_handle) { | 878 void DownloadManager::RemoveDownload(DownloadItem* download) { |
894 DownloadMap::iterator it = history_downloads_.find(download_handle); | 879 // Silently ignores request if db handled indicates that the download |
Randy Smith (Not in Mondays)
2011/06/30 23:05:13
"handled" -> "handle"
Randy Smith (Not in Mondays)
2011/07/05 20:28:44
Done.
| |
895 if (it == history_downloads_.end()) | 880 // isn't in the history. |
896 return; | 881 download_history_->RemoveEntry(download->db_handle()); |
897 | |
898 // Make history update. | |
899 DownloadItem* download = it->second; | |
900 download_history_->RemoveEntry(download); | |
901 | 882 |
902 // Remove from our tables and delete. | 883 // Remove from our tables and delete. |
903 history_downloads_.erase(it); | 884 if (download->db_handle() != DownloadHistory::kUninitializedHandle) |
885 history_downloads_.erase(download->db_handle()); | |
904 int downloads_count = downloads_.erase(download); | 886 int downloads_count = downloads_.erase(download); |
905 DCHECK_EQ(1, downloads_count); | 887 DCHECK_EQ(1, downloads_count); |
906 | 888 |
907 // Tell observers to refresh their views. | 889 // Tell observers to refresh their views. |
908 NotifyModelChanged(); | 890 NotifyModelChanged(); |
909 | 891 |
910 delete download; | 892 delete download; |
911 } | 893 } |
912 | 894 |
913 int DownloadManager::RemoveDownloadsBetween(const base::Time remove_begin, | 895 int DownloadManager::RemoveDownloadsBetween(const base::Time remove_begin, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1099 int32 download_id = *id_ptr; | 1081 int32 download_id = *id_ptr; |
1100 delete id_ptr; | 1082 delete id_ptr; |
1101 | 1083 |
1102 DownloadItem* download = GetActiveDownloadItem(download_id); | 1084 DownloadItem* download = GetActiveDownloadItem(download_id); |
1103 if (!download) | 1085 if (!download) |
1104 return; | 1086 return; |
1105 | 1087 |
1106 VLOG(20) << __FUNCTION__ << "()" | 1088 VLOG(20) << __FUNCTION__ << "()" |
1107 << " download = " << download->DebugString(true); | 1089 << " download = " << download->DebugString(true); |
1108 | 1090 |
1109 DownloadCancelledInternal(download_id, download->request_handle()); | 1091 download->Cancel(); |
1110 } | 1092 } |
1111 | 1093 |
1112 // TODO(phajdan.jr): This is apparently not being exercised in tests. | 1094 // TODO(phajdan.jr): This is apparently not being exercised in tests. |
1113 bool DownloadManager::IsDangerous(const DownloadItem& download, | 1095 bool DownloadManager::IsDangerous(const DownloadItem& download, |
1114 const DownloadStateInfo& state, | 1096 const DownloadStateInfo& state, |
1115 bool visited_referrer_before) { | 1097 bool visited_referrer_before) { |
1116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1098 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1117 | 1099 |
1118 bool auto_open = ShouldOpenFileBasedOnExtension(state.suggested_path); | 1100 bool auto_open = ShouldOpenFileBasedOnExtension(state.suggested_path); |
1119 download_util::DownloadDangerLevel danger_level = | 1101 download_util::DownloadDangerLevel danger_level = |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1162 NotifyModelChanged(); | 1144 NotifyModelChanged(); |
1163 CheckForHistoryFilesRemoval(); | 1145 CheckForHistoryFilesRemoval(); |
1164 } | 1146 } |
1165 | 1147 |
1166 // Once the new DownloadItem's creation info has been committed to the history | 1148 // Once the new DownloadItem's creation info has been committed to the history |
1167 // service, we associate the DownloadItem with the db handle, update our | 1149 // service, we associate the DownloadItem with the db handle, update our |
1168 // 'history_downloads_' map and inform observers. | 1150 // 'history_downloads_' map and inform observers. |
1169 void DownloadManager::OnCreateDownloadEntryComplete(int32 download_id, | 1151 void DownloadManager::OnCreateDownloadEntryComplete(int32 download_id, |
1170 int64 db_handle) { | 1152 int64 db_handle) { |
1171 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1172 DownloadItem* download = GetActiveDownloadItem(download_id); | |
1173 if (!download) | |
1174 return; | |
1175 | 1154 |
1176 VLOG(20) << __FUNCTION__ << "()" << " db_handle = " << db_handle | 1155 VLOG(20) << __FUNCTION__ << "()" << " db_handle = " << db_handle |
1177 << " download_id = " << download_id | 1156 << " download_id = " << download_id; |
1178 << " download = " << download->DebugString(true); | |
1179 | 1157 |
1180 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 1158 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
1181 // call this function with an invalid |db_handle|. For instance, this can | 1159 // call this function with an invalid |db_handle|. For instance, this can |
1182 // happen when the history database is offline. We cannot have multiple | 1160 // happen when the history database is offline. We cannot have multiple |
1183 // DownloadItems with the same invalid db_handle, so we need to assign a | 1161 // DownloadItems with the same invalid db_handle, so we need to assign a |
1184 // unique |db_handle| here. | 1162 // unique |db_handle| here. |
1185 if (db_handle == DownloadHistory::kUninitializedHandle) | 1163 if (db_handle == DownloadHistory::kUninitializedHandle) |
1186 db_handle = download_history_->GetNextFakeDbHandle(); | 1164 db_handle = download_history_->GetNextFakeDbHandle(); |
1187 | 1165 |
1166 DownloadItem* download = GetActiveDownloadItem(download_id); | |
1167 if (!download) { | |
1168 // The download was cancelled while the history system was entering it. | |
1169 // We resolve this race by turning around and deleting it in the | |
1170 // history system (implicitly treating is as a failure in download | |
Randy Smith (Not in Mondays)
2011/06/30 23:05:13
"is" -> "it"
Randy Smith (Not in Mondays)
2011/07/05 20:28:44
Done.
| |
1171 // initiation, which is appropriate as the only places the cancel could | |
1172 // have come from were in resolving issues (like the file name) which | |
1173 // we need to have resolved for history system insertion. | |
Randy Smith (Not in Mondays)
2011/06/30 23:05:13
Not quite true--could have come from FileSelection
Randy Smith (Not in Mondays)
2011/07/05 20:28:44
FileSelectionCancelled is part of resolving the fi
| |
1174 | |
1175 // Make sure we haven't already been shutdown (the callback raced | |
1176 // with shutdown), as that would mean that the history service has | |
1177 // also been shutdown. In that case, the history will be fixed up | |
1178 // when it's next read in. | |
Randy Smith (Not in Mondays)
2011/06/30 23:05:13
"on next browser startup".
Randy Smith (Not in Mondays)
2011/07/05 20:28:44
Done.
| |
1179 if (download_history_.get()) | |
1180 download_history_->RemoveEntry(db_handle); | |
1181 return; | |
1182 } | |
1183 | |
1184 VLOG(20) << __FUNCTION__ << "()" << " db_handle = " << db_handle | |
1185 << " download_id = " << download_id | |
1186 << " download = " << download->DebugString(true); | |
1187 | |
1188 // The download shouldn't have been returned from GetActiveDownloadItem() | |
1189 // if it's not in progress. | |
1190 DCHECK(download->IsInProgress()); | |
1191 | |
1188 DCHECK(download->db_handle() == DownloadHistory::kUninitializedHandle); | 1192 DCHECK(download->db_handle() == DownloadHistory::kUninitializedHandle); |
1189 download->set_db_handle(db_handle); | 1193 download->set_db_handle(db_handle); |
1190 | 1194 |
1191 DCHECK(!ContainsKey(history_downloads_, download->db_handle())); | 1195 DCHECK(!ContainsKey(history_downloads_, download->db_handle())); |
1192 history_downloads_[download->db_handle()] = download; | 1196 history_downloads_[download->db_handle()] = download; |
1193 | 1197 |
1194 // Show in the appropriate browser UI. | 1198 // Show in the appropriate browser UI. |
1195 // This includes buttons to save or cancel, for a dangerous download. | 1199 // This includes buttons to save or cancel, for a dangerous download. |
1196 ShowDownloadInBrowser(download); | 1200 ShowDownloadInBrowser(download); |
1197 | 1201 |
1198 // Inform interested objects about the new download. | 1202 // Inform interested objects about the new download. |
1199 NotifyModelChanged(); | 1203 NotifyModelChanged(); |
1200 | 1204 |
1201 // If the download is still in progress, try to complete it. | 1205 MaybeCompleteDownload(download); |
1202 // | |
1203 // Otherwise, download has been cancelled or interrupted before we've | |
1204 // received the DB handle. We post one final message to the history | |
1205 // service so that it can be properly in sync with the DownloadItem's | |
1206 // completion status, and also inform any observers so that they get | |
1207 // more than just the start notification. | |
1208 if (download->IsInProgress()) { | |
1209 MaybeCompleteDownload(download); | |
1210 } else { | |
1211 DCHECK(download->IsCancelled()) | |
1212 << " download = " << download->DebugString(true); | |
1213 in_progress_.erase(download_id); | |
1214 active_downloads_.erase(download_id); | |
1215 download_history_->UpdateEntry(download); | |
1216 download->UpdateObservers(); | |
1217 } | |
1218 } | 1206 } |
1219 | 1207 |
1220 void DownloadManager::ShowDownloadInBrowser(DownloadItem* download) { | 1208 void DownloadManager::ShowDownloadInBrowser(DownloadItem* download) { |
1221 | 1209 |
1222 // The 'contents' may no longer exist if the user closed the tab before we | 1210 // The 'contents' may no longer exist if the user closed the tab before we |
1223 // get this start completion event. If it does, tell the origin TabContents | 1211 // get this start completion event. If it does, tell the origin TabContents |
1224 // to display its download shelf. | 1212 // to display its download shelf. |
1225 DownloadRequestHandle request_handle = download->request_handle(); | 1213 DownloadRequestHandle request_handle = download->request_handle(); |
1226 TabContents* contents = request_handle.GetTabContents(); | 1214 TabContents* contents = request_handle.GetTabContents(); |
1227 TabContentsWrapper* wrapper = NULL; | 1215 TabContentsWrapper* wrapper = NULL; |
(...skipping 29 matching lines...) Expand all Loading... | |
1257 // not its id, so we have to iterate. | 1245 // not its id, so we have to iterate. |
1258 for (DownloadMap::iterator it = history_downloads_.begin(); | 1246 for (DownloadMap::iterator it = history_downloads_.begin(); |
1259 it != history_downloads_.end(); ++it) { | 1247 it != history_downloads_.end(); ++it) { |
1260 DownloadItem* item = it->second; | 1248 DownloadItem* item = it->second; |
1261 if (item->id() == download_id) | 1249 if (item->id() == download_id) |
1262 return item; | 1250 return item; |
1263 } | 1251 } |
1264 return NULL; | 1252 return NULL; |
1265 } | 1253 } |
1266 | 1254 |
1255 void DownloadManager::GetInProgressDownloads( | |
1256 std::vector<DownloadItem*>* result) { | |
1257 DCHECK(result); | |
1258 | |
1259 for (DownloadMap::iterator it = active_downloads_.begin(); | |
1260 it != active_downloads_.end(); ++it) { | |
1261 result->push_back(it->second); | |
1262 } | |
1263 } | |
1264 | |
1267 DownloadItem* DownloadManager::GetActiveDownloadItem(int download_id) { | 1265 DownloadItem* DownloadManager::GetActiveDownloadItem(int download_id) { |
1268 DCHECK(ContainsKey(active_downloads_, download_id)); | 1266 DCHECK(ContainsKey(active_downloads_, download_id)); |
1269 DownloadItem* download = active_downloads_[download_id]; | 1267 DownloadItem* download = active_downloads_[download_id]; |
1270 DCHECK(download != NULL); | 1268 DCHECK(download != NULL); |
1271 return download; | 1269 return download; |
1272 } | 1270 } |
1273 | 1271 |
1274 // Confirm that everything in all maps is also in |downloads_|, and that | 1272 // Confirm that everything in all maps is also in |downloads_|, and that |
1275 // everything in |downloads_| is also in some other map. | 1273 // everything in |downloads_| is also in some other map. |
1276 void DownloadManager::AssertContainersConsistent() const { | 1274 void DownloadManager::AssertContainersConsistent() const { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1337 observed_download_manager_->RemoveObserver(this); | 1335 observed_download_manager_->RemoveObserver(this); |
1338 } | 1336 } |
1339 | 1337 |
1340 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { | 1338 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { |
1341 observing_download_manager_->NotifyModelChanged(); | 1339 observing_download_manager_->NotifyModelChanged(); |
1342 } | 1340 } |
1343 | 1341 |
1344 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { | 1342 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { |
1345 observed_download_manager_ = NULL; | 1343 observed_download_manager_ = NULL; |
1346 } | 1344 } |
OLD | NEW |