SDWebImageDownloaderOperation.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import <Foundation/Foundation.h>
  9. #import "SDWebImageDownloader.h"
  10. #import "SDWebImageOperation.h"
  11. extern NSString *const SDWebImageDownloadStartNotification;
  12. extern NSString *const SDWebImageDownloadReceiveResponseNotification;
  13. extern NSString *const SDWebImageDownloadStopNotification;
  14. extern NSString *const SDWebImageDownloadFinishNotification;
  15. @interface SDWebImageDownloaderOperation : NSOperation <SDWebImageOperation>
  16. /**
  17. * The request used by the operation's connection.
  18. */
  19. @property (strong, nonatomic, readonly) NSURLRequest *request;
  20. @property (assign, nonatomic) BOOL shouldDecompressImages;
  21. /**
  22. * Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default.
  23. *
  24. * This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`.
  25. */
  26. @property (nonatomic, assign) BOOL shouldUseCredentialStorage;
  27. /**
  28. * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`.
  29. *
  30. * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present.
  31. */
  32. @property (nonatomic, strong) NSURLCredential *credential;
  33. /**
  34. * The SDWebImageDownloaderOptions for the receiver.
  35. */
  36. @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options;
  37. /**
  38. * The expected size of data.
  39. */
  40. @property (assign, nonatomic) NSInteger expectedSize;
  41. /**
  42. * The response returned by the operation's connection.
  43. */
  44. @property (strong, nonatomic) NSURLResponse *response;
  45. /**
  46. * Initializes a `SDWebImageDownloaderOperation` object
  47. *
  48. * @see SDWebImageDownloaderOperation
  49. *
  50. * @param request the URL request
  51. * @param options downloader options
  52. * @param progressBlock the block executed when a new chunk of data arrives.
  53. * @note the progress block is executed on a background queue
  54. * @param completedBlock the block executed when the download is done.
  55. * @note the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue
  56. * @param cancelBlock the block executed if the download (operation) is cancelled
  57. *
  58. * @return the initialized instance
  59. */
  60. - (id)initWithRequest:(NSURLRequest *)request
  61. options:(SDWebImageDownloaderOptions)options
  62. progress:(SDWebImageDownloaderProgressBlock)progressBlock
  63. completed:(SDWebImageDownloaderCompletedBlock)completedBlock
  64. cancelled:(SDWebImageNoParamsBlock)cancelBlock;
  65. @end