diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-09-24 16:09:26 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-09-24 16:19:47 +0200 |
commit | 992d9ff051ecd45f83160930c43c9d5a2da04048 (patch) | |
tree | b89bc59a887b336ddada4b5dd2d22a34eaa3b033 /include | |
parent | 0fc1f6686886e1122757d5cee17e401ece8178bb (diff) | |
download | qtlocation-mapboxgl-992d9ff051ecd45f83160930c43c9d5a2da04048.tar.gz |
add back CURL requesting
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/storage/http_request.hpp | 14 | ||||
-rw-r--r-- | include/mbgl/storage/http_request_baton.hpp | 38 |
2 files changed, 23 insertions, 29 deletions
diff --git a/include/mbgl/storage/http_request.hpp b/include/mbgl/storage/http_request.hpp index 61aed954f0..9edefcaaae 100644 --- a/include/mbgl/storage/http_request.hpp +++ b/include/mbgl/storage/http_request.hpp @@ -3,12 +3,14 @@ #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> typedef struct uv_loop_s uv_loop_t; +typedef struct uv_timer_s uv_timer_t; namespace mbgl { @@ -25,14 +27,22 @@ public: void cancel(); private: - void loadedCacheEntry(std::unique_ptr<Response> &&response); + void handleCacheResponse(std::unique_ptr<Response> &&response, uv_loop_t *loop); + void handleHTTPResponse(HTTPResponseType responseType, std::unique_ptr<Response> &&response, uv_loop_t *loop); + + void startRequest(uv_loop_t *loop); + + void removeCacheBaton(); + void removeHTTPBaton(); private: const unsigned long thread_id; CacheRequestBaton *cache_baton = nullptr; - HTTPRequestBaton *http_baton = nullptr; + util::ptr<HTTPRequestBaton> http_baton; + uv_timer_t *backoff_timer = nullptr; util::ptr<SQLiteStore> store; const ResourceType type; + uint8_t attempts = 0; friend struct HTTPRequestBaton; }; diff --git a/include/mbgl/storage/http_request_baton.hpp b/include/mbgl/storage/http_request_baton.hpp index b492ee0c75..279784ec25 100644 --- a/include/mbgl/storage/http_request_baton.hpp +++ b/include/mbgl/storage/http_request_baton.hpp @@ -2,11 +2,11 @@ #define MBGL_STORAGE_HTTP_REQUEST_BATON #include <mbgl/storage/response.hpp> +#include <mbgl/util/ptr.hpp> #include <string> typedef struct uv_async_s uv_async_t; -typedef struct uv_timer_s uv_timer_t; namespace mbgl { @@ -44,44 +44,28 @@ enum class HTTPResponseType : int8_t { }; struct HTTPRequestBaton { - HTTPRequestBaton(); + HTTPRequestBaton(const std::string &path); ~HTTPRequestBaton(); const unsigned long thread_id; + const std::string path; + HTTPRequest *request = nullptr; - std::string path; uv_async_t *async = nullptr; - uv_timer_t *timer = nullptr; + + HTTPResponseType type = HTTPResponseType::Unknown; std::unique_ptr<Response> response; + + // Implementation specific use. void *ptr = nullptr; - HTTPResponseType type = HTTPResponseType::Unknown; - uint8_t attempts = 0; // IMPLEMENT THESE 3 PLATFORM SPECIFIC FUNCTIONS: // Begin the HTTP request. Platform-specific implementation. - void start(); - - // This will be called so that the baton can release resources. It is expected that the ptr is - // null after this call. Platform-specific implementation. - void cleanup(); - - // This will be called to cancel the HTTP request (if possible). Platform-specific implementation. - void cancel(); - - - - // Called when the request should be canceled. This will call cancel() in turn. - void stop(); - - // After calling reset(), it is safe to call start() again on this baton object. - void reset(); - - // Will call start() after the specified timeout. - void retry(uint64_t delay); + static void start(const util::ptr<HTTPRequestBaton> &ptr); - // Will be - static void notify(uv_async_t *async); + // This will be called to stop/cancel the HTTP request (if possible). Platform-specific implementation. + static void stop(const util::ptr<HTTPRequestBaton> &ptr); }; } |