[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:
John Firebaugh
2016-01-13 14:32:21 -08:00
parent 27134df2e4
commit a877b9b192
10 changed files with 134 additions and 192 deletions

View File

@@ -13,9 +13,7 @@ public:
static std::unique_ptr<HTTPContextBase> createContext();
virtual ~HTTPContextBase() = default;
virtual HTTPRequestBase* createRequest(const std::string& url,
HTTPRequestBase::Callback,
std::shared_ptr<const Response>) = 0;
virtual HTTPRequestBase* createRequest(const Resource&, HTTPRequestBase::Callback) = 0;
};
} // namespace mbgl

View File

@@ -1,14 +1,14 @@
#ifndef MBGL_STORAGE_HTTP_REQUEST_BASE
#define MBGL_STORAGE_HTTP_REQUEST_BASE
#include <mbgl/storage/response.hpp>
#include <mbgl/storage/resource.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/optional.hpp>
#include <memory>
#include <functional>
#include <utility>
#include <string>
namespace mbgl {
@@ -16,10 +16,10 @@ class Response;
class HTTPRequestBase : private util::noncopyable {
public:
using Callback = std::function<void (std::shared_ptr<const Response> response)>;
using Callback = std::function<void (Response)>;
HTTPRequestBase(const std::string& url_, Callback notify_)
: url(url_)
HTTPRequestBase(const Resource& resource_, Callback notify_)
: resource(resource_)
, notify(std::move(notify_))
, cancelled(false) {
}
@@ -30,7 +30,7 @@ public:
protected:
static optional<SystemTimePoint> parseCacheControl(const char *value);
std::string url;
Resource resource;
Callback notify;
bool cancelled;
};

View File

@@ -10,7 +10,7 @@
namespace mbgl {
struct Resource;
class Resource;
class Response;
class WorkRequest;