mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
When CacheDataSource ignores cache, report to QoE.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=188902403
This commit is contained in:
parent
e565a46a7d
commit
8d6832e8b3
1 changed files with 24 additions and 0 deletions
|
|
@ -77,6 +77,17 @@ public final class CacheDataSource implements DataSource {
|
||||||
*/
|
*/
|
||||||
public static final int FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS = 1 << 2;
|
public static final int FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS = 1 << 2;
|
||||||
|
|
||||||
|
/** Reasons the cache may be ignored. */
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@IntDef({CACHE_IGNORED_REASON_ERROR, CACHE_IGNORED_REASON_UNSET_LENGTH})
|
||||||
|
public @interface CacheIgnoredReason {}
|
||||||
|
|
||||||
|
/** Cache ignored due to a cache related error */
|
||||||
|
public static final int CACHE_IGNORED_REASON_ERROR = 0;
|
||||||
|
|
||||||
|
/** Cache ignored due to a request with an unset length */
|
||||||
|
public static final int CACHE_IGNORED_REASON_UNSET_LENGTH = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener of {@link CacheDataSource} events.
|
* Listener of {@link CacheDataSource} events.
|
||||||
*/
|
*/
|
||||||
|
|
@ -90,6 +101,12 @@ public final class CacheDataSource implements DataSource {
|
||||||
*/
|
*/
|
||||||
void onCachedBytesRead(long cacheSizeBytes, long cachedBytesRead);
|
void onCachedBytesRead(long cacheSizeBytes, long cachedBytesRead);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the current request ignores cache.
|
||||||
|
*
|
||||||
|
* @param reason Reason cache is bypassed.
|
||||||
|
*/
|
||||||
|
void onCacheIgnored(@CacheIgnoredReason int reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Minimum number of bytes to read before checking cache for availability. */
|
/** Minimum number of bytes to read before checking cache for availability. */
|
||||||
|
|
@ -294,6 +311,13 @@ public final class CacheDataSource implements DataSource {
|
||||||
CacheSpan nextSpan;
|
CacheSpan nextSpan;
|
||||||
if (currentRequestIgnoresCache) {
|
if (currentRequestIgnoresCache) {
|
||||||
nextSpan = null;
|
nextSpan = null;
|
||||||
|
if (eventListener != null) {
|
||||||
|
int reason =
|
||||||
|
ignoreCacheOnError && seenCacheError
|
||||||
|
? CACHE_IGNORED_REASON_ERROR
|
||||||
|
: CACHE_IGNORED_REASON_UNSET_LENGTH;
|
||||||
|
eventListener.onCacheIgnored(reason);
|
||||||
|
}
|
||||||
} else if (blockOnCache) {
|
} else if (blockOnCache) {
|
||||||
try {
|
try {
|
||||||
nextSpan = cache.startReadWrite(key, readPosition);
|
nextSpan = cache.startReadWrite(key, readPosition);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue