|
2 | 2 |
|
3 | 3 | import android.os.Build;
|
4 | 4 | import android.support.annotation.NonNull;
|
5 |
| -import android.support.v4.os.TraceCompat; |
6 | 5 | import android.support.v4.util.Pools;
|
7 | 6 | import android.util.Log;
|
8 | 7 | import com.bumptech.glide.GlideContext;
|
|
21 | 20 | import com.bumptech.glide.util.LogTime;
|
22 | 21 | import com.bumptech.glide.util.Synthetic;
|
23 | 22 | import com.bumptech.glide.util.pool.FactoryPools.Poolable;
|
| 23 | +import com.bumptech.glide.util.pool.GlideTrace; |
24 | 24 | import com.bumptech.glide.util.pool.StateVerifier;
|
25 | 25 | import java.util.ArrayList;
|
26 | 26 | import java.util.List;
|
@@ -63,6 +63,7 @@ class DecodeJob<R> implements DataFetcherGenerator.FetcherReadyCallback,
|
63 | 63 | private RunReason runReason;
|
64 | 64 | private long startFetchTime;
|
65 | 65 | private boolean onlyRetrieveFromCache;
|
| 66 | + private Object model; |
66 | 67 |
|
67 | 68 | private Thread currentThread;
|
68 | 69 | private Key currentSourceKey;
|
@@ -125,6 +126,7 @@ DecodeJob<R> init(
|
125 | 126 | this.callback = callback;
|
126 | 127 | this.order = order;
|
127 | 128 | this.runReason = RunReason.INITIALIZE;
|
| 129 | + this.model = model; |
128 | 130 | return this;
|
129 | 131 | }
|
130 | 132 |
|
@@ -188,6 +190,7 @@ private void releaseInternal() {
|
188 | 190 | currentFetcher = null;
|
189 | 191 | startFetchTime = 0L;
|
190 | 192 | isCancelled = false;
|
| 193 | + model = null; |
191 | 194 | throwables.clear();
|
192 | 195 | pool.release(this);
|
193 | 196 | }
|
@@ -218,7 +221,7 @@ public void run() {
|
218 | 221 | // This should be much more fine grained, but since Java's thread pool implementation silently
|
219 | 222 | // swallows all otherwise fatal exceptions, this will at least make it obvious to developers
|
220 | 223 | // that something is failing.
|
221 |
| - TraceCompat.beginSection("DecodeJob#run"); |
| 224 | + GlideTrace.beginSectionFormat("DecodeJob#run(model=%s)", model); |
222 | 225 | // Methods in the try statement can invalidate currentFetcher, so set a local variable here to
|
223 | 226 | // ensure that the fetcher is cleaned up either way.
|
224 | 227 | DataFetcher<?> localFetcher = currentFetcher;
|
@@ -254,7 +257,7 @@ public void run() {
|
254 | 257 | if (localFetcher != null) {
|
255 | 258 | localFetcher.cleanup();
|
256 | 259 | }
|
257 |
| - TraceCompat.endSection(); |
| 260 | + GlideTrace.endSection(); |
258 | 261 | }
|
259 | 262 | }
|
260 | 263 |
|
@@ -371,11 +374,11 @@ public void onDataFetcherReady(Key sourceKey, Object data, DataFetcher<?> fetche
|
371 | 374 | runReason = RunReason.DECODE_DATA;
|
372 | 375 | callback.reschedule(this);
|
373 | 376 | } else {
|
374 |
| - TraceCompat.beginSection("DecodeJob.decodeFromRetrievedData"); |
| 377 | + GlideTrace.beginSection("DecodeJob.decodeFromRetrievedData"); |
375 | 378 | try {
|
376 | 379 | decodeFromRetrievedData();
|
377 | 380 | } finally {
|
378 |
| - TraceCompat.endSection(); |
| 381 | + GlideTrace.endSection(); |
379 | 382 | }
|
380 | 383 | }
|
381 | 384 | }
|
@@ -654,13 +657,13 @@ <X> void init(Key key, ResourceEncoder<X> encoder, LockedResource<X> toEncode) {
|
654 | 657 | }
|
655 | 658 |
|
656 | 659 | void encode(DiskCacheProvider diskCacheProvider, Options options) {
|
657 |
| - TraceCompat.beginSection("DecodeJob.encode"); |
| 660 | + GlideTrace.beginSection("DecodeJob.encode"); |
658 | 661 | try {
|
659 | 662 | diskCacheProvider.getDiskCache().put(key,
|
660 | 663 | new DataCacheWriter<>(encoder, toEncode, options));
|
661 | 664 | } finally {
|
662 | 665 | toEncode.unlock();
|
663 |
| - TraceCompat.endSection(); |
| 666 | + GlideTrace.endSection(); |
664 | 667 | }
|
665 | 668 | }
|
666 | 669 |
|
|
0 commit comments