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

Unified Diff: chrome/common/net/url_fetcher.cc

Issue 6966038: Anti-DDoS enhancements: Log to net log, UMA stats, improved policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove NON_EXPORTED_BASE where not needed. Created 9 years, 7 months 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: chrome/common/net/url_fetcher.cc
diff --git a/chrome/common/net/url_fetcher.cc b/chrome/common/net/url_fetcher.cc
index 95ffc584c67b291ffa9f79534f43d36806dcebfc..960676cc0e99447faf6e715126582893deb7f7c4 100644
--- a/chrome/common/net/url_fetcher.cc
+++ b/chrome/common/net/url_fetcher.cc
@@ -58,7 +58,12 @@ class URLFetcher::Core
// safe to call this multiple times.
void Stop();
- // Reports that the received content was malformed.
+ // Reports that the received content was malformed (i.e. failed parsing
+ // or validation). This makes the throttling logic that does exponential
+ // back-off when servers are having problems treat the current request as
+ // a failure. Your call to this method will be ignored if your request is
+ // already considered a failure based on the HTTP response code or response
+ // headers.
void ReceivedContentWasMalformed();
// Overridden from net::URLRequest::Delegate:
@@ -805,6 +810,9 @@ void URLFetcher::Core::OnCompletedURLRequest(
++num_retries_;
// Restarts the request if we still need to notify the delegate.
if (delegate_) {
+ // Note that backoff_delay_ may be 0 because (a) the URLRequestThrottler
+ // code does not necessarily back off on the first error, and (b) it
+ // only backs off on some of the 5xx status codes.
fetcher_->backoff_delay_ = backoff_release_time_ - base::TimeTicks::Now();
if (fetcher_->backoff_delay_ < base::TimeDelta())
fetcher_->backoff_delay_ = base::TimeDelta();
@@ -832,8 +840,18 @@ void URLFetcher::Core::InformDelegateFetchIsComplete() {
void URLFetcher::Core::NotifyMalformedContent() {
DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
- if (url_throttler_entry_ != NULL)
- url_throttler_entry_->ReceivedContentWasMalformed();
+ if (url_throttler_entry_ != NULL) {
+ int status_code = response_code_;
+ if (status_code == -1) {
yzshen1 2011/05/25 03:49:06 Might be better to use kInvalidHttpResponseCode.
Jói 2011/05/25 14:30:35 Done.
+ // The status code will generally be known by the time clients
+ // call the |ReceivedContentWasMalformed()| function (which ends up
+ // calling the current function) but if it's not, we need to assume
+ // the response was successful so that the total failure count
+ // used to calculate exponential back-off goes up.
+ status_code = 200;
+ }
+ url_throttler_entry_->ReceivedContentWasMalformed(status_code);
+ }
}
void URLFetcher::Core::ReleaseRequest() {

Powered by Google App Engine
This is Rietveld 408576698