diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java
index 91349e9284..12905f908c 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java
@@ -49,19 +49,18 @@ public interface Cache {
void onSpanRemoved(Cache cache, CacheSpan span);
/**
- * Called when an existing {@link CacheSpan} is accessed, causing it to be replaced. The new
+ * Called when an existing {@link CacheSpan} is touched, causing it to be replaced. The new
* {@link CacheSpan} is guaranteed to represent the same data as the one it replaces, however
- * {@link CacheSpan#file} and {@link CacheSpan#lastAccessTimestamp} may have changed.
- *
- * Note that for span replacement, {@link #onSpanAdded(Cache, CacheSpan)} and
- * {@link #onSpanRemoved(Cache, CacheSpan)} are not called in addition to this method.
+ * {@link CacheSpan#file} and {@link CacheSpan#lastTouchTimestamp} may have changed.
+ *
+ *
Note that for span replacement, {@link #onSpanAdded(Cache, CacheSpan)} and {@link
+ * #onSpanRemoved(Cache, CacheSpan)} are not called in addition to this method.
*
* @param cache The source of the event.
* @param oldSpan The old {@link CacheSpan}, which has been removed from the cache.
* @param newSpan The new {@link CacheSpan}, which has been added to the cache.
*/
void onSpanTouched(Cache cache, CacheSpan oldSpan, CacheSpan newSpan);
-
}
/**
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheEvictor.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheEvictor.java
index dbec4b78fc..6ebfe01df4 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheEvictor.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheEvictor.java
@@ -23,6 +23,13 @@ import com.google.android.exoplayer2.C;
*/
public interface CacheEvictor extends Cache.Listener {
+ /**
+ * Returns whether the evictor requires the {@link Cache} to touch {@link CacheSpan CacheSpans}
+ * when it accesses them. Implementations that do not use {@link CacheSpan#lastTouchTimestamp}
+ * should return {@code false}.
+ */
+ boolean requiresCacheSpanTouches();
+
/**
* Called when cache has been initialized.
*/
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheFileMetadata.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheFileMetadata.java
index 492b98a0de..7ac80325a5 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheFileMetadata.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheFileMetadata.java
@@ -19,10 +19,10 @@ package com.google.android.exoplayer2.upstream.cache;
/* package */ final class CacheFileMetadata {
public final long length;
- public final long lastAccessTimestamp;
+ public final long lastTouchTimestamp;
- public CacheFileMetadata(long length, long lastAccessTimestamp) {
+ public CacheFileMetadata(long length, long lastTouchTimestamp) {
this.length = length;
- this.lastAccessTimestamp = lastAccessTimestamp;
+ this.lastTouchTimestamp = lastTouchTimestamp;
}
}
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheFileMetadataIndex.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheFileMetadataIndex.java
index 084c02b11b..027172e090 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheFileMetadataIndex.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheFileMetadataIndex.java
@@ -36,17 +36,17 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private static final String COLUMN_NAME = "name";
private static final String COLUMN_LENGTH = "length";
- private static final String COLUMN_LAST_ACCESS_TIMESTAMP = "last_access_timestamp";
+ private static final String COLUMN_LAST_TOUCH_TIMESTAMP = "last_touch_timestamp";
private static final int COLUMN_INDEX_NAME = 0;
private static final int COLUMN_INDEX_LENGTH = 1;
- private static final int COLUMN_INDEX_LAST_ACCESS_TIMESTAMP = 2;
+ private static final int COLUMN_INDEX_LAST_TOUCH_TIMESTAMP = 2;
private static final String WHERE_NAME_EQUALS = COLUMN_INDEX_NAME + " = ?";
private static final String[] COLUMNS =
new String[] {
- COLUMN_NAME, COLUMN_LENGTH, COLUMN_LAST_ACCESS_TIMESTAMP,
+ COLUMN_NAME, COLUMN_LENGTH, COLUMN_LAST_TOUCH_TIMESTAMP,
};
private static final String TABLE_SCHEMA =
"("
@@ -54,7 +54,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
+ " TEXT PRIMARY KEY NOT NULL,"
+ COLUMN_LENGTH
+ " INTEGER NOT NULL,"
- + COLUMN_LAST_ACCESS_TIMESTAMP
+ + COLUMN_LAST_TOUCH_TIMESTAMP
+ " INTEGER NOT NULL)";
private final DatabaseProvider databaseProvider;
@@ -141,8 +141,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
while (cursor.moveToNext()) {
String name = cursor.getString(COLUMN_INDEX_NAME);
long length = cursor.getLong(COLUMN_INDEX_LENGTH);
- long lastAccessTimestamp = cursor.getLong(COLUMN_INDEX_LAST_ACCESS_TIMESTAMP);
- fileMetadata.put(name, new CacheFileMetadata(length, lastAccessTimestamp));
+ long lastTouchTimestamp = cursor.getLong(COLUMN_INDEX_LAST_TOUCH_TIMESTAMP);
+ fileMetadata.put(name, new CacheFileMetadata(length, lastTouchTimestamp));
}
return fileMetadata;
} catch (SQLException e) {
@@ -155,17 +155,17 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
*
* @param name The name of the file.
* @param length The file length.
- * @param lastAccessTimestamp The file last access timestamp.
+ * @param lastTouchTimestamp The file last touch timestamp.
* @throws DatabaseIOException If an error occurs setting the metadata.
*/
- public void set(String name, long length, long lastAccessTimestamp) throws DatabaseIOException {
+ public void set(String name, long length, long lastTouchTimestamp) throws DatabaseIOException {
Assertions.checkNotNull(tableName);
try {
SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(COLUMN_NAME, name);
values.put(COLUMN_LENGTH, length);
- values.put(COLUMN_LAST_ACCESS_TIMESTAMP, lastAccessTimestamp);
+ values.put(COLUMN_LAST_TOUCH_TIMESTAMP, lastTouchTimestamp);
writableDatabase.replaceOrThrow(tableName, /* nullColumnHack= */ null, values);
} catch (SQLException e) {
throw new DatabaseIOException(e);
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheSpan.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheSpan.java
index 7dbcd4a922..1e8cf1517d 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheSpan.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheSpan.java
@@ -45,13 +45,12 @@ public class CacheSpan implements Comparable {
* The file corresponding to this {@link CacheSpan}, or null if {@link #isCached} is false.
*/
public final @Nullable File file;
- /**
- * The last access timestamp, or {@link C#TIME_UNSET} if {@link #isCached} is false.
- */
- public final long lastAccessTimestamp;
+ /** The last touch timestamp, or {@link C#TIME_UNSET} if {@link #isCached} is false. */
+ public final long lastTouchTimestamp;
/**
- * Creates a hole CacheSpan which isn't cached, has no last access time and no file associated.
+ * Creates a hole CacheSpan which isn't cached, has no last touch timestamp and no file
+ * associated.
*
* @param key The cache key that uniquely identifies the original stream.
* @param position The position of the {@link CacheSpan} in the original stream.
@@ -69,18 +68,18 @@ public class CacheSpan implements Comparable {
* @param position The position of the {@link CacheSpan} in the original stream.
* @param length The length of the {@link CacheSpan}, or {@link C#LENGTH_UNSET} if this is an
* open-ended hole.
- * @param lastAccessTimestamp The last access timestamp, or {@link C#TIME_UNSET} if {@link
+ * @param lastTouchTimestamp The last touch timestamp, or {@link C#TIME_UNSET} if {@link
* #isCached} is false.
* @param file The file corresponding to this {@link CacheSpan}, or null if it's a hole.
*/
public CacheSpan(
- String key, long position, long length, long lastAccessTimestamp, @Nullable File file) {
+ String key, long position, long length, long lastTouchTimestamp, @Nullable File file) {
this.key = key;
this.position = position;
this.length = length;
this.isCached = file != null;
this.file = file;
- this.lastAccessTimestamp = lastAccessTimestamp;
+ this.lastTouchTimestamp = lastTouchTimestamp;
}
/**
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContent.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContent.java
index e244163bc8..7abb9b3896 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContent.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContent.java
@@ -141,30 +141,30 @@ import java.util.TreeSet;
}
/**
- * Sets the given span's last access timestamp. The passed span becomes invalid after this call.
+ * Sets the given span's last touch timestamp. The passed span becomes invalid after this call.
*
* @param cacheSpan Span to be copied and updated.
- * @param lastAccessTimestamp The new last access timestamp.
+ * @param lastTouchTimestamp The new last touch timestamp.
* @param updateFile Whether the span file should be renamed to have its timestamp match the new
- * last access time.
- * @return A span with the updated last access timestamp.
+ * last touch time.
+ * @return A span with the updated last touch timestamp.
*/
- public SimpleCacheSpan setLastAccessTimestamp(
- SimpleCacheSpan cacheSpan, long lastAccessTimestamp, boolean updateFile) {
+ public SimpleCacheSpan setLastTouchTimestamp(
+ SimpleCacheSpan cacheSpan, long lastTouchTimestamp, boolean updateFile) {
Assertions.checkState(cachedSpans.remove(cacheSpan));
File file = cacheSpan.file;
if (updateFile) {
File directory = file.getParentFile();
long position = cacheSpan.position;
- File newFile = SimpleCacheSpan.getCacheFile(directory, id, position, lastAccessTimestamp);
+ File newFile = SimpleCacheSpan.getCacheFile(directory, id, position, lastTouchTimestamp);
if (file.renameTo(newFile)) {
file = newFile;
} else {
- Log.w(TAG, "Failed to rename " + file + " to " + newFile + ".");
+ Log.w(TAG, "Failed to rename " + file + " to " + newFile);
}
}
SimpleCacheSpan newCacheSpan =
- cacheSpan.copyWithFileAndLastAccessTimestamp(file, lastAccessTimestamp);
+ cacheSpan.copyWithFileAndLastTouchTimestamp(file, lastTouchTimestamp);
cachedSpans.add(newCacheSpan);
return newCacheSpan;
}
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictor.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictor.java
index aa40c1d2fd..44a735f144 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictor.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictor.java
@@ -35,6 +35,11 @@ public final class LeastRecentlyUsedCacheEvictor implements CacheEvictor, Compar
this.leastRecentlyUsed = new TreeSet<>(this);
}
+ @Override
+ public boolean requiresCacheSpanTouches() {
+ return true;
+ }
+
@Override
public void onCacheInitialized() {
// Do nothing.
@@ -68,12 +73,12 @@ public final class LeastRecentlyUsedCacheEvictor implements CacheEvictor, Compar
@Override
public int compare(CacheSpan lhs, CacheSpan rhs) {
- long lastAccessTimestampDelta = lhs.lastAccessTimestamp - rhs.lastAccessTimestamp;
- if (lastAccessTimestampDelta == 0) {
+ long lastTouchTimestampDelta = lhs.lastTouchTimestamp - rhs.lastTouchTimestamp;
+ if (lastTouchTimestampDelta == 0) {
// Use the standard compareTo method as a tie-break.
return lhs.compareTo(rhs);
}
- return lhs.lastAccessTimestamp < rhs.lastAccessTimestamp ? -1 : 1;
+ return lhs.lastTouchTimestamp < rhs.lastTouchTimestamp ? -1 : 1;
}
private void evictCache(Cache cache, long requiredSpace) {
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/NoOpCacheEvictor.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/NoOpCacheEvictor.java
index b0c8c7e087..da89dc1cb3 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/NoOpCacheEvictor.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/NoOpCacheEvictor.java
@@ -24,6 +24,11 @@ package com.google.android.exoplayer2.upstream.cache;
*/
public final class NoOpCacheEvictor implements CacheEvictor {
+ @Override
+ public boolean requiresCacheSpanTouches() {
+ return false;
+ }
+
@Override
public void onCacheInitialized() {
// Do nothing.
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java
index 14f659855b..b31d3b66f3 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java
@@ -70,6 +70,7 @@ public final class SimpleCache implements Cache {
@Nullable private final CacheFileMetadataIndex fileIndex;
private final HashMap> listeners;
private final Random random;
+ private final boolean touchCacheSpans;
private long uid;
private long totalSpace;
@@ -279,6 +280,7 @@ public final class SimpleCache implements Cache {
this.fileIndex = fileIndex;
listeners = new HashMap<>();
random = new Random();
+ touchCacheSpans = evictor.requiresCacheSpanTouches();
uid = UID_UNSET;
// Start cache initialization.
@@ -408,23 +410,26 @@ public final class SimpleCache implements Cache {
// Read case.
if (span.isCached) {
+ if (!touchCacheSpans) {
+ return span;
+ }
String fileName = Assertions.checkNotNull(span.file).getName();
long length = span.length;
- long lastAccessTimestamp = System.currentTimeMillis();
+ long lastTouchTimestamp = System.currentTimeMillis();
boolean updateFile = false;
if (fileIndex != null) {
try {
- fileIndex.set(fileName, length, lastAccessTimestamp);
+ fileIndex.set(fileName, length, lastTouchTimestamp);
} catch (IOException e) {
- throw new CacheException(e);
+ Log.w(TAG, "Failed to update index with new touch timestamp.");
}
} else {
- // Updating the file itself to incorporate the new last access timestamp is much slower than
+ // Updating the file itself to incorporate the new last touch timestamp is much slower than
// updating the file index. Hence we only update the file if we don't have a file index.
updateFile = true;
}
SimpleCacheSpan newSpan =
- contentIndex.get(key).setLastAccessTimestamp(span, lastAccessTimestamp, updateFile);
+ contentIndex.get(key).setLastTouchTimestamp(span, lastTouchTimestamp, updateFile);
notifySpanTouched(span, newSpan);
return newSpan;
}
@@ -459,8 +464,8 @@ public final class SimpleCache implements Cache {
if (!fileDir.exists()) {
fileDir.mkdir();
}
- long lastAccessTimestamp = System.currentTimeMillis();
- return SimpleCacheSpan.getCacheFile(fileDir, cachedContent.id, position, lastAccessTimestamp);
+ long lastTouchTimestamp = System.currentTimeMillis();
+ return SimpleCacheSpan.getCacheFile(fileDir, cachedContent.id, position, lastTouchTimestamp);
}
@Override
@@ -488,7 +493,7 @@ public final class SimpleCache implements Cache {
if (fileIndex != null) {
String fileName = file.getName();
try {
- fileIndex.set(fileName, span.length, span.lastAccessTimestamp);
+ fileIndex.set(fileName, span.length, span.lastTouchTimestamp);
} catch (IOException e) {
throw new CacheException(e);
}
@@ -674,14 +679,14 @@ public final class SimpleCache implements Cache {
continue;
}
long length = C.LENGTH_UNSET;
- long lastAccessTimestamp = C.TIME_UNSET;
+ long lastTouchTimestamp = C.TIME_UNSET;
CacheFileMetadata metadata = fileMetadata != null ? fileMetadata.remove(fileName) : null;
if (metadata != null) {
length = metadata.length;
- lastAccessTimestamp = metadata.lastAccessTimestamp;
+ lastTouchTimestamp = metadata.lastTouchTimestamp;
}
SimpleCacheSpan span =
- SimpleCacheSpan.createCacheEntry(file, length, lastAccessTimestamp, contentIndex);
+ SimpleCacheSpan.createCacheEntry(file, length, lastTouchTimestamp, contentIndex);
if (span != null) {
addSpan(span);
} else {
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpan.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpan.java
index 7235830019..7d9f0c9ff1 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpan.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpan.java
@@ -96,7 +96,7 @@ import java.util.regex.Pattern;
*/
@Nullable
public static SimpleCacheSpan createCacheEntry(File file, long length, CachedContentIndex index) {
- return createCacheEntry(file, length, /* lastAccessTimestamp= */ C.TIME_UNSET, index);
+ return createCacheEntry(file, length, /* lastTouchTimestamp= */ C.TIME_UNSET, index);
}
/**
@@ -106,14 +106,14 @@ import java.util.regex.Pattern;
* @param length The length of the cache file in bytes, or {@link C#LENGTH_UNSET} to query the
* underlying file system. Querying the underlying file system can be expensive, so callers
* that already know the length of the file should pass it explicitly.
- * @param lastAccessTimestamp The last access timestamp, or {@link C#TIME_UNSET} to use the file
+ * @param lastTouchTimestamp The last touch timestamp, or {@link C#TIME_UNSET} to use the file
* timestamp.
* @return The span, or null if the file name is not correctly formatted, or if the id is not
* present in the content index, or if the length is 0.
*/
@Nullable
public static SimpleCacheSpan createCacheEntry(
- File file, long length, long lastAccessTimestamp, CachedContentIndex index) {
+ File file, long length, long lastTouchTimestamp, CachedContentIndex index) {
String name = file.getName();
if (!name.endsWith(SUFFIX)) {
file = upgradeFile(file, index);
@@ -142,10 +142,10 @@ import java.util.regex.Pattern;
}
long position = Long.parseLong(matcher.group(2));
- if (lastAccessTimestamp == C.TIME_UNSET) {
- lastAccessTimestamp = Long.parseLong(matcher.group(3));
+ if (lastTouchTimestamp == C.TIME_UNSET) {
+ lastTouchTimestamp = Long.parseLong(matcher.group(3));
}
- return new SimpleCacheSpan(key, position, length, lastAccessTimestamp, file);
+ return new SimpleCacheSpan(key, position, length, lastTouchTimestamp, file);
}
/**
@@ -187,26 +187,26 @@ import java.util.regex.Pattern;
* @param position The position of the {@link CacheSpan} in the original stream.
* @param length The length of the {@link CacheSpan}, or {@link C#LENGTH_UNSET} if this is an
* open-ended hole.
- * @param lastAccessTimestamp The last access timestamp, or {@link C#TIME_UNSET} if {@link
+ * @param lastTouchTimestamp The last touch timestamp, or {@link C#TIME_UNSET} if {@link
* #isCached} is false.
* @param file The file corresponding to this {@link CacheSpan}, or null if it's a hole.
*/
private SimpleCacheSpan(
- String key, long position, long length, long lastAccessTimestamp, @Nullable File file) {
- super(key, position, length, lastAccessTimestamp, file);
+ String key, long position, long length, long lastTouchTimestamp, @Nullable File file) {
+ super(key, position, length, lastTouchTimestamp, file);
}
/**
- * Returns a copy of this CacheSpan with a new file and last access timestamp.
+ * Returns a copy of this CacheSpan with a new file and last touch timestamp.
*
* @param file The new file.
- * @param lastAccessTimestamp The new last access time.
- * @return A copy with the new file and last access timestamp.
+ * @param lastTouchTimestamp The new last touch time.
+ * @return A copy with the new file and last touch timestamp.
* @throws IllegalStateException If called on a non-cached span (i.e. {@link #isCached} is false).
*/
- public SimpleCacheSpan copyWithFileAndLastAccessTimestamp(File file, long lastAccessTimestamp) {
+ public SimpleCacheSpan copyWithFileAndLastTouchTimestamp(File file, long lastTouchTimestamp) {
Assertions.checkState(isCached);
- return new SimpleCacheSpan(key, position, length, lastAccessTimestamp, file);
+ return new SimpleCacheSpan(key, position, length, lastTouchTimestamp, file);
}
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java
index bebcf0ec12..cee5703ff8 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java
@@ -108,7 +108,7 @@ public class CachedContentIndexTest {
cachedContent1.id,
/* offset= */ 10,
cacheFileLength,
- /* lastAccessTimestamp= */ 30);
+ /* lastTouchTimestamp= */ 30);
SimpleCacheSpan span = SimpleCacheSpan.createCacheEntry(cacheSpanFile, cacheFileLength, index);
assertThat(span).isNotNull();
cachedContent1.addSpan(span);
@@ -293,7 +293,7 @@ public class CachedContentIndexTest {
cachedContent.id,
/* offset= */ 10,
cacheFileLength,
- /* lastAccessTimestamp= */ 30);
+ /* lastTouchTimestamp= */ 30);
SimpleCacheSpan span = SimpleCacheSpan.createCacheEntry(cacheFile, cacheFileLength, index);
cachedContent.addSpan(span);
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTrackerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTrackerTest.java
index 5efdf36191..b00ee73f0f 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTrackerTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTrackerTest.java
@@ -134,8 +134,8 @@ public final class CachedRegionTrackerTest {
}
public static File createCacheSpanFile(
- File cacheDir, int id, long offset, int length, long lastAccessTimestamp) throws IOException {
- File cacheFile = SimpleCacheSpan.getCacheFile(cacheDir, id, offset, lastAccessTimestamp);
+ File cacheDir, int id, long offset, int length, long lastTouchTimestamp) throws IOException {
+ File cacheFile = SimpleCacheSpan.getCacheFile(cacheDir, id, offset, lastTouchTimestamp);
createTestFile(cacheFile, length);
return cacheFile;
}
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java
index 028937dc5a..39be9fbcd8 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java
@@ -38,9 +38,8 @@ import org.junit.runner.RunWith;
public class SimpleCacheSpanTest {
public static File createCacheSpanFile(
- File cacheDir, int id, long offset, long length, long lastAccessTimestamp)
- throws IOException {
- File cacheFile = SimpleCacheSpan.getCacheFile(cacheDir, id, offset, lastAccessTimestamp);
+ File cacheDir, int id, long offset, long length, long lastTouchTimestamp) throws IOException {
+ File cacheFile = SimpleCacheSpan.getCacheFile(cacheDir, id, offset, lastTouchTimestamp);
createTestFile(cacheFile, length);
return cacheFile;
}
@@ -117,7 +116,7 @@ public class SimpleCacheSpanTest {
SimpleCacheSpan cacheSpan = SimpleCacheSpan.createCacheEntry(file, file.length(), index);
if (cacheSpan != null) {
assertThat(cacheSpan.key).isEqualTo(key);
- cachedPositions.put(cacheSpan.position, cacheSpan.lastAccessTimestamp);
+ cachedPositions.put(cacheSpan.position, cacheSpan.lastTouchTimestamp);
}
}
@@ -140,12 +139,11 @@ public class SimpleCacheSpanTest {
return file;
}
- private void assertCacheSpan(String key, long offset, long lastAccessTimestamp)
+ private void assertCacheSpan(String key, long offset, long lastTouchTimestamp)
throws IOException {
int id = index.assignIdForKey(key);
long cacheFileLength = 1;
- File cacheFile =
- createCacheSpanFile(cacheDir, id, offset, cacheFileLength, lastAccessTimestamp);
+ File cacheFile = createCacheSpanFile(cacheDir, id, offset, cacheFileLength, lastTouchTimestamp);
SimpleCacheSpan cacheSpan = SimpleCacheSpan.createCacheEntry(cacheFile, cacheFileLength, index);
String message = cacheFile.toString();
assertWithMessage(message).that(cacheSpan).isNotNull();
@@ -155,14 +153,13 @@ public class SimpleCacheSpanTest {
assertWithMessage(message).that(cacheSpan.length).isEqualTo(1);
assertWithMessage(message).that(cacheSpan.isCached).isTrue();
assertWithMessage(message).that(cacheSpan.file).isEqualTo(cacheFile);
- assertWithMessage(message).that(cacheSpan.lastAccessTimestamp).isEqualTo(lastAccessTimestamp);
+ assertWithMessage(message).that(cacheSpan.lastTouchTimestamp).isEqualTo(lastTouchTimestamp);
}
- private void assertNullCacheSpan(File parent, String key, long offset,
- long lastAccessTimestamp) {
+ private void assertNullCacheSpan(File parent, String key, long offset, long lastTouchTimestamp) {
long cacheFileLength = 0;
- File cacheFile = SimpleCacheSpan.getCacheFile(parent, index.assignIdForKey(key), offset,
- lastAccessTimestamp);
+ File cacheFile =
+ SimpleCacheSpan.getCacheFile(parent, index.assignIdForKey(key), offset, lastTouchTimestamp);
CacheSpan cacheSpan = SimpleCacheSpan.createCacheEntry(cacheFile, cacheFileLength, index);
assertWithMessage(cacheFile.toString()).that(cacheSpan).isNull();
}