summaryrefslogtreecommitdiff
path: root/platform/default/online_file_source.cpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-03-07 22:50:57 -0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-03-08 10:31:01 -0300
commit672727f773070f11e9eb2755d3e9c83b75b0d2d8 (patch)
treed47c7a00f339994dd861c6b346e22e3407967072 /platform/default/online_file_source.cpp
parentb8b283588f59db539715217aba164a380e053ea5 (diff)
downloadqtlocation-mapboxgl-672727f773070f11e9eb2755d3e9c83b75b0d2d8.tar.gz
[core] Make OnlineFileSource respect the NetworkStatus
The user can now force the Offline mode and set it back to Online, triggering the requests waiting for network connection.
Diffstat (limited to 'platform/default/online_file_source.cpp')
-rw-r--r--platform/default/online_file_source.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/platform/default/online_file_source.cpp b/platform/default/online_file_source.cpp
index a39aee35a1..77dddac112 100644
--- a/platform/default/online_file_source.cpp
+++ b/platform/default/online_file_source.cpp
@@ -289,6 +289,15 @@ void OnlineFileRequestImpl::schedule(OnlineFileSource::Impl& impl, optional<Syst
return;
}
+ // Emulate a Connection error when the Offline mode is forced with
+ // a really long timeout. The request will get re-triggered when
+ // the NetworkStatus is set back to Online.
+ if (NetworkStatus::Get() == NetworkStatus::Status::Offline) {
+ failedRequestReason = Response::Error::Reason::Connection;
+ failedRequests = 1;
+ timeout = Duration::max();
+ }
+
timer.start(timeout, Duration::zero(), [&] {
impl.activateOrQueueRequest(this);
});