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

Unified Diff: content/browser/download/download_manager_impl.cc

Issue 2593183002: [downloads] Remove DownloadManager::RemoveAllDownloads. (Closed)
Patch Set: Fix SavePageBrowsertest Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_manager_impl.cc
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc
index 8131d2740b1bbc811762e9fd9e361eda65287c10..2ef6b930ecd4e6a846d2f3a007554614dba8f534 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -588,25 +588,10 @@ DownloadInterruptReason DownloadManagerImpl::BeginDownloadRequest(
return DOWNLOAD_INTERRUPT_REASON_NONE;
}
-namespace {
-
-bool EmptyFilter(const GURL& url) {
- return true;
-}
-
-bool RemoveDownloadByURLAndTime(
+int DownloadManagerImpl::RemoveDownloadsByURLAndTime(
const base::Callback<bool(const GURL&)>& url_filter,
- base::Time remove_begin,
- base::Time remove_end,
- const DownloadItemImpl* download_item) {
- return url_filter.Run(download_item->GetURL()) &&
- download_item->GetStartTime() >= remove_begin &&
- (remove_end.is_null() || download_item->GetStartTime() < remove_end);
-}
-
-} // namespace
-
-int DownloadManagerImpl::RemoveDownloads(const DownloadRemover& remover) {
+ base::Time remove_begin,
+ base::Time remove_end) {
int count = 0;
auto it = downloads_.begin();
while (it != downloads_.end()) {
@@ -616,7 +601,9 @@ int DownloadManagerImpl::RemoveDownloads(const DownloadRemover& remover) {
++it;
if (download->GetState() != DownloadItem::IN_PROGRESS &&
- remover.Run(download)) {
+ url_filter.Run(download->GetURL()) &&
+ download->GetStartTime() >= remove_begin &&
+ (remove_end.is_null() || download->GetStartTime() < remove_end)) {
download->Remove();
count++;
}
@@ -624,25 +611,6 @@ int DownloadManagerImpl::RemoveDownloads(const DownloadRemover& remover) {
return count;
}
-int DownloadManagerImpl::RemoveDownloadsByURLAndTime(
- const base::Callback<bool(const GURL&)>& url_filter,
- base::Time remove_begin,
- base::Time remove_end) {
- return RemoveDownloads(base::Bind(&RemoveDownloadByURLAndTime,
- url_filter,
- remove_begin, remove_end));
-}
-
-int DownloadManagerImpl::RemoveAllDownloads() {
- const base::Callback<bool(const GURL&)> empty_filter =
- base::Bind(&EmptyFilter);
- // The null times make the date range unbounded.
- int num_deleted = RemoveDownloadsByURLAndTime(
- empty_filter, base::Time(), base::Time());
- RecordClearAllSize(num_deleted);
- return num_deleted;
-}
-
void DownloadManagerImpl::DownloadUrl(
std::unique_ptr<DownloadUrlParameters> params) {
if (params->post_id() >= 0) {
« no previous file with comments | « content/browser/download/download_manager_impl.h ('k') | content/browser/download/download_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698