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

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

Issue 10914158: Revert 155351 - Make DownloadManager::GetAllDownloads return all downloads regardless of state, per… (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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 DownloadItemImpl* item = it->second; 342 DownloadItemImpl* item = it->second;
343 // TODO(benjhayden): Don't check IsPersisted(). 343 // TODO(benjhayden): Don't check IsPersisted().
344 if (item->IsTemporary() && 344 if (item->IsTemporary() &&
345 item->IsPersisted() && 345 item->IsPersisted() &&
346 (dir_path.empty() || 346 (dir_path.empty() ||
347 item->GetTargetFilePath().DirName() == dir_path)) 347 item->GetTargetFilePath().DirName() == dir_path))
348 result->push_back(item); 348 result->push_back(item);
349 } 349 }
350 } 350 }
351 351
352 void DownloadManagerImpl::GetAllDownloads(
353 const FilePath& dir_path, DownloadVector* result) {
354 DCHECK(result);
355
356 for (DownloadMap::iterator it = downloads_.begin();
357 it != downloads_.end(); ++it) {
358 DownloadItemImpl* item = it->second;
359 // TODO(benjhayden): Don't check IsPersisted().
360 if (!item->IsTemporary() &&
361 item->IsPersisted() &&
362 (dir_path.empty() ||
363 item->GetTargetFilePath().DirName() == dir_path))
364 result->push_back(item);
365 }
366 }
367
352 void DownloadManagerImpl::SearchDownloads(const string16& query, 368 void DownloadManagerImpl::SearchDownloads(const string16& query,
353 DownloadVector* result) { 369 DownloadVector* result) {
354 string16 query_lower(base::i18n::ToLower(query)); 370 string16 query_lower(base::i18n::ToLower(query));
355 371
356 for (DownloadMap::iterator it = downloads_.begin(); 372 for (DownloadMap::iterator it = downloads_.begin();
357 it != downloads_.end(); ++it) { 373 it != downloads_.end(); ++it) {
358 DownloadItemImpl* download_item = it->second; 374 DownloadItemImpl* download_item = it->second;
359 // TODO(benjhayden): Don't check IsPersisted(). 375 // TODO(benjhayden): Don't check IsPersisted().
360 if (!download_item->IsTemporary() && 376 if (!download_item->IsTemporary() &&
361 download_item->IsPersisted() && 377 download_item->IsPersisted() &&
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 975
960 DownloadItem* DownloadManagerImpl::GetDownloadItem(int download_id) { 976 DownloadItem* DownloadManagerImpl::GetDownloadItem(int download_id) {
961 DownloadItem* download = GetDownload(download_id); 977 DownloadItem* download = GetDownload(download_id);
962 return (download && download->IsPersisted()) ? download : NULL; 978 return (download && download->IsPersisted()) ? download : NULL;
963 } 979 }
964 980
965 DownloadItem* DownloadManagerImpl::GetDownload(int download_id) { 981 DownloadItem* DownloadManagerImpl::GetDownload(int download_id) {
966 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL; 982 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL;
967 } 983 }
968 984
969 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) {
970 for (DownloadMap::iterator it = downloads_.begin();
971 it != downloads_.end(); ++it) {
972 downloads->push_back(it->second);
973 }
974 }
975
976 DownloadItem* DownloadManagerImpl::GetActiveDownloadItem(int download_id) { 985 DownloadItem* DownloadManagerImpl::GetActiveDownloadItem(int download_id) {
977 if (ContainsKey(active_downloads_, download_id)) 986 if (ContainsKey(active_downloads_, download_id))
978 return active_downloads_[download_id]; 987 return active_downloads_[download_id];
979 return NULL; 988 return NULL;
980 } 989 }
981 990
982 // Confirm that everything in all maps is also in |downloads_|, and that 991 // Confirm that everything in all maps is also in |downloads_|, and that
983 // everything in |downloads_| is also in some other map. 992 // everything in |downloads_| is also in some other map.
984 void DownloadManagerImpl::AssertContainersConsistent() const { 993 void DownloadManagerImpl::AssertContainersConsistent() const {
985 #if !defined(NDEBUG) 994 #if !defined(NDEBUG)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 void DownloadManagerImpl::DownloadRenamedToFinalName( 1090 void DownloadManagerImpl::DownloadRenamedToFinalName(
1082 DownloadItemImpl* download) { 1091 DownloadItemImpl* download) {
1083 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1092 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1084 // If the rename failed, we receive an OnDownloadInterrupted() call before we 1093 // If the rename failed, we receive an OnDownloadInterrupted() call before we
1085 // receive the DownloadRenamedToFinalName() call. 1094 // receive the DownloadRenamedToFinalName() call.
1086 if (delegate_) { 1095 if (delegate_) {
1087 delegate_->UpdatePathForItemInPersistentStore( 1096 delegate_->UpdatePathForItemInPersistentStore(
1088 download, download->GetFullPath()); 1097 download, download->GetFullPath());
1089 } 1098 }
1090 } 1099 }
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.h ('k') | content/public/browser/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698