diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-04-17 17:47:28 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-04-20 21:54:31 +0300 |
commit | 3c6ccfbb5d7a80e266eda4fa41ae35cf8f625f0d (patch) | |
tree | 1c5bc541361483df01a0d397dda9873319cf183d /src/mbgl/tile/tile_loader_impl.hpp | |
parent | ce11fc6cfeb157673befd6a00290e19d6522b01a (diff) | |
download | qtlocation-mapboxgl-3c6ccfbb5d7a80e266eda4fa41ae35cf8f625f0d.tar.gz |
[core] Introduce Tile::setMinimumUpdateInterval()
Diffstat (limited to 'src/mbgl/tile/tile_loader_impl.hpp')
-rw-r--r-- | src/mbgl/tile/tile_loader_impl.hpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/mbgl/tile/tile_loader_impl.hpp b/src/mbgl/tile/tile_loader_impl.hpp index b518ac6782..78b9fe6df3 100644 --- a/src/mbgl/tile/tile_loader_impl.hpp +++ b/src/mbgl/tile/tile_loader_impl.hpp @@ -57,6 +57,30 @@ template <typename T> TileLoader<T>::~TileLoader() = default; template <typename T> +void TileLoader<T>::setNecessity(TileNecessity newNecessity) { + if (newNecessity != necessity) { + necessity = newNecessity; + if (necessity == TileNecessity::Required) { + makeRequired(); + } else { + makeOptional(); + } + } +} + +template <typename T> +void TileLoader<T>::setMinimumUpdateInterval(Duration interval) { + if (minimumUpdateInterval != interval) { + minimumUpdateInterval = interval; + if (hasPendingNetworkRequest()) { + // Update the pending request. + request.reset(); + loadFromNetwork(); + } + } +} + +template <typename T> void TileLoader<T>::loadFromCache() { assert(!request); if (!fileSource) { @@ -99,7 +123,7 @@ void TileLoader<T>::makeRequired() { template <typename T> void TileLoader<T>::makeOptional() { - if (resource.loadingMethod == Resource::LoadingMethod::NetworkOnly && request) { + if (hasPendingNetworkRequest()) { // Abort the current request, but only when we know that we're specifically querying for a // network resource only. request.reset(); @@ -135,6 +159,7 @@ void TileLoader<T>::loadFromNetwork() { // Instead of using Resource::LoadingMethod::All, we're first doing a CacheOnly, and then a // NetworkOnly request. resource.loadingMethod = Resource::LoadingMethod::NetworkOnly; + resource.minimumUpdateInterval = minimumUpdateInterval; request = fileSource->request(resource, [this](const Response& res) { loadedData(res); }); } |