Rewrite DownloadManagerImpl::InProgressCount to actually look at the items' states
Sheriffs! If DownloadsApiTest is failing, please let me disable it with http://codereview.chromium.org/9694006 instead of rolling this back.
If DownloadsApiTest is passing, then I'll instead use that CL to disable console.debug in test.js.
BUG=101170
Review URL: http://codereview.chromium.org/9663011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126449 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc
index 2852aa0e..f6d16f7 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -1057,7 +1057,17 @@
}
int DownloadManagerImpl::InProgressCount() const {
- return static_cast<int>(in_progress_.size());
+ // Don't use in_progress_.count() because Cancel() leaves items in
+ // in_progress_ if they haven't made it into the persistent store yet.
+ // Need to actually look at each item's state.
+ int count = 0;
+ for (DownloadMap::const_iterator it = in_progress_.begin();
+ it != in_progress_.end(); ++it) {
+ DownloadItem* item = it->second;
+ if (item->IsInProgress())
+ ++count;
+ }
+ return count;
}
// Clears the last download path, used to initialize "save as" dialogs.