Files
MapLibreParticleLab/src/mbgl/storage/http_request_base.hpp
John Firebaugh a877b9b192 [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.
2016-01-22 18:42:53 -08:00

41 lines
907 B
C++

#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 <functional>
namespace mbgl {
class Response;
class HTTPRequestBase : private util::noncopyable {
public:
using Callback = std::function<void (Response)>;
HTTPRequestBase(const Resource& resource_, Callback notify_)
: resource(resource_)
, notify(std::move(notify_))
, cancelled(false) {
}
virtual ~HTTPRequestBase() = default;
virtual void cancel() { cancelled = true; };
protected:
static optional<SystemTimePoint> parseCacheControl(const char *value);
Resource resource;
Callback notify;
bool cancelled;
};
} // namespace mbgl
#endif // MBGL_STORAGE_HTTP_REQUEST_BASE