Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: content/browser/download/download_manager_impl.cc

Issue 10912183: Remove DownloadManager::GetDownloadItem in favor of GetDownload() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "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 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 if (item->IsInProgress()) 966 if (item->IsInProgress())
967 ++count; 967 ++count;
968 } 968 }
969 return count; 969 return count;
970 } 970 }
971 971
972 void DownloadManagerImpl::NotifyModelChanged() { 972 void DownloadManagerImpl::NotifyModelChanged() {
973 FOR_EACH_OBSERVER(Observer, observers_, ModelChanged(this)); 973 FOR_EACH_OBSERVER(Observer, observers_, ModelChanged(this));
974 } 974 }
975 975
976 DownloadItem* DownloadManagerImpl::GetDownloadItem(int download_id) {
977 DownloadItem* download = GetDownload(download_id);
978 return (download && download->IsPersisted()) ? download : NULL;
979 }
980
981 DownloadItem* DownloadManagerImpl::GetDownload(int download_id) { 976 DownloadItem* DownloadManagerImpl::GetDownload(int download_id) {
982 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL; 977 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL;
983 } 978 }
984 979
985 DownloadItem* DownloadManagerImpl::GetActiveDownloadItem(int download_id) {
986 if (ContainsKey(active_downloads_, download_id))
987 return active_downloads_[download_id];
988 return NULL;
989 }
990
991 // Confirm that everything in all maps is also in |downloads_|, and that 980 // Confirm that everything in all maps is also in |downloads_|, and that
992 // everything in |downloads_| is also in some other map. 981 // everything in |downloads_| is also in some other map.
993 void DownloadManagerImpl::AssertContainersConsistent() const { 982 void DownloadManagerImpl::AssertContainersConsistent() const {
994 #if !defined(NDEBUG) 983 #if !defined(NDEBUG)
995 // Turn everything into sets. 984 // Turn everything into sets.
996 const DownloadMap* input_maps[] = {&active_downloads_}; 985 const DownloadMap* input_maps[] = {&active_downloads_};
997 DownloadSet active_set; 986 DownloadSet active_set;
998 DownloadSet* all_sets[] = {&active_set}; 987 DownloadSet* all_sets[] = {&active_set};
999 DCHECK_EQ(ARRAYSIZE_UNSAFE(input_maps), ARRAYSIZE_UNSAFE(all_sets)); 988 DCHECK_EQ(ARRAYSIZE_UNSAFE(input_maps), ARRAYSIZE_UNSAFE(all_sets));
1000 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_maps); i++) { 989 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_maps); i++) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 void DownloadManagerImpl::DownloadRenamedToFinalName( 1079 void DownloadManagerImpl::DownloadRenamedToFinalName(
1091 DownloadItemImpl* download) { 1080 DownloadItemImpl* download) {
1092 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1081 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1093 // If the rename failed, we receive an OnDownloadInterrupted() call before we 1082 // If the rename failed, we receive an OnDownloadInterrupted() call before we
1094 // receive the DownloadRenamedToFinalName() call. 1083 // receive the DownloadRenamedToFinalName() call.
1095 if (delegate_) { 1084 if (delegate_) {
1096 delegate_->UpdatePathForItemInPersistentStore( 1085 delegate_->UpdatePathForItemInPersistentStore(
1097 download, download->GetFullPath()); 1086 download, download->GetFullPath());
1098 } 1087 }
1099 } 1088 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698