in imagepipeline/src/main/java/com/facebook/imagepipeline/producers/EncodedProbeProducer.java [110:151]
public void onNewResultImpl(@Nullable EncodedImage newResult, @Status int status) {
try {
if (FrescoSystrace.isTracing()) {
FrescoSystrace.beginSection("EncodedProbeProducer#onNewResultImpl");
}
// intermediate, null or uncacheable results are not cached, so we just forward them
// as well as the images with unknown format which could be html response from the server
if (isNotLast(status)
|| newResult == null
|| statusHasAnyFlag(status, DO_NOT_CACHE_ENCODED | IS_PARTIAL_RESULT)
|| newResult.getImageFormat() == ImageFormat.UNKNOWN) {
getConsumer().onNewResult(newResult, status);
return;
}
final ImageRequest imageRequest = mProducerContext.getImageRequest();
final CacheKey cacheKey =
mCacheKeyFactory.getEncodedCacheKey(imageRequest, mProducerContext.getCallerContext());
mEncodedMemoryCacheHistory.add(cacheKey);
if ("memory_encoded".equals(mProducerContext.getExtra(ProducerContext.ExtraKeys.ORIGIN))) {
if (!mDiskCacheHistory.contains(cacheKey)) {
final boolean isSmallRequest =
(imageRequest.getCacheChoice() == ImageRequest.CacheChoice.SMALL);
final BufferedDiskCache preferredCache =
isSmallRequest ? mSmallImageBufferedDiskCache : mDefaultBufferedDiskCache;
preferredCache.addKeyForAsyncProbing(cacheKey);
mDiskCacheHistory.add(cacheKey);
}
} else if ("disk".equals(mProducerContext.getExtra(ProducerContext.ExtraKeys.ORIGIN))) {
// image was fetched from disk cache, therefore it was probed in disk cache by default
mDiskCacheHistory.add(cacheKey);
}
getConsumer().onNewResult(newResult, status);
} finally {
if (FrescoSystrace.isTracing()) {
FrescoSystrace.endSection();
}
}
}