summaryrefslogtreecommitdiff
path: root/src/mbgl/tile/tile.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-10-09 12:59:27 +0200
committerKonstantin Käfer <mail@kkaefer.com>2017-10-12 10:41:49 +0200
commitf4cb3b8a4f70723f22d89b163160dc1a28d8d8a0 (patch)
treee41558bee74394c181664cf6047abad8a8cb7a2d /src/mbgl/tile/tile.hpp
parent98a47884f06a8f165a2c15a54f82b356c8ef23d8 (diff)
downloadqtlocation-mapboxgl-f4cb3b8a4f70723f22d89b163160dc1a28d8d8a0.tar.gz
[core] make forcing cache/network only more explicit
Previously, we used the existence of a `prior*` field in the Resource object as an indication for whether we should consult the cache or not. However, this is prone to error, since a failed cache lookup won't set any prior fields. Therefore, we manually set `priorExpires` to 0. This in turn triggered another bug where generated wrong expiration timestamps when the server response we got was expired (or expired between sending and receiving). This commit changes the flags so that we can now explicitly request CacheOnly/NetworkOnly (or All) loading methods, rather than the implicit Optional/Required naming scheme.
Diffstat (limited to 'src/mbgl/tile/tile.hpp')
-rw-r--r--src/mbgl/tile/tile.hpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/mbgl/tile/tile.hpp b/src/mbgl/tile/tile.hpp
index 39cc0de8bd..8be7c4d862 100644
--- a/src/mbgl/tile/tile.hpp
+++ b/src/mbgl/tile/tile.hpp
@@ -6,6 +6,7 @@
#include <mbgl/util/feature.hpp>
#include <mbgl/util/tile_coordinate.hpp>
#include <mbgl/tile/tile_id.hpp>
+#include <mbgl/tile/tile_necessity.hpp>
#include <mbgl/renderer/tile_mask.hpp>
#include <mbgl/renderer/bucket.hpp>
#include <mbgl/tile/geometry_tile_data.hpp>
@@ -38,14 +39,7 @@ public:
void setObserver(TileObserver* observer);
- // Tiles can have two states: optional or required.
- // - optional means that only low-cost actions should be taken to obtain the data
- // (e.g. load from cache, but accept stale data)
- // - required means that every effort should be taken to obtain the data (e.g. load
- // from internet and keep the data fresh if it expires)
- using Necessity = Resource::Necessity;
-
- virtual void setNecessity(Necessity) = 0;
+ virtual void setNecessity(TileNecessity) {}
// Mark this tile as no longer needed and cancel any pending work.
virtual void cancel() = 0;
@@ -68,11 +62,11 @@ public:
std::vector<Feature>& result,
const SourceQueryOptions&);
- void setTriedOptional();
+ void setTriedCache();
// Returns true when the tile source has received a first response, regardless of whether a load
// error occurred or actual data was loaded.
- bool hasTriedOptional() const {
+ bool hasTriedCache() const {
return triedOptional;
}