[core] Include prior values of caching headers in Resource
This allows the FileSource interface itself to support revalidation. We could (and probably should) now rewrite HTTPContextBase implementations as FileSource implementations.
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
#ifndef MBGL_STORAGE_RESOURCE
|
||||
#define MBGL_STORAGE_RESOURCE
|
||||
|
||||
#include <mbgl/storage/response.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
struct Resource {
|
||||
class Resource {
|
||||
public:
|
||||
enum Kind : uint8_t {
|
||||
Unknown = 0,
|
||||
Style,
|
||||
@@ -17,19 +20,17 @@ struct Resource {
|
||||
SpriteJSON
|
||||
};
|
||||
|
||||
Resource(Kind kind_, const std::string& url_)
|
||||
: kind(kind_),
|
||||
url(url_) {
|
||||
}
|
||||
|
||||
const Kind kind;
|
||||
const std::string url;
|
||||
|
||||
inline bool operator==(const Resource &res) const {
|
||||
return kind == res.kind && url == res.url;
|
||||
}
|
||||
|
||||
struct Hash {
|
||||
std::size_t operator()(Resource const& r) const {
|
||||
return std::hash<std::string>()(r.url) ^ (std::hash<uint8_t>()(r.kind) << 1);
|
||||
}
|
||||
};
|
||||
|
||||
optional<SystemTimePoint> priorModified;
|
||||
optional<SystemTimePoint> priorExpires;
|
||||
optional<std::string> priorEtag;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
// This is set to true for 304 Not Modified responses.
|
||||
bool notModified = false;
|
||||
|
||||
// The actual data of the response. This is guaranteed to never be empty.
|
||||
// The actual data of the response. This is null if notModified is true.
|
||||
std::shared_ptr<const std::string> data;
|
||||
|
||||
optional<SystemTimePoint> modified;
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
class Response::Error {
|
||||
public:
|
||||
enum class Reason : uint8_t {
|
||||
// Success = 1, // Reserve 1 for Success.
|
||||
Success = 1,
|
||||
NotFound = 2,
|
||||
Server = 3,
|
||||
Connection = 4,
|
||||
|
||||
Reference in New Issue
Block a user