Add Downloader.getCounters method
PiperOrigin-RevId: 241636860
This commit is contained in:
parent
ee7bf4b0ee
commit
8480a4b44d
@ -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 {
|
|||||||
*/
|
*/
|
||||||
float getDownloadPercentage();
|
float getDownloadPercentage();
|
||||||
|
|
||||||
|
/** Returns a {@link CachingCounters} which holds download counters. */
|
||||||
|
CachingCounters getCounters();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the media.
|
* Removes the media.
|
||||||
*
|
*
|
||||||
|
@ -106,6 +106,11 @@ public final class ProgressiveDownloader implements Downloader {
|
|||||||
return cachingCounters.percentage;
|
return cachingCounters.percentage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CachingCounters getCounters() {
|
||||||
|
return cachingCounters;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
CacheUtil.remove(dataSpec, cache, cacheKeyFactory);
|
CacheUtil.remove(dataSpec, cache, cacheKeyFactory);
|
||||||
|
@ -158,6 +158,11 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M>> impleme
|
|||||||
return counters.percentage;
|
return counters.percentage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CachingCounters getCounters() {
|
||||||
|
return counters;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void remove() throws InterruptedException {
|
public final void remove() throws InterruptedException {
|
||||||
try {
|
try {
|
||||||
|
@ -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 {
|
|||||||
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user