mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add start and update time fields to DownloadState
PiperOrigin-RevId: 225363788
This commit is contained in:
parent
36f2bead16
commit
383df3f0c3
1 changed files with 18 additions and 6 deletions
|
|
@ -508,15 +508,16 @@ public final class DownloadManager {
|
||||||
public final DownloadAction action;
|
public final DownloadAction action;
|
||||||
/** The state of the download. */
|
/** The state of the download. */
|
||||||
public final @State int state;
|
public final @State int state;
|
||||||
|
/** The estimated download percentage, or {@link C#PERCENTAGE_UNSET} if unavailable. */
|
||||||
/**
|
|
||||||
* The estimated download percentage, or {@link C#PERCENTAGE_UNSET} if no estimate is available.
|
|
||||||
*/
|
|
||||||
public final float downloadPercentage;
|
public final float downloadPercentage;
|
||||||
/** The total number of downloaded bytes. */
|
/** The total number of downloaded bytes. */
|
||||||
public final long downloadedBytes;
|
public final long downloadedBytes;
|
||||||
/** The total size of the media, or {@link C#LENGTH_UNSET} if unknown. */
|
/** The total size of the media, or {@link C#LENGTH_UNSET} if unknown. */
|
||||||
public final long totalBytes;
|
public final long totalBytes;
|
||||||
|
/** The first time when download entry is created. */
|
||||||
|
public final long startTimeMs;
|
||||||
|
/** The last update time. */
|
||||||
|
public final long updateTimeMs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If {@link #state} is {@link #STATE_FAILED} then this is the cause, otherwise {@link
|
* If {@link #state} is {@link #STATE_FAILED} then this is the cause, otherwise {@link
|
||||||
|
|
@ -530,7 +531,8 @@ public final class DownloadManager {
|
||||||
float downloadPercentage,
|
float downloadPercentage,
|
||||||
long downloadedBytes,
|
long downloadedBytes,
|
||||||
long totalBytes,
|
long totalBytes,
|
||||||
@FailureReason int failureReason) {
|
@FailureReason int failureReason,
|
||||||
|
long startTimeMs) {
|
||||||
Assertions.checkState(
|
Assertions.checkState(
|
||||||
failureReason == FAILURE_REASON_NONE ? state != STATE_FAILED : state == STATE_FAILED);
|
failureReason == FAILURE_REASON_NONE ? state != STATE_FAILED : state == STATE_FAILED);
|
||||||
this.id = action.id;
|
this.id = action.id;
|
||||||
|
|
@ -540,6 +542,8 @@ public final class DownloadManager {
|
||||||
this.downloadedBytes = downloadedBytes;
|
this.downloadedBytes = downloadedBytes;
|
||||||
this.totalBytes = totalBytes;
|
this.totalBytes = totalBytes;
|
||||||
this.failureReason = failureReason;
|
this.failureReason = failureReason;
|
||||||
|
this.startTimeMs = startTimeMs;
|
||||||
|
updateTimeMs = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -556,6 +560,7 @@ public final class DownloadManager {
|
||||||
private final DownloadManager downloadManager;
|
private final DownloadManager downloadManager;
|
||||||
private final DownloaderFactory downloaderFactory;
|
private final DownloaderFactory downloaderFactory;
|
||||||
private final int minRetryCount;
|
private final int minRetryCount;
|
||||||
|
private final long startTimeMs;
|
||||||
private final ArrayDeque<DownloadAction> actionQueue;
|
private final ArrayDeque<DownloadAction> actionQueue;
|
||||||
private DownloadAction action;
|
private DownloadAction action;
|
||||||
/** The current state of the download. */
|
/** The current state of the download. */
|
||||||
|
|
@ -580,6 +585,7 @@ public final class DownloadManager {
|
||||||
this.downloaderFactory = downloaderFactory;
|
this.downloaderFactory = downloaderFactory;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.minRetryCount = minRetryCount;
|
this.minRetryCount = minRetryCount;
|
||||||
|
this.startTimeMs = System.currentTimeMillis();
|
||||||
state = STATE_QUEUED;
|
state = STATE_QUEUED;
|
||||||
targetState = STATE_COMPLETED;
|
targetState = STATE_COMPLETED;
|
||||||
actionQueue = new ArrayDeque<>();
|
actionQueue = new ArrayDeque<>();
|
||||||
|
|
@ -614,7 +620,13 @@ public final class DownloadManager {
|
||||||
totalBytes = downloader.getTotalBytes();
|
totalBytes = downloader.getTotalBytes();
|
||||||
}
|
}
|
||||||
return new DownloadState(
|
return new DownloadState(
|
||||||
action, state, downloadPercentage, downloadedBytes, totalBytes, failureReason);
|
action,
|
||||||
|
state,
|
||||||
|
downloadPercentage,
|
||||||
|
downloadedBytes,
|
||||||
|
totalBytes,
|
||||||
|
failureReason,
|
||||||
|
startTimeMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns whether the download is finished. */
|
/** Returns whether the download is finished. */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue