зеркало из https://github.com/mozilla/gecko-dev.git
Bug 934172 - Retry on error and timeout. r=schien
This commit is contained in:
Родитель
5243b2c0a5
Коммит
dd6b8289d9
|
@ -298,12 +298,13 @@ CaptivePortalDetector.prototype = {
|
|||
|
||||
let urlFetcher = new URLFetcher(this._canonicalSiteURL, this._maxWaitingTime);
|
||||
|
||||
let requestDone = this.executeCallback.bind(this, true);
|
||||
urlFetcher.ontimeout = requestDone;
|
||||
urlFetcher.onerror = requestDone;
|
||||
let mayRetry = this._mayRetry.bind(this);
|
||||
|
||||
urlFetcher.ontimeout = mayRetry;
|
||||
urlFetcher.onerror = mayRetry;
|
||||
urlFetcher.onsuccess = function (content) {
|
||||
if (self.validateContent(content)) {
|
||||
requestDone();
|
||||
self.executeCallback(true);
|
||||
} else {
|
||||
// Content of the canonical website has been overwrite
|
||||
self._startLogin();
|
||||
|
@ -313,11 +314,8 @@ CaptivePortalDetector.prototype = {
|
|||
if (status >= 300 && status <= 399) {
|
||||
// The canonical website has been redirected to an unknown location
|
||||
self._startLogin();
|
||||
} else if (self._runningRequest.retryCount++ < self._maxRetryCount) {
|
||||
debug('startDetection-retry: ' + self._runningRequest.retryCount);
|
||||
self._startDetection();
|
||||
} else {
|
||||
requestDone();
|
||||
mayRetry();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -336,6 +334,15 @@ CaptivePortalDetector.prototype = {
|
|||
this._sendEvent(kOpenCaptivePortalLoginEvent, details);
|
||||
},
|
||||
|
||||
_mayRetry: function _mayRetry() {
|
||||
if (this._runningRequest.retryCount++ < this._maxRetryCount) {
|
||||
debug('retry-Detection: ' + this._runningRequest.retryCount + '/' + this._maxRetryCount);
|
||||
this._startDetection();
|
||||
} else {
|
||||
this.executeCallback(true);
|
||||
}
|
||||
},
|
||||
|
||||
executeCallback: function executeCallback(success) {
|
||||
if (this._runningRequest) {
|
||||
debug('callback executed');
|
||||
|
|
Загрузка…
Ссылка в новой задаче