[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.
This commit is contained in:
Konstantin Käfer
2017-10-09 12:59:27 +02:00
parent 98a47884f0
commit f4cb3b8a4f
25 changed files with 284 additions and 251 deletions

View File

@@ -32,12 +32,12 @@ void RasterTile::setError(std::exception_ptr err) {
observer->onTileError(*this, err);
}
void RasterTile::setData(std::shared_ptr<const std::string> data,
optional<Timestamp> modified_,
optional<Timestamp> expires_) {
void RasterTile::setMetadata(optional<Timestamp> modified_, optional<Timestamp> expires_) {
modified = modified_;
expires = expires_;
}
void RasterTile::setData(std::shared_ptr<const std::string> data) {
pending = true;
++correlationID;
worker.invoke(&RasterTileWorker::parse, data, correlationID);
@@ -77,7 +77,7 @@ void RasterTile::setMask(TileMask&& mask) {
}
}
void RasterTile::setNecessity(Necessity necessity) {
void RasterTile::setNecessity(TileNecessity necessity) {
loader.setNecessity(necessity);
}