-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactors downloading and fixes download start time. #360
Conversation
🚫 CI failed with log |
🚫 CI failed with log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some non-blocking feedback. Merge at will.
|
||
@interface PINURLSessionTaskObserver : NSObject | ||
{ | ||
id selfCopy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is a leftover?
|
||
@property (atomic, assign) CFTimeInterval startTime; | ||
@property (atomic, assign) CFTimeInterval endTime; | ||
@property (nonatomic, weak, readonly) NSURLSessionTask *task; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably remove this property unless it's used.
|
||
@interface PINRemoteImageTask (Subclassing) | ||
|
||
- (nonnull NSMutableDictionary *)l_callbackBlocks; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well go in with NS_ASSUME_NONNULL
here, and nullable PINResume *_Nullable *
or whatever it is for the resume handler.
Source/Classes/PINProgressiveImage.m
Outdated
NSAssert(_dataTask.PIN_startTime != 0, @"Start time needs to be set by now."); | ||
CFTimeInterval endTime = CACurrentMediaTime(); | ||
if (_dataTask.PIN_endTime != 0) { | ||
endTime = _dataTask.PIN_endTime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic here is a little bit hard to follow. Let's do something like CFTimeInterval endTime = (_dataTask.PIN_endTime ?: CACurrentMediaTime())
@@ -1062,26 +1018,14 @@ - (void)cancelTaskWithUUID:(nonnull NSUUID *)UUID storeResumeData:(BOOL)storeRes | |||
[strongSelf.canceledTasks addObject:UUID]; | |||
} | |||
|
|||
if ([taskToEvaluate cancelWithUUID:UUID manager:strongSelf]) { | |||
if ([taskToEvaluate cancelWithUUID:UUID resume:storeResumeData ? &resume : nil]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silly nit: this should be NULL
since its type is id *
🚫 CI failed with log |
🚫 CI failed with log |
Download start time was being incorrectly computed since the timer was started when the image was added to the queue instead of when the image was actually started downloading. When attempting to address this, I decided to do some much needed cleanup and refactoring by moving much of the download work to PINRemoteImageDownloadTask
1265ebe
to
8891791
Compare
🚫 CI failed with log |
Generated by 🚫 Danger |
Download start time was being incorrectly computed since the timer
was started when the image was added to the queue instead of when the
image was actually started downloading.
When attempting to address this, I decided to do some much needed cleanup
and refactoring by moving much of the download work to PINRemoteImageDownloadTask