Skip to content
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

Merged
merged 9 commits into from
May 23, 2017

Conversation

garrettmoon
Copy link
Collaborator

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

@ghost
Copy link

ghost commented May 23, 2017

🚫 CI failed with log

@ghost
Copy link

ghost commented May 23, 2017

🚫 CI failed with log

Copy link
Contributor

@Adlai-Holler Adlai-Holler left a 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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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.

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;
Copy link
Contributor

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]) {
Copy link
Contributor

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 *

@ghost
Copy link

ghost commented May 23, 2017

🚫 CI failed with log

@ghost
Copy link

ghost commented May 23, 2017

🚫 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
@garrettmoon garrettmoon force-pushed the refactorDownloadFixTiming branch from 1265ebe to 8891791 Compare May 23, 2017 23:05
@ghost
Copy link

ghost commented May 23, 2017

🚫 CI failed with log

@ghost
Copy link

ghost commented May 23, 2017

1 Warning
⚠️ This is a big PR, please consider splitting it up to ease code review.

Generated by 🚫 Danger

@garrettmoon garrettmoon merged commit 3781e4b into master May 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants