Bug 423790: Back off of safebrowsing updates for 4xx errors. r=tony, blocking-firefox3=beltzner

git-svn-id: svn://10.0.0.236/trunk@248245 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dcamp%mozilla.com 2008-03-20 01:55:56 +00:00
parent 1aca9802fb
commit 96d0874e34
2 changed files with 12 additions and 7 deletions

View File

@ -467,6 +467,9 @@ PROT_ListManager.prototype.updateSuccess_ = function(waitForUpdate) {
if (delay >= (5 * 60) && this.updateChecker_)
this.updateChecker_.setDelay(delay * 1000);
}
// Let the backoff object know that we completed successfully.
this.requestBackoff_.noteServerResponse(200);
}
/**
@ -492,9 +495,11 @@ PROT_ListManager.prototype.downloadError_ = function(status) {
status = parseInt(status, 10);
this.requestBackoff_.noteServerResponse(status);
// Try again in a minute
this.currentUpdateChecker_ =
new G_Alarm(BindToObject(this.checkForUpdates, this), 60000);
if (this.requestBackoff_.isErrorStatus(status)) {
// Try again in a minute
this.currentUpdateChecker_ =
new G_Alarm(BindToObject(this.checkForUpdates, this), 60000);
}
}
/**

View File

@ -90,7 +90,7 @@ RequestBackoff.prototype.canMakeRequest = function() {
* Notify this object of the last server response. If it's an error,
*/
RequestBackoff.prototype.noteServerResponse = function(status) {
if (this.isErrorStatus_(status)) {
if (this.isErrorStatus(status)) {
var now = Date.now();
this.errorTimes_.push(now);
@ -120,12 +120,12 @@ RequestBackoff.prototype.noteServerResponse = function(status) {
}
/**
* We consider 302, 303, 307, and 5xx http responses to be errors.
* We consider 302, 303, 307, 4xx, and 5xx http responses to be errors.
* @param status Number http status
* @return Boolean true if we consider this http status an error
*/
RequestBackoff.prototype.isErrorStatus_ = function(status) {
return ((500 <= status && status <= 599) ||
RequestBackoff.prototype.isErrorStatus = function(status) {
return ((400 <= status && status <= 599) ||
HTTP_FOUND == status ||
HTTP_SEE_OTHER == status ||
HTTP_TEMPORARY_REDIRECT == status);