From 4d5c6333be52aae4a9c72f4b01941e16ead503f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 2 Nov 2015 16:14:41 +0100 Subject: [core] move retry logic to DefaultFileSource --- include/mbgl/storage/response.hpp | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'include/mbgl/storage/response.hpp') diff --git a/include/mbgl/storage/response.hpp b/include/mbgl/storage/response.hpp index b5973457b5..8ab6170ba2 100644 --- a/include/mbgl/storage/response.hpp +++ b/include/mbgl/storage/response.hpp @@ -8,20 +8,47 @@ namespace mbgl { class Response { public: + Response() = default; + Response(const Response&); + Response& operator=(const Response&); + bool isExpired() const; public: - enum Status { Error, Successful, NotFound }; + class Error; + // When this object is empty, the response was successful. + std::unique_ptr error; - Status status = Error; + // Stale responses are fetched from cache and are expired. bool stale = false; - std::string message; + + // The actual data of the response. This is guaranteed to never be empty. + std::shared_ptr data; + int64_t modified = 0; int64_t expires = 0; std::string etag; - std::shared_ptr data; }; -} +class Response::Error { +public: + enum class Reason : uint8_t { + // Success = 1, // Reserve 1 for Success. + NotFound = 2, + Server = 3, + Connection = 4, + Canceled = 5, + Other = 6, + } reason = Reason::Other; + + // An error message from the request handler, e.g. a server message or a system message + // informing the user about the reason for the failure. + std::string message; + +public: + Error(Reason, const std::string& = ""); +}; + +} // namespace mbgl #endif -- cgit v1.2.1