| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.download; | 5 package org.chromium.chrome.browser.download; |
| 6 | 6 |
| 7 import org.chromium.base.annotations.CalledByNative; | 7 import org.chromium.base.annotations.CalledByNative; |
| 8 import org.chromium.components.offline_items_collection.ContentId; | 8 import org.chromium.components.offline_items_collection.ContentId; |
| 9 import org.chromium.components.offline_items_collection.OfflineItem.Progress; |
| 9 | 10 |
| 10 /** | 11 /** |
| 11 * A generic class representing a download item. The item can be either download
ed through the | 12 * A generic class representing a download item. The item can be either download
ed through the |
| 12 * Android DownloadManager, or through Chrome's network stack. | 13 * Android DownloadManager, or through Chrome's network stack. |
| 13 * | 14 * |
| 14 * This represents the native DownloadItem at a specific point in time -- the na
tive side | 15 * This represents the native DownloadItem at a specific point in time -- the na
tive side |
| 15 * DownloadManager must be queried for the correct status. | 16 * DownloadManager must be queried for the correct status. |
| 16 */ | 17 */ |
| 17 public class DownloadItem { | 18 public class DownloadItem { |
| 18 public static final int INDETERMINATE_DOWNLOAD_PERCENTAGE = -1; | |
| 19 static final long INVALID_DOWNLOAD_ID = -1L; | 19 static final long INVALID_DOWNLOAD_ID = -1L; |
| 20 | 20 |
| 21 private final ContentId mContentId = new ContentId(); | 21 private final ContentId mContentId = new ContentId(); |
| 22 private boolean mUseAndroidDownloadManager; | 22 private boolean mUseAndroidDownloadManager; |
| 23 private DownloadInfo mDownloadInfo; | 23 private DownloadInfo mDownloadInfo; |
| 24 private long mDownloadId = INVALID_DOWNLOAD_ID; | 24 private long mDownloadId = INVALID_DOWNLOAD_ID; |
| 25 private long mStartTime; | 25 private long mStartTime; |
| 26 private boolean mHasBeenExternallyRemoved; | 26 private boolean mHasBeenExternallyRemoved; |
| 27 | 27 |
| 28 public DownloadItem(boolean useAndroidDownloadManager, DownloadInfo info) { | 28 public DownloadItem(boolean useAndroidDownloadManager, DownloadInfo info) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 DownloadItem downloadItem = new DownloadItem(false, downloadInfo); | 136 DownloadItem downloadItem = new DownloadItem(false, downloadInfo); |
| 137 downloadItem.setStartTime(startTimestamp); | 137 downloadItem.setStartTime(startTimestamp); |
| 138 downloadItem.setHasBeenExternallyRemoved(hasBeenExternallyRemoved); | 138 downloadItem.setHasBeenExternallyRemoved(hasBeenExternallyRemoved); |
| 139 return downloadItem; | 139 return downloadItem; |
| 140 } | 140 } |
| 141 | 141 |
| 142 /** | 142 /** |
| 143 * @return Whether or not the download has an indeterminate percentage. | 143 * @return Whether or not the download has an indeterminate percentage. |
| 144 */ | 144 */ |
| 145 public boolean isIndeterminate() { | 145 public boolean isIndeterminate() { |
| 146 return getDownloadInfo().getPercentCompleted() == INDETERMINATE_DOWNLOAD
_PERCENTAGE; | 146 Progress progress = getDownloadInfo().getProgress(); |
| 147 return progress == null || progress.isIndeterminate(); |
| 147 } | 148 } |
| 148 } | 149 } |
| OLD | NEW |