Commit 8480a4b4 by eguven Committed by Oliver Woodman

Add Downloader.getCounters method

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