|
|
@ -33,12 +33,16 @@ class GiphyAssetSegment {
|
|
|
|
AssertIsOnMainThread()
|
|
|
|
AssertIsOnMainThread()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This state is accessed off the main thread.
|
|
|
|
// This state is accessed off the main thread.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// * During downloads it will be accessed on the task delegate queue.
|
|
|
|
// * During downloads it will be accessed on the task delegate queue.
|
|
|
|
// * After downloads it will be accessed on a worker queue.
|
|
|
|
// * After downloads it will be accessed on a worker queue.
|
|
|
|
private var segmentData = Data()
|
|
|
|
private var segmentData = Data()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This state should only be accessed on the main thread.
|
|
|
|
|
|
|
|
public weak var task: URLSessionDataTask?
|
|
|
|
|
|
|
|
|
|
|
|
init(index: UInt,
|
|
|
|
init(index: UInt,
|
|
|
|
segmentStart: UInt,
|
|
|
|
segmentStart: UInt,
|
|
|
|
segmentLength: UInt,
|
|
|
|
segmentLength: UInt,
|
|
|
@ -131,6 +135,7 @@ enum GiphyAssetRequestState: UInt {
|
|
|
|
createSegments()
|
|
|
|
createSegments()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public weak var contentLengthTask: URLSessionDataTask?
|
|
|
|
|
|
|
|
|
|
|
|
init(rendition: GiphyRendition,
|
|
|
|
init(rendition: GiphyRendition,
|
|
|
|
priority: GiphyRequestPriority,
|
|
|
|
priority: GiphyRequestPriority,
|
|
|
@ -294,6 +299,12 @@ enum GiphyAssetRequestState: UInt {
|
|
|
|
AssertIsOnMainThread()
|
|
|
|
AssertIsOnMainThread()
|
|
|
|
|
|
|
|
|
|
|
|
wasCancelled = true
|
|
|
|
wasCancelled = true
|
|
|
|
|
|
|
|
contentLengthTask?.cancel()
|
|
|
|
|
|
|
|
contentLengthTask = nil
|
|
|
|
|
|
|
|
for segment in segments {
|
|
|
|
|
|
|
|
segment.task?.cancel()
|
|
|
|
|
|
|
|
segment.task = nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Don't call the callbacks if the request is cancelled.
|
|
|
|
// Don't call the callbacks if the request is cancelled.
|
|
|
|
clearCallbacks()
|
|
|
|
clearCallbacks()
|
|
|
|