summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/default/default_file_source.cpp11
-rw-r--r--platform/default/online_file_source.cpp9
2 files changed, 13 insertions, 7 deletions
diff --git a/platform/default/default_file_source.cpp b/platform/default/default_file_source.cpp
index 80666ca122..e3b785d086 100644
--- a/platform/default/default_file_source.cpp
+++ b/platform/default/default_file_source.cpp
@@ -1,6 +1,5 @@
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/storage/asset_file_source.hpp>
-#include <mbgl/storage/network_status.hpp>
#include <mbgl/storage/online_file_source.hpp>
#include <mbgl/storage/offline_database.hpp>
#include <mbgl/storage/offline_download.hpp>
@@ -40,12 +39,10 @@ public:
callback(*offlineResponse);
}
- if (NetworkStatus::Get() == NetworkStatus::Status::Online) {
- onlineRequest = impl->onlineFileSource.request(revalidation, [=] (Response onlineResponse) {
- impl->offlineDatabase.put(revalidation, onlineResponse);
- callback(onlineResponse);
- });
- }
+ onlineRequest = impl->onlineFileSource.request(revalidation, [=] (Response onlineResponse) {
+ impl->offlineDatabase.put(revalidation, onlineResponse);
+ callback(onlineResponse);
+ });
}
std::unique_ptr<FileRequest> onlineRequest;
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);
});