Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Unified Diff: net/url_request/url_fetcher_core.h

Issue 11464028: Introduce ERR_NETWORK_CHANGED and allow URLFetcher to automatically retry on that error. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased, post first try if online, more tests Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/url_request/url_fetcher_core.h
diff --git a/net/url_request/url_fetcher_core.h b/net/url_request/url_fetcher_core.h
index 4b258e5384c380e611447da09d29d79838b678d1..67589c481c2f701e077c7877a009effec04efbcf 100644
--- a/net/url_request/url_fetcher_core.h
+++ b/net/url_request/url_fetcher_core.h
@@ -20,6 +20,7 @@
#include "base/timer.h"
#include "googleurl/src/gurl.h"
#include "net/base/host_port_pair.h"
+#include "net/base/network_change_notifier.h"
#include "net/http/http_request_headers.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request.h"
@@ -38,7 +39,8 @@ class URLRequestThrottlerEntryInterface;
class URLFetcherCore
: public base::RefCountedThreadSafe<URLFetcherCore>,
- public URLRequest::Delegate {
+ public URLRequest::Delegate,
+ public NetworkChangeNotifier::ConnectionTypeObserver {
szym 2012/12/10 18:36:31 Shouldn't it use NetworkChangeObserver?
Joao da Silva 2012/12/11 13:36:43 This is only used to determine if IsOffline() chan
public:
URLFetcherCore(URLFetcher* fetcher,
const GURL& original_url,
@@ -86,9 +88,10 @@ class URLFetcherCore
const URLFetcher::CreateDataCallback& create_data_callback);
void SetStopOnRedirect(bool stop_on_redirect);
void SetAutomaticallyRetryOn5xx(bool retry);
- void SetMaxRetries(int max_retries);
- int GetMaxRetries() const;
+ void SetMaxRetriesOn5xx(int max_retries);
+ int GetMaxRetriesOn5xx() const;
base::TimeDelta GetBackoffDelay() const;
+ void SetAutomaticallyRetryOnNetworkChanges(int max_retries);
void SaveResponseToFileAtPath(
const FilePath& file_path,
scoped_refptr<base::TaskRunner> file_task_runner);
@@ -122,6 +125,10 @@ class URLFetcherCore
virtual void OnReadCompleted(URLRequest* request,
int bytes_read) OVERRIDE;
+ // Overridden from NetworkChangeNotifier::ConnectionTypeObserver:
+ virtual void OnConnectionTypeChanged(
+ NetworkChangeNotifier::ConnectionType type) OVERRIDE;
+
URLFetcherDelegate* delegate() const { return delegate_; }
static void CancelAll();
static int GetNumFetcherCores();
@@ -352,11 +359,6 @@ class URLFetcherCore
original_url_throttler_entry_;
scoped_refptr<URLRequestThrottlerEntryInterface> url_throttler_entry_;
- // |num_retries_| indicates how many times we've failed to successfully
- // fetch this URL. Once this value exceeds the maximum number of retries
- // specified by the owner URLFetcher instance, we'll give up.
- int num_retries_;
-
// True if the URLFetcher has been cancelled.
bool was_cancelled_;
@@ -384,11 +386,22 @@ class URLFetcherCore
// re-execute the request, after the back-off delay has expired.
// true by default.
bool automatically_retry_on_5xx_;
- // Maximum retries allowed.
- int max_retries_;
+ // |num_retries_on_5xx_| indicates how many times we've failed to successfully
+ // fetch this URL due to 5xx responses. Once this value exceeds the maximum
+ // number of retries specified by the owner URLFetcher instance,
+ // we'll give up.
+ int num_retries_on_5xx_;
+ // Maximum retries allowed when 5xx responses are received.
+ int max_retries_on_5xx_;
// Back-off time delay. 0 by default.
base::TimeDelta backoff_delay_;
+ // The number of retries that have been attempted due to ERR_NETWORK_CHANGED.
+ int num_retries_on_network_changes_;
+ // Maximum retries allowed when the request fails with ERR_NETWORK_CHANGED.
+ // 0 by default.
+ int max_retries_on_network_changes_;
+
// Timer to poll the progress of uploading for POST and PUT requests.
// When crbug.com/119629 is fixed, scoped_ptr is not necessary here.
scoped_ptr<base::RepeatingTimer<URLFetcherCore> >

Powered by Google App Engine
This is Rietveld 408576698