From 8ebe5c250a7b34e5653869b22ea846867a891d3f Mon Sep 17 00:00:00 2001 From: Garrett Moon Date: Wed, 13 Sep 2017 17:57:40 -0700 Subject: [PATCH] Add code to temporarily report metrics --- Source/Details/ASPINRemoteImageDownloader.h | 11 +++++++++++ Source/Details/ASPINRemoteImageDownloader.m | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/Source/Details/ASPINRemoteImageDownloader.h b/Source/Details/ASPINRemoteImageDownloader.h index 179104901..400d31305 100644 --- a/Source/Details/ASPINRemoteImageDownloader.h +++ b/Source/Details/ASPINRemoteImageDownloader.h @@ -23,6 +23,10 @@ NS_ASSUME_NONNULL_BEGIN +@class PINRemoteImageManagerResult; + +typedef void (^ASPINRemoteImageResultProvider)(PINRemoteImageManagerResult *result); + @class PINRemoteImageManager; @interface ASPINRemoteImageDownloader : NSObject @@ -58,6 +62,13 @@ NS_ASSUME_NONNULL_BEGIN */ - (PINRemoteImageManager *)sharedPINRemoteImageManager; +/** + * Allows you to view results of any download requests + * + * This is likely temporary. + */ +@property (atomic, strong, nullable) ASPINRemoteImageResultProvider resultProvider; + @end NS_ASSUME_NONNULL_END diff --git a/Source/Details/ASPINRemoteImageDownloader.m b/Source/Details/ASPINRemoteImageDownloader.m index 601d00945..1a6b4578f 100644 --- a/Source/Details/ASPINRemoteImageDownloader.m +++ b/Source/Details/ASPINRemoteImageDownloader.m @@ -276,6 +276,10 @@ - (nullable id)downloadImageWithURLs:(NSArray *)URLs }; PINRemoteImageManagerImageCompletion imageCompletion = ^(PINRemoteImageManagerResult * _Nonnull result) { + if (self.resultProvider) { + self.resultProvider(result); + } + /// If we're targeting the main queue and we're on the main thread, complete immediately. if (ASDisplayNodeThreadIsMain() && callbackQueue == dispatch_get_main_queue()) { #if PIN_ANIMATED_AVAILABLE