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

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

Issue 1684293002: Separate download cancel handling from download failure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | content/browser/android/download_controller_android_impl.cc » ('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/DownloadManagerService.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java
index dd110a83ca38df459e3ecbfa63c8cb995b71ae63..6babe919f531d7b4b4a8a2488d6c3e2a2c7daeab 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java
@@ -100,7 +100,8 @@ public class DownloadManagerService extends BroadcastReceiver implements
private enum DownloadStatus {
IN_PROGRESS,
COMPLETE,
- FAILED
+ FAILED,
+ CANCELLED
}
/**
@@ -275,6 +276,12 @@ public class DownloadManagerService extends BroadcastReceiver implements
scheduleUpdateIfNeeded();
}
+ @Override
+ public void onDownloadCancelled(final DownloadInfo downloadInfo) {
+ updateDownloadProgress(downloadInfo, DownloadStatus.CANCELLED);
+ scheduleUpdateIfNeeded();
+ }
+
/**
* Clear any pending notifications for incomplete downloads by reading them from shared prefs.
* When Clank is restarted it clears any old notifications for incomplete downloads.
@@ -514,7 +521,8 @@ public class DownloadManagerService extends BroadcastReceiver implements
*
* @return A map that maps all download info to their corresponding download IDs in the
* download manager and whether the download can be resolved. If a download fails,
- * its download ID is INVALID_DOWNLOAD_ID and the launching intent is null.
+ * its download ID is INVALID_DOWNLOAD_ID and the launching intent is null. If a
+ * download is cancelled, return an empty map so that no action needs to be taken.
*/
private Map<DownloadInfo, Pair<Long, Boolean>> updateAllNotifications() {
assert !ThreadUtils.runningOnUiThread();
@@ -553,6 +561,11 @@ public class DownloadManagerService extends BroadcastReceiver implements
case IN_PROGRESS:
mDownloadNotifier.notifyDownloadProgress(progress.mDownloadInfo,
progress.mStartTimeInMillis);
+ break;
+ case CANCELLED:
+ removeProgressNotificationForDownload(
+ progress.mDownloadInfo.getDownloadId());
+ break;
}
}
}
« no previous file with comments | « no previous file | content/browser/android/download_controller_android_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698