Commit 8480a4b4 by eguven Committed by Oliver Woodman

Add Downloader.getCounters method

PiperOrigin-RevId: 241636860
parent ee7bf4b0
......@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.offline;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.upstream.cache.CacheUtil.CachingCounters;
import java.io.IOException;
/**
......@@ -47,6 +48,9 @@ public interface Downloader {
*/
float getDownloadPercentage();
/** Returns a {@link CachingCounters} which holds download counters. */
CachingCounters getCounters();
/**
* Removes the media.
*
......
......@@ -107,6 +107,11 @@ public final class ProgressiveDownloader implements Downloader {
}
@Override
public CachingCounters getCounters() {
return cachingCounters;
}
@Override
public void remove() {
CacheUtil.remove(dataSpec, cache, cacheKeyFactory);
}
......
......@@ -159,6 +159,11 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M>> impleme
}
@Override
public CachingCounters getCounters() {
return counters;
}
@Override
public final void remove() throws InterruptedException {
try {
M manifest = getManifest(offlineDataSource, manifestDataSpec);
......
......@@ -28,6 +28,7 @@ import com.google.android.exoplayer2.testutil.DummyMainThread.TestRunnable;
import com.google.android.exoplayer2.testutil.RobolectricUtil;
import com.google.android.exoplayer2.testutil.TestDownloadManagerListener;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.upstream.cache.CacheUtil.CachingCounters;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -747,6 +748,11 @@ public class DownloadManagerTest {
return C.PERCENTAGE_UNSET;
}
@Override
public CachingCounters getCounters() {
return null;
}
private void assertDoesNotStart() throws InterruptedException {
Thread.sleep(ASSERT_FALSE_TIME);
assertThat(started.getCount()).isEqualTo(1);
......
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