blob: 7cc72101d570447fab30236968bcf0ec43cb26fa (
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
55
56
57
58
|
#ifndef MBGL_STORAGE_HTTP_REQUEST
#define MBGL_STORAGE_HTTP_REQUEST
#include <mbgl/storage/resource_type.hpp>
#include <mbgl/storage/base_request.hpp>
#include <mbgl/storage/http_request_baton.hpp>
#include <string>
#include <memory>
#include <cassert>
#include <thread>
typedef struct uv_loop_s uv_loop_t;
typedef struct uv_timer_s uv_timer_t;
namespace mbgl {
struct CacheRequestBaton;
struct HTTPRequestBaton;
struct CacheEntry;
class SQLiteStore;
class HTTPRequest : public BaseRequest {
public:
HTTPRequest(ResourceType type, const std::string &path, uv_loop_t *loop, util::ptr<SQLiteStore> store);
~HTTPRequest();
void cancel();
void retryImmediately();
private:
void startCacheRequest();
void handleCacheResponse(std::unique_ptr<Response> &&response);
void startHTTPRequest(std::unique_ptr<Response> &&res);
void handleHTTPResponse(HTTPResponseType responseType, std::unique_ptr<Response> &&response);
void retryHTTPRequest(std::unique_ptr<Response> &&res, uint64_t timeout);
void removeCacheBaton();
void removeHTTPBaton();
void removeBackoffTimer();
private:
const std::thread::id threadId;
uv_loop_t *const loop;
CacheRequestBaton *cacheBaton = nullptr;
util::ptr<HTTPRequestBaton> httpBaton;
uv_timer_t *backoffTimer = nullptr;
util::ptr<SQLiteStore> store;
const ResourceType type;
uint8_t attempts = 0;
friend struct HTTPRequestBaton;
};
}
#endif
|