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

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: 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..dbb764959f98693fc59ae5ff41411c4976cd8e92 100644
--- a/media/test/data/eme_player_js/utils.js
+++ b/media/test/data/eme_player_js/utils.js
@@ -216,10 +216,11 @@ Utils.sendRequest = function(requestType, responseType, message, serverURL,
var requestAttemptCount = 0;
var MAXIMUM_REQUEST_ATTEMPTS = 3;
var REQUEST_RETRY_DELAY_MS = 3000;
+ var REQUEST_TIMEOUT_MS = 1000;
function sendRequestAttempt() {
requestAttemptCount++;
- if (requestAttemptCount == MAXIMUM_REQUEST_ATTEMPTS) {
+ if (requestAttemptCount > MAXIMUM_REQUEST_ATTEMPTS) {
Utils.failTest('FAILED: Exceeded maximum license request attempts.');
return;
}
@@ -227,8 +228,10 @@ Utils.sendRequest = function(requestType, responseType, message, serverURL,
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('Request error: ' + this.statusText);
+ Utils.timeLog('Retrying request if possible in ' +
+ REQUEST_RETRY_DELAY_MS + 'ms');
sandersd (OOO until July 31) 2014/10/01 17:46:12 statusText is typically uninformative (it's probab
jrummell 2014/10/01 20:49:07 Done.
+ setTimeout(sendRequestAttempt, REQUEST_RETRY_DELAY_MS);
};
xmlhttp.onload = function(e) {
if (this.status == 200) {
@@ -242,6 +245,13 @@ Utils.sendRequest = function(requestType, responseType, message, serverURL,
setTimeout(sendRequestAttempt, REQUEST_RETRY_DELAY_MS);
}
};
+ xmlhttp.timeout = REQUEST_TIMEOUT_MS;
+ xmlhttp.ontimeout = function(e) {
+ Utils.timeLog('Attempt (' + requestAttemptCount + ') timeout');
sandersd (OOO until July 31) 2014/10/01 17:46:11 It would be good to format the three kinds of fail
jrummell 2014/10/01 20:49:07 Done.
+ Utils.timeLog('Retrying request if possible 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