forked from facebookarchive/three20
/
TTURLRequestQueue.h
84 lines (70 loc) · 2.35 KB
/
TTURLRequestQueue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#import "Three20/TTGlobal.h"
@class TTURLRequest;
@interface TTURLRequestQueue : NSObject {
NSMutableDictionary* _loaders;
NSMutableArray* _loaderQueue;
NSTimer* _loaderQueueTimer;
NSInteger _totalLoading;
NSUInteger _maxContentLength;
NSString* _userAgent;
CGFloat _imageCompressionQuality;
BOOL _suspended;
}
/**
* Gets the flag that determines if new load requests are allowed to reach the network.
*
* Because network requests tend to slow down performance, this property can be used to
* temporarily delay them. All requests made while suspended are queued, and when
* suspended becomes false again they are executed.
*/
@property(nonatomic) BOOL suspended;
/**
* The maximum size of a download that is allowed.
*
* If a response reports a content length greater than the max, the download will be
* cancelled. This is helpful for preventing excessive memory usage. Setting this to
* zero will allow all downloads regardless of size. The default is a relatively large value.
*/
@property(nonatomic) NSUInteger maxContentLength;
/**
* The user-agent string that is sent with all HTTP requests.
*/
@property(nonatomic,copy) NSString* userAgent;
/**
* The compression quality used for encoding images sent with HTTP posts.
*/
@property(nonatomic) CGFloat imageCompressionQuality;
/**
* Gets the shared cache singleton used across the application.
*/
+ (TTURLRequestQueue*)mainQueue;
/**
* Sets the shared cache singleton used across the application.
*/
+ (void)setMainQueue:(TTURLRequestQueue*)queue;
/**
* Loads a request from the cache or the network if it is not in the cache.
*
* @return YES if the request was loaded synchronously from the cache.
*/
- (BOOL)sendRequest:(TTURLRequest*)request;
/**
* Cancels a request that is in progress.
*/
- (void)cancelRequest:(TTURLRequest*)request;
/**
* Cancels all active or pending requests whose delegate or response is an object.
*
* This is useful for when an object is about to be destroyed and you want to remove pointers
* to it from active requests to prevent crashes when those pointers are later referenced.
*/
- (void)cancelRequestsWithDelegate:(id)delegate;
/**
* Cancel all active or pending requests.
*/
- (void)cancelAllRequests;
/**
* Creates a Cocoa URL request from a Three20 URL request.
*/
- (NSURLRequest*)createNSURLRequest:(TTURLRequest*)request url:(NSURL*)url;
@end