Pipeline systrace - add markers to BitmapMemoryCacheProducer
@@ -15,6 +15,7 @@ import com.facebook.imagepipeline.cache.MemoryCache;
import com.facebook.imagepipeline.image.CloseableImage;
import com.facebook.imagepipeline.image.QualityInfo;
import com.facebook.imagepipeline.request.ImageRequest;
+import com.facebook.imagepipeline.systrace.FrescoSystrace;
/**
* Memory cache producer for the bitmap memory cache.
@@ -41,7 +42,8 @@ public class BitmapMemoryCacheProducer implements Producer<CloseableReference<Cl
public void produceResults(
final Consumer<CloseableReference<CloseableImage>> consumer,
final ProducerContext producerContext) {
-
+ try {
+ FrescoSystrace.beginSection("BitmapMemoryCacheProducer#produceResults");
final ProducerListener listener = producerContext.getListener();
final String requestId = producerContext.getId();
listener.onProducerStart(requestId, getProducerName());
@@ -70,8 +72,8 @@ public class BitmapMemoryCacheProducer implements Producer<CloseableReference<Cl
}
}
- if (producerContext.getLowestPermittedRequestLevel().getValue() >=
- ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE.getValue()) {
+ if (producerContext.getLowestPermittedRequestLevel().getValue()
+ >= ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE.getValue()) {
listener.onProducerFinishWithSuccess(
requestId,
getProducerName(),
@@ -84,7 +86,8 @@ public class BitmapMemoryCacheProducer implements Producer<CloseableReference<Cl
}
Consumer<CloseableReference<CloseableImage>> wrappedConsumer =
- wrapConsumer(consumer, cacheKey, producerContext.getImageRequest().isMemoryCacheEnabled());
+ wrapConsumer(
+ consumer, cacheKey, producerContext.getImageRequest().isMemoryCacheEnabled());
listener.onProducerFinishWithSuccess(
requestId,
getProducerName(),
@@ -92,6 +95,9 @@ public class BitmapMemoryCacheProducer implements Producer<CloseableReference<Cl
? ImmutableMap.of(EXTRA_CACHED_VALUE_FOUND, "false")
: null);
mInputProducer.produceResults(wrappedConsumer, producerContext);
+ } finally {
+ FrescoSystrace.endSection();
+ }
}
protected Consumer<CloseableReference<CloseableImage>> wrapConsumer(
@@ -103,6 +109,8 @@ public class BitmapMemoryCacheProducer implements Producer<CloseableReference<Cl
@Override
public void onNewResultImpl(
CloseableReference<CloseableImage> newResult, @Status int status) {
+ try {
+ FrescoSystrace.beginSection("BitmapMemoryCacheProducer#onNewResultImpl");
final boolean isLast = isLast(status);
// ignore invalid intermediate results and forward the null result if last
if (newResult == null) {
@@ -124,7 +132,8 @@ public class BitmapMemoryCacheProducer implements Producer<CloseableReference<Cl
try {
QualityInfo newInfo = newResult.get().getQualityInfo();
QualityInfo cachedInfo = currentCachedResult.get().getQualityInfo();
- if (cachedInfo.isOfFullQuality() || cachedInfo.getQuality() >= newInfo.getQuality()) {
+ if (cachedInfo.isOfFullQuality()
+ || cachedInfo.getQuality() >= newInfo.getQuality()) {
getConsumer().onNewResult(currentCachedResult, status);
return;
}
@@ -147,6 +156,9 @@ public class BitmapMemoryCacheProducer implements Producer<CloseableReference<Cl
} finally {
CloseableReference.closeSafely(newCachedResult);
}
+ } finally {
+ FrescoSystrace.endSection();
+ }
}
};
}
