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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java

Issue 2626903005: [Download Home] Add missing files to map (Closed)
Patch Set: Rebasing Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadManagerUi.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
index 3dbf0792818a471fa835499163e517c0d202a2bf..75fcea601c0dc46500fbf11a8b56b81fc01c424c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
@@ -26,6 +26,7 @@ import org.chromium.chrome.browser.widget.selection.SelectionDelegate;
import org.chromium.content_public.browser.DownloadState;
import java.util.List;
+import java.util.Set;
/** Bridges the user's download history and the UI used to display it. */
public class DownloadHistoryAdapter extends DateDividedAdapter implements DownloadUiObserver {
@@ -248,12 +249,21 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
DownloadHistoryItemWrapper existingWrapper = list.get(index);
boolean isUpdated = existingWrapper.replaceItem(item);
+ // Re-add the file mapping once it finishes downloading. This accounts for the backend
+ // creating DownloadItems with a null file path, then updating it after the download starts.
+ // Doing it once after completion instead of at every update is a compromise that prevents
+ // us from rapidly and repeatedly updating the map with the same info.
+ if (item.getDownloadInfo().state() == DownloadState.COMPLETE) {
+ mFilePathsToItemsMap.addItem(existingWrapper);
+ }
+
if (item.getDownloadInfo().state() == DownloadState.CANCELLED) {
// The old one is being removed.
filter(mFilter);
} else if (existingWrapper.isVisibleToUser(mFilter)) {
if (existingWrapper.getPosition() == TimedItem.INVALID_POSITION) {
filter(mFilter);
+ for (TestObserver observer : mObservers) observer.onDownloadItemUpdated(item);
} else if (isUpdated) {
notifyItemChanged(existingWrapper.getPosition());
for (TestObserver observer : mObservers) observer.onDownloadItemUpdated(item);
@@ -307,7 +317,7 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
* @param filePath The file path used to retrieve items.
* @return DownloadHistoryItemWrappers associated with filePath.
*/
- List<DownloadHistoryItemWrapper> getItemsForFilePath(String filePath) {
+ Set<DownloadHistoryItemWrapper> getItemsForFilePath(String filePath) {
return mFilePathsToItemsMap.getItemsForFilePath(filePath);
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadManagerUi.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698