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

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

Issue 10913015: Reland DownloadManager::GetAllDownloads actually does now (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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 326
327 // We'll have nothing more to report to the observers after this point. 327 // We'll have nothing more to report to the observers after this point.
328 observers_.Clear(); 328 observers_.Clear();
329 329
330 file_manager_ = NULL; 330 file_manager_ = NULL;
331 if (delegate_) 331 if (delegate_)
332 delegate_->Shutdown(); 332 delegate_->Shutdown();
333 delegate_ = NULL; 333 delegate_ = NULL;
334 } 334 }
335 335
336 void DownloadManagerImpl::GetTemporaryDownloads(
337 const FilePath& dir_path, DownloadVector* result) {
338 DCHECK(result);
339
340 for (DownloadMap::iterator it = downloads_.begin();
341 it != downloads_.end(); ++it) {
342 DownloadItemImpl* item = it->second;
343 // TODO(benjhayden): Don't check IsPersisted().
344 if (item->IsTemporary() &&
345 item->IsPersisted() &&
346 (dir_path.empty() ||
347 item->GetTargetFilePath().DirName() == dir_path))
348 result->push_back(item);
349 }
350 }
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
368 void DownloadManagerImpl::SearchDownloads(const string16& query, 336 void DownloadManagerImpl::SearchDownloads(const string16& query,
369 DownloadVector* result) { 337 DownloadVector* result) {
370 string16 query_lower(base::i18n::ToLower(query)); 338 string16 query_lower(base::i18n::ToLower(query));
371 339
372 for (DownloadMap::iterator it = downloads_.begin(); 340 for (DownloadMap::iterator it = downloads_.begin();
373 it != downloads_.end(); ++it) { 341 it != downloads_.end(); ++it) {
374 DownloadItemImpl* download_item = it->second; 342 DownloadItemImpl* download_item = it->second;
375 // TODO(benjhayden): Don't check IsPersisted(). 343 // TODO(benjhayden): Don't check IsPersisted().
376 if (!download_item->IsTemporary() && 344 if (!download_item->IsTemporary() &&
377 download_item->IsPersisted() && 345 download_item->IsPersisted() &&
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 943
976 DownloadItem* DownloadManagerImpl::GetDownloadItem(int download_id) { 944 DownloadItem* DownloadManagerImpl::GetDownloadItem(int download_id) {
977 DownloadItem* download = GetDownload(download_id); 945 DownloadItem* download = GetDownload(download_id);
978 return (download && download->IsPersisted()) ? download : NULL; 946 return (download && download->IsPersisted()) ? download : NULL;
979 } 947 }
980 948
981 DownloadItem* DownloadManagerImpl::GetDownload(int download_id) { 949 DownloadItem* DownloadManagerImpl::GetDownload(int download_id) {
982 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL; 950 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL;
983 } 951 }
984 952
953 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) {
954 for (DownloadMap::iterator it = downloads_.begin();
955 it != downloads_.end(); ++it) {
956 downloads->push_back(it->second);
957 }
958 }
959
985 DownloadItem* DownloadManagerImpl::GetActiveDownloadItem(int download_id) { 960 DownloadItem* DownloadManagerImpl::GetActiveDownloadItem(int download_id) {
986 if (ContainsKey(active_downloads_, download_id)) 961 if (ContainsKey(active_downloads_, download_id))
987 return active_downloads_[download_id]; 962 return active_downloads_[download_id];
988 return NULL; 963 return NULL;
989 } 964 }
990 965
991 // Confirm that everything in all maps is also in |downloads_|, and that 966 // Confirm that everything in all maps is also in |downloads_|, and that
992 // everything in |downloads_| is also in some other map. 967 // everything in |downloads_| is also in some other map.
993 void DownloadManagerImpl::AssertContainersConsistent() const { 968 void DownloadManagerImpl::AssertContainersConsistent() const {
994 #if !defined(NDEBUG) 969 #if !defined(NDEBUG)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 void DownloadManagerImpl::DownloadRenamedToFinalName( 1065 void DownloadManagerImpl::DownloadRenamedToFinalName(
1091 DownloadItemImpl* download) { 1066 DownloadItemImpl* download) {
1092 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1067 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1093 // If the rename failed, we receive an OnDownloadInterrupted() call before we 1068 // If the rename failed, we receive an OnDownloadInterrupted() call before we
1094 // receive the DownloadRenamedToFinalName() call. 1069 // receive the DownloadRenamedToFinalName() call.
1095 if (delegate_) { 1070 if (delegate_) {
1096 delegate_->UpdatePathForItemInPersistentStore( 1071 delegate_->UpdatePathForItemInPersistentStore(
1097 download, download->GetFullPath()); 1072 download, download->GetFullPath());
1098 } 1073 }
1099 } 1074 }
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.h ('k') | content/browser/download/drag_download_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698