blob: 8ab6170ba2e53eee3255db340b891b87e4f2e111 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#ifndef MBGL_STORAGE_RESPONSE
#define MBGL_STORAGE_RESPONSE
#include <string>
#include <memory>
namespace mbgl {
class Response {
public:
Response() = default;
Response(const Response&);
Response& operator=(const Response&);
bool isExpired() const;
public:
class Error;
// When this object is empty, the response was successful.
std::unique_ptr<const Error> error;
// Stale responses are fetched from cache and are expired.
bool stale = false;
// 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;
};
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
|