summaryrefslogtreecommitdiff
path: root/include/mbgl
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
parent52558acde88f6fe813f691758643cfe8b8aeae6e (diff)
downloadqtlocation-mapboxgl-4d5c6333be52aae4a9c72f4b01941e16ead503f4.tar.gz
[core] move retry logic to DefaultFileSource
Diffstat (limited to 'include/mbgl')
-rw-r--r--include/mbgl/storage/file_cache.hpp2
-rw-r--r--include/mbgl/storage/response.hpp37
2 files changed, 33 insertions, 6 deletions
diff --git a/include/mbgl/storage/file_cache.hpp b/include/mbgl/storage/file_cache.hpp
index a9071b1b67..b32bdf67e6 100644
--- a/include/mbgl/storage/file_cache.hpp
+++ b/include/mbgl/storage/file_cache.hpp
@@ -16,7 +16,7 @@ class FileCache : private util::noncopyable {
public:
virtual ~FileCache() = default;
- enum class Hint : uint8_t { Full, Refresh, No };
+ enum class Hint : bool { Full, Refresh };
using Callback = std::function<void(std::unique_ptr<Response>)>;
virtual std::unique_ptr<WorkRequest> get(const Resource &resource, Callback callback) = 0;
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