summaryrefslogtreecommitdiff
path: root/include/mbgl/storage/response.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-11-02 16:14:41 +0100
committerKonstantin Käfer <mail@kkaefer.com>2015-11-02 17:24:40 +0100
commit4d5c6333be52aae4a9c72f4b01941e16ead503f4 (patch)
tree1d6e34faf4184e3ed8a14dc2be9352a8836bc78b /include/mbgl/storage/response.hpp
parent52558acde88f6fe813f691758643cfe8b8aeae6e (diff)
downloadqtlocation-mapboxgl-4d5c6333be52aae4a9c72f4b01941e16ead503f4.tar.gz
[core] move retry logic to DefaultFileSource
Diffstat (limited to 'include/mbgl/storage/response.hpp')
-rw-r--r--include/mbgl/storage/response.hpp37
1 files changed, 32 insertions, 5 deletions
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<const Error> 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<const std::string> data;
+
int64_t modified = 0;
int64_t expires = 0;
std::string etag;
- std::shared_ptr<const std::string> 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