PageRenderTime 28ms CodeModel.GetById 12ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 1ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/HTTPFetcher/GTMHTTPFetcherService.h

http://macfuse.googlecode.com/
C++ Header | 125 lines | 48 code | 20 blank | 57 comment | 0 complexity | b1739d82b7b69d59c918cd836c49ed09 MD5 | raw file
  1/* Copyright (c) 2010 Google Inc.
  2 *
  3 * Licensed under the Apache License, Version 2.0 (the "License");
  4 * you may not use this file except in compliance with the License.
  5 * You may obtain a copy of the License at
  6 *
  7 *     http://www.apache.org/licenses/LICENSE-2.0
  8 *
  9 * Unless required by applicable law or agreed to in writing, software
 10 * distributed under the License is distributed on an "AS IS" BASIS,
 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12 * See the License for the specific language governing permissions and
 13 * limitations under the License.
 14 */
 15
 16//
 17//  GTMHTTPFetcherService.h
 18//
 19
 20// The fetcher service class maintains a history to be used by a sequence
 21// of fetchers objects generated by the service.
 22//
 23// Fetchers that do not need to share a history may be generated independently,
 24// like
 25//
 26//   GTMHTTPFetcher* myFetcher = [GTMHTTPFetcher fetcherWithRequest:request];
 27//
 28// Fetchers that should share cookies or an ETagged data cache should be
 29// generated by a common GTMHTTPFetcherService instance, like
 30//
 31//   GTMHTTPFetcherService *myFetcherService = [[GTMHTTPFetcherService alloc] init];
 32//   GTMHTTPFetcher* myFirstFetcher = [myFetcherService fetcherWithRequest:request1];
 33//   GTMHTTPFetcher* mySecondFetcher = [myFetcherService fetcherWithRequest:request2];
 34
 35#import "GTMHTTPFetcher.h"
 36#import "GTMHTTPFetchHistory.h"
 37
 38@interface GTMHTTPFetcherService : NSObject<GTMHTTPFetcherServiceProtocol> {
 39 @private
 40  NSMutableDictionary *delayedHosts_;
 41  NSMutableDictionary *runningHosts_;
 42  NSUInteger maxRunningFetchersPerHost_;
 43
 44  GTMHTTPFetchHistory *fetchHistory_;
 45  NSOperationQueue *delegateQueue_;
 46  NSArray *runLoopModes_;
 47  NSString *userAgent_;
 48  NSTimeInterval timeout_;
 49  NSURLCredential *credential_;       // username & password
 50  NSURLCredential *proxyCredential_;  // credential supplied to proxy servers
 51  NSInteger cookieStorageMethod_;
 52
 53  BOOL shouldFetchInBackground_;
 54
 55  id <GTMFetcherAuthorizationProtocol> authorizer_;
 56}
 57
 58// Create a fetcher
 59//
 60// These methods will return an autoreleased fetcher, but if
 61// the fetcher is successfully created, the connection will retain the
 62// fetcher for the life of the connection as well. So the caller doesn't have
 63// to retain the fetcher explicitly unless they want to be able to monitor
 64// or cancel it.
 65- (GTMHTTPFetcher *)fetcherWithRequest:(NSURLRequest *)request;
 66- (GTMHTTPFetcher *)fetcherWithURL:(NSURL *)requestURL;
 67- (GTMHTTPFetcher *)fetcherWithURLString:(NSString *)requestURLString;
 68- (id)fetcherWithRequest:(NSURLRequest *)request
 69            fetcherClass:(Class)fetcherClass;
 70
 71// Queues of delayed and running fetchers. Each dictionary contains arrays
 72// of fetchers, keyed by host
 73//
 74// A max value of 0 means no fetchers should be delayed.
 75//
 76// The default limit is 10 simultaneous fetchers targeting each host.
 77@property (assign) NSUInteger maxRunningFetchersPerHost;
 78@property (retain, readonly) NSDictionary *delayedHosts;
 79@property (retain, readonly) NSDictionary *runningHosts;
 80
 81- (BOOL)isDelayingFetcher:(GTMHTTPFetcher *)fetcher;
 82
 83- (NSUInteger)numberOfFetchers;        // running + delayed fetchers
 84- (NSUInteger)numberOfRunningFetchers;
 85- (NSUInteger)numberOfDelayedFetchers;
 86
 87// Search for running or delayed fetchers with the specified URL.
 88//
 89// Returns an array of fetcher objects found, or nil if none found.
 90- (NSArray *)issuedFetchersWithRequestURL:(NSURL *)requestURL;
 91
 92- (void)stopAllFetchers;
 93
 94// Properties to be applied to each fetcher;
 95// see GTMHTTPFetcher.h for descriptions
 96@property (copy) NSString *userAgent;
 97@property (assign) NSTimeInterval timeout;
 98@property (retain) NSOperationQueue *delegateQueue;
 99@property (retain) NSArray *runLoopModes;
100@property (retain) NSURLCredential *credential;
101@property (retain) NSURLCredential *proxyCredential;
102@property (assign) BOOL shouldFetchInBackground;
103
104// Fetch history
105@property (retain) GTMHTTPFetchHistory *fetchHistory;
106
107@property (assign) NSInteger cookieStorageMethod;
108@property (assign) BOOL shouldRememberETags;      // default: NO
109@property (assign) BOOL shouldCacheETaggedData;   // default: NO
110
111- (void)clearETaggedDataCache;
112- (void)clearHistory;
113
114@property (nonatomic, retain) id <GTMFetcherAuthorizationProtocol> authorizer;
115
116// Spin the run loop, discarding events, until all running and delayed fetchers
117// have completed
118//
119// This is only for use in testing or in tools without a user interface.
120//
121// Synchronous fetches should never be done by shipping apps; they are
122// sufficient reason for rejection from the app store.
123- (void)waitForCompletionOfAllFetchersWithTimeout:(NSTimeInterval)timeoutInSeconds;
124
125@end