mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Merge pull request #7210 from nebyan:CacheKeyFactoryNotUsed
PiperOrigin-RevId: 307045655
This commit is contained in:
parent
aea9f8e550
commit
ad36f64965
3 changed files with 12 additions and 26 deletions
|
|
@ -109,7 +109,6 @@ public final class CacheUtil {
|
||||||
*
|
*
|
||||||
* @param dataSpec Defines the data to be cached.
|
* @param dataSpec Defines the data to be cached.
|
||||||
* @param cache A {@link Cache} to store the data.
|
* @param cache A {@link Cache} to store the data.
|
||||||
* @param cacheKeyFactory An optional factory for cache keys.
|
|
||||||
* @param upstream A {@link DataSource} for reading data not in the cache.
|
* @param upstream A {@link DataSource} for reading data not in the cache.
|
||||||
* @param progressListener A listener to receive progress updates, or {@code null}.
|
* @param progressListener A listener to receive progress updates, or {@code null}.
|
||||||
* @param isCanceled An optional flag that will interrupt caching if set to true.
|
* @param isCanceled An optional flag that will interrupt caching if set to true.
|
||||||
|
|
@ -120,7 +119,6 @@ public final class CacheUtil {
|
||||||
public static void cache(
|
public static void cache(
|
||||||
DataSpec dataSpec,
|
DataSpec dataSpec,
|
||||||
Cache cache,
|
Cache cache,
|
||||||
@Nullable CacheKeyFactory cacheKeyFactory,
|
|
||||||
DataSource upstream,
|
DataSource upstream,
|
||||||
@Nullable ProgressListener progressListener,
|
@Nullable ProgressListener progressListener,
|
||||||
@Nullable AtomicBoolean isCanceled)
|
@Nullable AtomicBoolean isCanceled)
|
||||||
|
|
@ -128,7 +126,7 @@ public final class CacheUtil {
|
||||||
cache(
|
cache(
|
||||||
dataSpec,
|
dataSpec,
|
||||||
cache,
|
cache,
|
||||||
cacheKeyFactory,
|
/* cacheKeyFactory= */ null,
|
||||||
new CacheDataSource(cache, upstream),
|
new CacheDataSource(cache, upstream),
|
||||||
new byte[DEFAULT_BUFFER_SIZE_BYTES],
|
new byte[DEFAULT_BUFFER_SIZE_BYTES],
|
||||||
/* priorityTaskManager= */ null,
|
/* priorityTaskManager= */ null,
|
||||||
|
|
@ -139,14 +137,14 @@ public final class CacheUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Caches the data defined by {@code dataSpec} while skipping already cached data. Caching stops
|
* Caches the data defined by {@code dataSpec}, skipping already cached data. Caching stops early
|
||||||
* early if end of input is reached and {@code enableEOFException} is false.
|
* if end of input is reached and {@code enableEOFException} is false.
|
||||||
*
|
*
|
||||||
* <p>If a {@link PriorityTaskManager} is given, it's used to pause and resume caching depending
|
* <p>If a {@link PriorityTaskManager} is provided, it's used to pause and resume caching
|
||||||
* on {@code priority} and the priority of other tasks registered to the PriorityTaskManager.
|
* depending on {@code priority} and the priority of other tasks registered to the
|
||||||
* Please note that it's the responsibility of the calling code to call {@link
|
* PriorityTaskManager. Please note that it's the responsibility of the calling code to call
|
||||||
* PriorityTaskManager#add} to register with the manager before calling this method, and to call
|
* {@link PriorityTaskManager#add} to register with the manager before calling this method, and to
|
||||||
* {@link PriorityTaskManager#remove} afterwards to unregister.
|
* call {@link PriorityTaskManager#remove} afterwards to unregister.
|
||||||
*
|
*
|
||||||
* <p>This method may be slow and shouldn't normally be called on the main thread.
|
* <p>This method may be slow and shouldn't normally be called on the main thread.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -365,7 +365,6 @@ public final class CacheDataSourceTest {
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(
|
||||||
unboundedDataSpec,
|
unboundedDataSpec,
|
||||||
cache,
|
cache,
|
||||||
/* cacheKeyFactory= */ null,
|
|
||||||
upstream2,
|
upstream2,
|
||||||
/* progressListener= */ null,
|
/* progressListener= */ null,
|
||||||
/* isCanceled= */ null);
|
/* isCanceled= */ null);
|
||||||
|
|
@ -414,7 +413,6 @@ public final class CacheDataSourceTest {
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(
|
||||||
unboundedDataSpec,
|
unboundedDataSpec,
|
||||||
cache,
|
cache,
|
||||||
/* cacheKeyFactory= */ null,
|
|
||||||
upstream2,
|
upstream2,
|
||||||
/* progressListener= */ null,
|
/* progressListener= */ null,
|
||||||
/* isCanceled= */ null);
|
/* isCanceled= */ null);
|
||||||
|
|
@ -438,7 +436,6 @@ public final class CacheDataSourceTest {
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(
|
||||||
dataSpec,
|
dataSpec,
|
||||||
cache,
|
cache,
|
||||||
/* cacheKeyFactory= */ null,
|
|
||||||
upstream,
|
upstream,
|
||||||
/* progressListener= */ null,
|
/* progressListener= */ null,
|
||||||
/* isCanceled= */ null);
|
/* isCanceled= */ null);
|
||||||
|
|
@ -474,7 +471,6 @@ public final class CacheDataSourceTest {
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(
|
||||||
dataSpec,
|
dataSpec,
|
||||||
cache,
|
cache,
|
||||||
/* cacheKeyFactory= */ null,
|
|
||||||
upstream,
|
upstream,
|
||||||
/* progressListener= */ null,
|
/* progressListener= */ null,
|
||||||
/* isCanceled= */ null);
|
/* isCanceled= */ null);
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,6 @@ public final class CacheUtilTest {
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(
|
||||||
new DataSpec(Uri.parse("test_data")),
|
new DataSpec(Uri.parse("test_data")),
|
||||||
cache,
|
cache,
|
||||||
/* cacheKeyFactory= */ null,
|
|
||||||
dataSource,
|
dataSource,
|
||||||
counters,
|
counters,
|
||||||
/* isCanceled= */ null);
|
/* isCanceled= */ null);
|
||||||
|
|
@ -224,8 +223,7 @@ public final class CacheUtilTest {
|
||||||
Uri testUri = Uri.parse("test_data");
|
Uri testUri = Uri.parse("test_data");
|
||||||
DataSpec dataSpec = new DataSpec(testUri, 10, 20, null);
|
DataSpec dataSpec = new DataSpec(testUri, 10, 20, null);
|
||||||
CachingCounters counters = new CachingCounters();
|
CachingCounters counters = new CachingCounters();
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(dataSpec, cache, dataSource, counters, /* isCanceled= */ null);
|
||||||
dataSpec, cache, /* cacheKeyFactory= */ null, dataSource, counters, /* isCanceled= */ null);
|
|
||||||
|
|
||||||
counters.assertValues(0, 20, 20);
|
counters.assertValues(0, 20, 20);
|
||||||
counters.reset();
|
counters.reset();
|
||||||
|
|
@ -233,7 +231,6 @@ public final class CacheUtilTest {
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(
|
||||||
new DataSpec(testUri),
|
new DataSpec(testUri),
|
||||||
cache,
|
cache,
|
||||||
/* cacheKeyFactory= */ null,
|
|
||||||
dataSource,
|
dataSource,
|
||||||
counters,
|
counters,
|
||||||
/* isCanceled= */ null);
|
/* isCanceled= */ null);
|
||||||
|
|
@ -251,8 +248,7 @@ public final class CacheUtilTest {
|
||||||
|
|
||||||
DataSpec dataSpec = new DataSpec(Uri.parse("test_data"));
|
DataSpec dataSpec = new DataSpec(Uri.parse("test_data"));
|
||||||
CachingCounters counters = new CachingCounters();
|
CachingCounters counters = new CachingCounters();
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(dataSpec, cache, dataSource, counters, /* isCanceled= */ null);
|
||||||
dataSpec, cache, /* cacheKeyFactory= */ null, dataSource, counters, /* isCanceled= */ null);
|
|
||||||
|
|
||||||
counters.assertValues(0, 100, 100);
|
counters.assertValues(0, 100, 100);
|
||||||
assertCachedData(cache, fakeDataSet);
|
assertCachedData(cache, fakeDataSet);
|
||||||
|
|
@ -268,8 +264,7 @@ public final class CacheUtilTest {
|
||||||
Uri testUri = Uri.parse("test_data");
|
Uri testUri = Uri.parse("test_data");
|
||||||
DataSpec dataSpec = new DataSpec(testUri, 10, 20, null);
|
DataSpec dataSpec = new DataSpec(testUri, 10, 20, null);
|
||||||
CachingCounters counters = new CachingCounters();
|
CachingCounters counters = new CachingCounters();
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(dataSpec, cache, dataSource, counters, /* isCanceled= */ null);
|
||||||
dataSpec, cache, /* cacheKeyFactory= */ null, dataSource, counters, /* isCanceled= */ null);
|
|
||||||
|
|
||||||
counters.assertValues(0, 20, 20);
|
counters.assertValues(0, 20, 20);
|
||||||
counters.reset();
|
counters.reset();
|
||||||
|
|
@ -277,7 +272,6 @@ public final class CacheUtilTest {
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(
|
||||||
new DataSpec(testUri),
|
new DataSpec(testUri),
|
||||||
cache,
|
cache,
|
||||||
/* cacheKeyFactory= */ null,
|
|
||||||
dataSource,
|
dataSource,
|
||||||
counters,
|
counters,
|
||||||
/* isCanceled= */ null);
|
/* isCanceled= */ null);
|
||||||
|
|
@ -294,8 +288,7 @@ public final class CacheUtilTest {
|
||||||
Uri testUri = Uri.parse("test_data");
|
Uri testUri = Uri.parse("test_data");
|
||||||
DataSpec dataSpec = new DataSpec(testUri, 0, 1000, null);
|
DataSpec dataSpec = new DataSpec(testUri, 0, 1000, null);
|
||||||
CachingCounters counters = new CachingCounters();
|
CachingCounters counters = new CachingCounters();
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(dataSpec, cache, dataSource, counters, /* isCanceled= */ null);
|
||||||
dataSpec, cache, /* cacheKeyFactory= */ null, dataSource, counters, /* isCanceled= */ null);
|
|
||||||
|
|
||||||
counters.assertValues(0, 100, 1000);
|
counters.assertValues(0, 100, 1000);
|
||||||
assertCachedData(cache, fakeDataSet);
|
assertCachedData(cache, fakeDataSet);
|
||||||
|
|
@ -344,7 +337,6 @@ public final class CacheUtilTest {
|
||||||
CacheUtil.cache(
|
CacheUtil.cache(
|
||||||
new DataSpec(Uri.parse("test_data")),
|
new DataSpec(Uri.parse("test_data")),
|
||||||
cache,
|
cache,
|
||||||
/* cacheKeyFactory= */ null,
|
|
||||||
dataSource,
|
dataSource,
|
||||||
counters,
|
counters,
|
||||||
/* isCanceled= */ null);
|
/* isCanceled= */ null);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue