SDWebImageDownloaderConfig.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 "SDWebImageCompat.h"
  10. /// Operation execution order
  11. typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) {
  12. /**
  13. * Default value. All download operations will execute in queue style (first-in-first-out).
  14. */
  15. SDWebImageDownloaderFIFOExecutionOrder,
  16. /**
  17. * All download operations will execute in stack style (last-in-first-out).
  18. */
  19. SDWebImageDownloaderLIFOExecutionOrder
  20. };
  21. /**
  22. The class contains all the config for image downloader
  23. @note This class conform to NSCopying, make sure to add the property in `copyWithZone:` as well.
  24. */
  25. @interface SDWebImageDownloaderConfig : NSObject <NSCopying>
  26. /**
  27. Gets the default downloader config used for shared instance or initialization when it does not provide any downloader config. Such as `SDWebImageDownloader.sharedDownloader`.
  28. @note You can modify the property on default downloader config, which can be used for later created downloader instance. The already created downloader instance does not get affected.
  29. */
  30. @property (nonatomic, class, readonly, nonnull) SDWebImageDownloaderConfig *defaultDownloaderConfig;
  31. /**
  32. * The maximum number of concurrent downloads.
  33. * Defaults to 6.
  34. */
  35. @property (nonatomic, assign) NSInteger maxConcurrentDownloads;
  36. /**
  37. * The timeout value (in seconds) for each download operation.
  38. * Defaults to 15.0.
  39. */
  40. @property (nonatomic, assign) NSTimeInterval downloadTimeout;
  41. /**
  42. * The minimum interval about progress percent during network downloading. Which means the next progress callback and current progress callback's progress percent difference should be larger or equal to this value. However, the final finish download progress callback does not get effected.
  43. * The value should be 0.0-1.0.
  44. * @note If you're using progressive decoding feature, this will also effect the image refresh rate.
  45. * @note This value may enhance the performance if you don't want progress callback too frequently.
  46. * Defaults to 0, which means each time we receive the new data from URLSession, we callback the progressBlock immediately.
  47. */
  48. @property (nonatomic, assign) double minimumProgressInterval;
  49. /**
  50. * The custom session configuration in use by NSURLSession. If you don't provide one, we will use `defaultSessionConfiguration` instead.
  51. * Defatuls to nil.
  52. * @note This property does not support dynamic changes, means it's immutable after the downloader instance initialized.
  53. */
  54. @property (nonatomic, strong, nullable) NSURLSessionConfiguration *sessionConfiguration;
  55. /**
  56. * Gets/Sets a subclass of `SDWebImageDownloaderOperation` as the default
  57. * `NSOperation` to be used each time SDWebImage constructs a request
  58. * operation to download an image.
  59. * Defaults to nil.
  60. * @note Passing `NSOperation<SDWebImageDownloaderOperation>` to set as default. Passing `nil` will revert to `SDWebImageDownloaderOperation`.
  61. */
  62. @property (nonatomic, assign, nullable) Class operationClass;
  63. /**
  64. * Changes download operations execution order.
  65. * Defaults to `SDWebImageDownloaderFIFOExecutionOrder`.
  66. */
  67. @property (nonatomic, assign) SDWebImageDownloaderExecutionOrder executionOrder;
  68. /**
  69. * Set the default URL credential to be set for request operations.
  70. * Defaults to nil.
  71. */
  72. @property (nonatomic, copy, nullable) NSURLCredential *urlCredential;
  73. /**
  74. * Set username using for HTTP Basic authentication.
  75. * Defaults to nil.
  76. */
  77. @property (nonatomic, copy, nullable) NSString *username;
  78. /**
  79. * Set password using for HTTP Basic authentication.
  80. * Defaults to nil.
  81. */
  82. @property (nonatomic, copy, nullable) NSString *password;
  83. @end