summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-01-08 15:58:55 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-01-13 13:38:12 -0800
commit54fc3831f2cef3128f3db2a3821cd2be455fc7fa (patch)
tree87cd7e902651dd20e10f75617c9770aae6839fff /platform
parent96781c0a8df89caaeffdb4267de38613a935fe25 (diff)
downloadqtlocation-mapboxgl-54fc3831f2cef3128f3db2a3821cd2be455fc7fa.tar.gz
[core] Use Seconds::max() rather than -1 for simpler logic
Diffstat (limited to 'platform')
-rw-r--r--platform/default/online_file_source.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/platform/default/online_file_source.cpp b/platform/default/online_file_source.cpp
index 54ed6c51b3..42373283cb 100644
--- a/platform/default/online_file_source.cpp
+++ b/platform/default/online_file_source.cpp
@@ -286,9 +286,9 @@ void OnlineFileRequestImpl::scheduleRealRequest(OnlineFileSource::Impl& impl, bo
return;
}
- // If we don't have a response, we should retry immediately.
- // A value < 0 means that we should not retry.
- Seconds timeout = (response && !response->stale) ? Seconds(-1) : Seconds::zero();
+ // If we don't have a fresh response, we'll retry immediately. Otherwise, the timeout will
+ // depend on how many consecutive errors we've encountered, and on the expiration time.
+ Seconds timeout = (!response || response->stale) ? Seconds::zero() : Seconds::max();
if (response && response->error) {
assert(failedRequests > 0);
@@ -314,17 +314,16 @@ void OnlineFileRequestImpl::scheduleRealRequest(OnlineFileSource::Impl& impl, bo
// Check to see if this response expires earlier than a potential error retry.
if (response && response->expires > Seconds::zero()) {
- const Seconds secsToExpire = response->expires - toSeconds(SystemClock::now());
// Only update the timeout if we don't have one yet, and only if the new timeout is shorter
// than the previous one.
- timeout = timeout < Seconds::zero() ? secsToExpire: std::min(timeout, std::max(Seconds::zero(), secsToExpire));
+ timeout = std::min(timeout, std::max(Seconds::zero(), response->expires - toSeconds(SystemClock::now())));
}
if (forceImmediate) {
timeout = Seconds::zero();
}
- if (timeout < Seconds::zero()) {
+ if (timeout == Seconds::max()) {
return;
}