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

Unified Diff: gm/rebaseline_server/static/loader.js

Issue 192833003: rebaseline_server: fix reload delay when there is client/server clock skew (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: reload: old chunk mismatch Created 6 years, 9 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: gm/rebaseline_server/static/loader.js
diff --git a/gm/rebaseline_server/static/loader.js b/gm/rebaseline_server/static/loader.js
index 254d0fda05e1956ab39537fc7663bb443414c520..d82c2f74f0c96040ff34517c39b520c71cbdce0b 100644
--- a/gm/rebaseline_server/static/loader.js
+++ b/gm/rebaseline_server/static/loader.js
@@ -75,14 +75,20 @@ Loader.controller(
function(data, status, header, config) {
var dataHeader = data[constants.KEY__HEADER];
if (dataHeader[constants.KEY__HEADER__IS_STILL_LOADING]) {
+ // Apply the server's requested reload delay to local time,
+ // so we will wait the right number of seconds regardless of clock
+ // skew between client and server.
+ var reloadDelayInSeconds =
+ dataHeader[constants.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE] -
+ dataHeader[constants.KEY__HEADER__TIME_UPDATED];
+ var timeNow = new Date().getTime();
+ var timeToReload = timeNow + reloadDelayInSeconds * 1000;
$scope.loadingMessage =
"Server is still loading results; will retry at " +
- $scope.localTimeString(dataHeader[
- constants.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE]);
+ $scope.localTimeString(timeToReload / 1000);
borenet 2014/03/10 17:51:14 Why not store this in a timeToReloadInSeconds vari
epoger 2014/03/10 18:04:47 The problem with that, is that I would need to div
$timeout(
function(){location.reload();},
- (dataHeader[constants.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE]
- * 1000) - new Date().getTime());
+ timeToReload - timeNow);
} else {
$scope.loadingMessage = "Processing data, please wait...";
« 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