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

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

Issue 2768953002: Initial work to move downloads to ContentIds (Closed)
Patch Set: Rebase because of a conflict... with a single. import. :( Created 3 years, 9 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
Index: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadItem.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadItem.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadItem.java
index 7c98a936264607b5c3e4c7a041786519db25a3fd..f21ca94e1a41422c643534f45be137617380f681 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadItem.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadItem.java
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.download;
import org.chromium.base.annotations.CalledByNative;
+import org.chromium.components.offline_items_collection.ContentId;
/**
* A generic class representing a download item. The item can be either downloaded through the
@@ -17,6 +18,7 @@ public class DownloadItem {
public static final int INDETERMINATE_DOWNLOAD_PERCENTAGE = -1;
static final long INVALID_DOWNLOAD_ID = -1L;
+ private final ContentId mContentId = new ContentId();
private boolean mUseAndroidDownloadManager;
private DownloadInfo mDownloadInfo;
private long mDownloadId = INVALID_DOWNLOAD_ID;
@@ -26,6 +28,8 @@ public class DownloadItem {
public DownloadItem(boolean useAndroidDownloadManager, DownloadInfo info) {
mUseAndroidDownloadManager = useAndroidDownloadManager;
mDownloadInfo = info;
+ if (mDownloadInfo != null) mContentId.namespace = mDownloadInfo.getContentId().namespace;
+ mContentId.id = getId();
}
/**
@@ -35,6 +39,9 @@ public class DownloadItem {
*/
public void setSystemDownloadId(long downloadId) {
mDownloadId = downloadId;
+
+ // Update our ContentId in case it changed.
+ mContentId.id = getId();
}
/**
@@ -52,6 +59,14 @@ public class DownloadItem {
}
/**
+ * @return A {@link ContentId} that represents this downloaded item. The id will match
+ * {@link #getId()}.
+ */
+ public ContentId getContentId() {
+ return mContentId;
+ }
+
+ /**
* @return String ID that uniquely identifies the download.
*/
public String getId() {

Powered by Google App Engine
This is Rietveld 408576698