Commit c1372299 by andrewlewis Committed by Oliver Woodman

Misc nit fixes for downloader

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=195358542
parent e6973226
...@@ -464,13 +464,13 @@ public final class DownloadManager { ...@@ -464,13 +464,13 @@ public final class DownloadManager {
}); });
} }
private void logd(String message) { private static void logd(String message) {
if (DEBUG) { if (DEBUG) {
Log.d(TAG, message); Log.d(TAG, message);
} }
} }
private void logd(String message, Task task) { private static void logd(String message, Task task) {
logd(message + ": " + task); logd(message + ": " + task);
} }
...@@ -710,7 +710,7 @@ public final class DownloadManager { ...@@ -710,7 +710,7 @@ public final class DownloadManager {
private void stop() { private void stop() {
if (changeStateAndNotify(STATE_STARTED, STATE_STARTED_STOPPING)) { if (changeStateAndNotify(STATE_STARTED, STATE_STARTED_STOPPING)) {
downloadManager.logd("Stopping", this); logd("Stopping", this);
thread.interrupt(); thread.interrupt();
} }
} }
...@@ -737,7 +737,7 @@ public final class DownloadManager { ...@@ -737,7 +737,7 @@ public final class DownloadManager {
@Override @Override
public void run() { public void run() {
downloadManager.logd("Task is started", this); logd("Task is started", this);
Throwable error = null; Throwable error = null;
try { try {
downloader = action.createDownloader(downloadManager.downloaderConstructorHelper); downloader = action.createDownloader(downloadManager.downloaderConstructorHelper);
...@@ -753,15 +753,14 @@ public final class DownloadManager { ...@@ -753,15 +753,14 @@ public final class DownloadManager {
} catch (IOException e) { } catch (IOException e) {
long downloadedBytes = downloader.getDownloadedBytes(); long downloadedBytes = downloader.getDownloadedBytes();
if (downloadedBytes != errorPosition) { if (downloadedBytes != errorPosition) {
downloadManager.logd( logd("Reset error count. downloadedBytes = " + downloadedBytes, this);
"Reset error count. downloadedBytes = " + downloadedBytes, this);
errorPosition = downloadedBytes; errorPosition = downloadedBytes;
errorCount = 0; errorCount = 0;
} }
if (currentState != STATE_STARTED || ++errorCount > minRetryCount) { if (currentState != STATE_STARTED || ++errorCount > minRetryCount) {
throw e; throw e;
} }
downloadManager.logd("Download error. Retry " + errorCount, this); logd("Download error. Retry " + errorCount, this);
Thread.sleep(getRetryDelayMillis(errorCount)); Thread.sleep(getRetryDelayMillis(errorCount));
} }
} }
......
...@@ -42,7 +42,7 @@ public final class ProgressiveDownloader implements Downloader { ...@@ -42,7 +42,7 @@ public final class ProgressiveDownloader implements Downloader {
* @param uri Uri of the data to be downloaded. * @param uri Uri of the data to be downloaded.
* @param customCacheKey A custom key that uniquely identifies the original stream. Used for cache * @param customCacheKey A custom key that uniquely identifies the original stream. Used for cache
* indexing. May be null. * indexing. May be null.
* @param constructorHelper a {@link DownloaderConstructorHelper} instance. * @param constructorHelper A {@link DownloaderConstructorHelper} instance.
*/ */
public ProgressiveDownloader( public ProgressiveDownloader(
Uri uri, String customCacheKey, DownloaderConstructorHelper constructorHelper) { Uri uri, String customCacheKey, DownloaderConstructorHelper constructorHelper) {
......
...@@ -75,7 +75,7 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M, K>, K> ...@@ -75,7 +75,7 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M, K>, K>
/** /**
* @param manifestUri The {@link Uri} of the manifest to be downloaded. * @param manifestUri The {@link Uri} of the manifest to be downloaded.
* @param constructorHelper a {@link DownloaderConstructorHelper} instance. * @param constructorHelper A {@link DownloaderConstructorHelper} instance.
* @param trackKeys Track keys to select when downloading. If empty, all tracks are downloaded. * @param trackKeys Track keys to select when downloading. If empty, all tracks are downloaded.
*/ */
public SegmentDownloader( public SegmentDownloader(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment