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

Unified Diff: media/test/data/eme_player_js/utils.js

Issue 614423002: Retry license request on timeouts and errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove retry limit Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/test/data/eme_player_js/utils.js
diff --git a/media/test/data/eme_player_js/utils.js b/media/test/data/eme_player_js/utils.js
index b7d2d6d4f03d58eee5f8e45bbca7c1e612baad80..43734c1c304c2e0e491e25f458467463b9139514 100644
--- a/media/test/data/eme_player_js/utils.js
+++ b/media/test/data/eme_player_js/utils.js
@@ -214,21 +214,21 @@ Utils.resetTitleChange = function() {
Utils.sendRequest = function(requestType, responseType, message, serverURL,
onSuccessCallbackFn, forceInvalidResponse) {
var requestAttemptCount = 0;
- var MAXIMUM_REQUEST_ATTEMPTS = 3;
var REQUEST_RETRY_DELAY_MS = 3000;
+ var REQUEST_TIMEOUT_MS = 1000;
function sendRequestAttempt() {
+ // No limit on the number of retries. This will retry on failures
+ // until the test framework stops the test.
requestAttemptCount++;
- if (requestAttemptCount == MAXIMUM_REQUEST_ATTEMPTS) {
- Utils.failTest('FAILED: Exceeded maximum license request attempts.');
- return;
- }
var xmlhttp = new XMLHttpRequest();
xmlhttp.responseType = responseType;
xmlhttp.open(requestType, serverURL, true);
xmlhttp.onerror = function(e) {
Utils.timeLog('Request status: ' + this.statusText);
- Utils.failTest('FAILED: License request XHR failed with network error.');
+ Utils.timeLog('FAILED: License request XHR failed with network error.');
+ Utils.timeLog('Retrying request in ' + REQUEST_RETRY_DELAY_MS + 'ms');
+ setTimeout(sendRequestAttempt, REQUEST_RETRY_DELAY_MS);
};
xmlhttp.onload = function(e) {
if (this.status == 200) {
@@ -237,11 +237,16 @@ Utils.sendRequest = function(requestType, responseType, message, serverURL,
} else {
Utils.timeLog('Bad response status: ' + this.status);
Utils.timeLog('Bad response: ' + this.response);
- Utils.timeLog('Retrying request if possible in ' +
- REQUEST_RETRY_DELAY_MS + 'ms');
+ Utils.timeLog('Retrying request in ' + REQUEST_RETRY_DELAY_MS + 'ms');
setTimeout(sendRequestAttempt, REQUEST_RETRY_DELAY_MS);
}
};
+ xmlhttp.timeout = REQUEST_TIMEOUT_MS;
+ xmlhttp.ontimeout = function(e) {
+ Utils.timeLog('Request timeout');
+ Utils.timeLog('Retrying request in ' + REQUEST_RETRY_DELAY_MS + 'ms');
+ setTimeout(sendRequestAttempt, REQUEST_RETRY_DELAY_MS);
+ }
Utils.timeLog('Attempt (' + requestAttemptCount +
'): sending request to server: ' + serverURL);
xmlhttp.send(message);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698