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

Side by Side Diff: net/url_request/url_request_throttler_entry.cc

Issue 6932013: Fix logic for handling reports of malformed bodies. To end up counting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/url_request/url_request_throttler_entry.h" 5 #include "net/url_request/url_request_throttler_entry.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 HandleCustomRetryAfter(retry_header); 189 HandleCustomRetryAfter(retry_header);
190 190
191 std::string throttling_header = response->GetNormalizedValue( 191 std::string throttling_header = response->GetNormalizedValue(
192 kExponentialThrottlingHeader); 192 kExponentialThrottlingHeader);
193 if (!throttling_header.empty()) 193 if (!throttling_header.empty())
194 HandleThrottlingHeader(throttling_header, host); 194 HandleThrottlingHeader(throttling_header, host);
195 } 195 }
196 } 196 }
197 197
198 void URLRequestThrottlerEntry::ReceivedContentWasMalformed() { 198 void URLRequestThrottlerEntry::ReceivedContentWasMalformed() {
199 // We keep this simple and just count it as a single error. 199 // A malformed body can only occur when the request to fetch a resource
200 // 200 // was successful. Therefore, in such a situation, we will receive one
201 // If we wanted to get fancy, we would count two errors here, and decrease 201 // call to ReceivedContentWasMalformed() and one call to UpdateWithResponse()
202 // the error count only by one when we receive a successful (by status 202 // with a response categorized as "good". To end up counting one failure,
203 // code) response. Instead, we keep things simple by always resetting the 203 // we need to count two failures here against the one success in
204 // error count on success, and therefore counting only a single error here. 204 // UpdateWithResponse().
205 GetBackoffEntry()->InformOfRequest(false);
205 GetBackoffEntry()->InformOfRequest(false); 206 GetBackoffEntry()->InformOfRequest(false);
206 } 207 }
207 208
208 URLRequestThrottlerEntry::~URLRequestThrottlerEntry() { 209 URLRequestThrottlerEntry::~URLRequestThrottlerEntry() {
209 } 210 }
210 211
211 void URLRequestThrottlerEntry::Initialize() { 212 void URLRequestThrottlerEntry::Initialize() {
212 sliding_window_release_time_ = base::TimeTicks::Now(); 213 sliding_window_release_time_ = base::TimeTicks::Now();
213 backoff_policy_.num_errors_to_ignore = kDefaultNumErrorsToIgnore; 214 backoff_policy_.num_errors_to_ignore = kDefaultNumErrorsToIgnore;
214 backoff_policy_.initial_backoff_ms = kDefaultInitialBackoffMs; 215 backoff_policy_.initial_backoff_ms = kDefaultInitialBackoffMs;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 259
259 const BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() const { 260 const BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() const {
260 return &backoff_entry_; 261 return &backoff_entry_;
261 } 262 }
262 263
263 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { 264 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() {
264 return &backoff_entry_; 265 return &backoff_entry_;
265 } 266 }
266 267
267 } // namespace net 268 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698