Skip to content

Commit

Permalink
Add changes from BIP project
Browse files Browse the repository at this point in the history
  • Loading branch information
nsc committed Jan 21, 2011
1 parent e65daf1 commit e66eb7d
Show file tree
Hide file tree
Showing 5 changed files with 671 additions and 407 deletions.
10 changes: 10 additions & 0 deletions AFCache+PrivateAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
- (void)removeItemsForURL:(NSURL*)url;
- (void)removeItemForURL:(NSURL*)url itemDelegate:(id)itemDelegate;
- (NSFileHandle*)createFileForItem:(AFCacheableItem*)cacheableItem;
- (void)addItemToDownloadQueue:(AFCacheableItem*)item;
- (void)removeFromDownloadQueue:(AFCacheableItem*)item;
- (void)removeFromDownloadQueueAndLoadNext:(AFCacheableItem*)item;
- (void)fillPendingConnections;
- (BOOL)isQueuedURL:(NSURL*)url;
- (void)downloadNextEnqueuedItem;
- (void)downloadItem:(AFCacheableItem*)item;
- (void)registerItem:(AFCacheableItem*)item;
- (void)signalItemsForURL:(NSURL*)url usingSelector:(SEL)selector;
Expand All @@ -57,8 +63,12 @@
- (void)setDownloadStartedFileAttributes;
- (void)setDownloadFinishedFileAttributes;
- (BOOL)isDownloading;
- (BOOL)hasDownloadFileAttribute;
- (BOOL)hasValidContentLength;
- (uint64_t)getContentLengthFromFile;
- (void)appendData:(NSData*)newData;
- (void)signalItems:(NSArray*)items usingSelector:(SEL)selector;
- (void)signalItemsDidFinish:(NSArray*)items;
- (void)signalItemsDidFail:(NSArray*)items;

@end
16 changes: 13 additions & 3 deletions AFCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
// max cache item size in bytes
#define kAFCacheDefaultMaxFileSize 1000000

// max number of concurrent connections
#define kAFCacheDefaultConcurrentConnections 5

//#define AFCACHE_LOGGING_ENABLED true
#define kHTTPHeaderIfModifiedSince @"If-Modified-Since"
#define kHTTPHeaderIfNoneMatch @"If-None-Match"
Expand Down Expand Up @@ -68,8 +71,10 @@ enum {
NSMutableDictionary *cacheInfoStore;
NSMutableDictionary *pendingConnections;
NSMutableDictionary *clientItems;
NSMutableArray *downloadQueue;
BOOL _offline;
int requestCounter;
int concurrentConnections;
double maxItemFileSize;
double diskCacheDisplacementTresholdSize;
NSDictionary *suffixToMimeTypeMap;
Expand All @@ -83,16 +88,16 @@ enum {
@property (nonatomic, copy) NSString *dataPath;
@property (nonatomic, retain) NSMutableDictionary *cacheInfoStore;
@property (nonatomic, retain) NSMutableDictionary *pendingConnections;
@property (nonatomic, retain) NSMutableArray *downloadQueue;
@property (nonatomic, retain) NSDictionary *suffixToMimeTypeMap;
@property (nonatomic, retain) NSDictionary *clientItems;
@property (nonatomic, assign) double maxItemFileSize;
@property (nonatomic, assign) double diskCacheDisplacementTresholdSize;
@property (nonatomic, assign) int concurrentConnections;
@property BOOL downloadPermission;

+ (AFCache *)sharedInstance;

- (AFCacheableItem *)cachedObjectForURL: (NSURL *) url
options: (int) options;

- (AFCacheableItem *)cachedObjectForURL: (NSURL *) url
delegate: (id) aDelegate;
Expand Down Expand Up @@ -120,6 +125,9 @@ enum {
*
*/

- (AFCacheableItem *)cachedObjectForURL: (NSURL *) url
options: (int) options __AVAILABILITY_INTERNAL_DEPRECATED;

- (AFCacheableItem *)cachedObjectForURL: (NSURL *) url
delegate: (id) aDelegate
selector: (SEL) aSelector
Expand All @@ -144,6 +152,8 @@ enum {
- (BOOL)hasCachedItemForURL:(NSURL *)url;
- (unsigned long)diskCacheSize;
- (void)cancelAsynchronousOperationsForURL:(NSURL *)url itemDelegate:(id)aDelegate;
- (void)cancelAsynchronousOperationsForURL:(NSURL *)url itemDelegate:(id)aDelegate didLoadSelector:(SEL)selector;
- (void)cancelAsynchronousOperationsForDelegate:(id)aDelegate;
- (NSArray*)cacheableItemsForURL:(NSURL*)url;

- (void)flushDownloadQueue;
@end
Loading

0 comments on commit e66eb7d

Please sign in to comment.