1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_CHROME_BROWSER_NET_RETRYABLE_URL_FETCHER_H_
6 #define IOS_CHROME_BROWSER_NET_RETRYABLE_URL_FETCHER_H_
8 #import <Foundation/Foundation.h>
10 #include "net/base/backoff_entry.h"
13 class URLRequestContextGetter
;
16 // Delegate protocol for RetryableURLFetcher object.
17 @protocol RetryableURLFetcherDelegate
<NSObject
>
19 // Returns the HTTP URL for RetryableURLFetcher to fetch.
20 - (NSString
*)urlToFetch
;
22 // Callback function after URL has been fetched. |response| is the content of
23 // the HTTP response. |response| may be nil if the HTTP request failed.
24 - (void)processSuccessResponse
:(NSString
*)response
;
28 @interface RetryableURLFetcher
: NSObject
30 // Designated initializer. |context| and |delegate| must not be nil. If |policy|
31 // is not null, it specifies how often to retry the URL fetch on a call to
32 // -startFetch. If |policy| is null, there is no retry.
34 initWithRequestContextGetter
:(net::URLRequestContextGetter
*)context
35 delegate
:(id
<RetryableURLFetcherDelegate
>)delegate
36 backoffPolicy
:(const net::BackoffEntry::Policy
*)policy
;
38 // Starts fetching URL. Uses the backoff policy specified when the object was
42 // Returns the number of times that this URL Fetcher failed to receive a
43 // success response. Returns 0 if this URL Fetcher was not set up to do retries.
48 #endif // IOS_CHROME_BROWSER_NET_RETRYABLE_URL_FETCHER_H_