Pipeline systrace - add markers to MultiplexProducer
@@ -12,6 +12,7 @@ import com.facebook.common.internal.Preconditions;
import com.facebook.common.internal.Sets;
import com.facebook.common.internal.VisibleForTesting;
import com.facebook.imagepipeline.common.Priority;
+import com.facebook.imagepipeline.systrace.FrescoSystrace;
import java.io.Closeable;
import java.io.IOException;
import java.util.HashMap;
@@ -57,6 +58,8 @@ public abstract class MultiplexProducer<K, T extends Closeable> implements Produ
@Override
public void produceResults(Consumer<T> consumer, ProducerContext context) {
+ try {
+ FrescoSystrace.beginSection("MultiplexProducer#produceResults");
K key = getKey(context);
Multiplexer multiplexer;
boolean createdNewMultiplexer;
@@ -81,6 +84,9 @@ public abstract class MultiplexProducer<K, T extends Closeable> implements Produ
if (createdNewMultiplexer) {
multiplexer.startInputProducerIfHasAttachedConsumers();
}
+ } finally {
+ FrescoSystrace.endSection();
+ }
}
private synchronized Multiplexer getExistingMultiplexer(K key) {
@@ -496,22 +502,42 @@ public abstract class MultiplexProducer<K, T extends Closeable> implements Produ
private class ForwardingConsumer extends BaseConsumer<T> {
@Override
protected void onNewResultImpl(T newResult, @Status int status) {
+ try {
+ FrescoSystrace.beginSection("MultiplexProducer#onNewResult");
Multiplexer.this.onNextResult(this, newResult, status);
+ } finally {
+ FrescoSystrace.endSection();
+ }
}
@Override
protected void onFailureImpl(Throwable t) {
+ try {
+ FrescoSystrace.beginSection("MultiplexProducer#onFailure");
Multiplexer.this.onFailure(this, t);
+ } finally {
+ FrescoSystrace.endSection();
+ }
}
@Override
protected void onCancellationImpl() {
+ try {
+ FrescoSystrace.beginSection("MultiplexProducer#onCancellation");
Multiplexer.this.onCancelled(this);
+ } finally {
+ FrescoSystrace.endSection();
+ }
}
@Override
protected void onProgressUpdateImpl(float progress) {
+ try {
+ FrescoSystrace.beginSection("MultiplexProducer#onProgressUpdate");
Multiplexer.this.onProgressUpdate(this, progress);
+ } finally {
+ FrescoSystrace.endSection();
+ }
}
}
}
