diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-15 17:35:13 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-04-14 14:18:19 -0700 |
commit | 3af3e72bb3cb3f05b33be304d59e66cc244ef4d9 (patch) | |
tree | ef1d237c3083694307081c219c9da94ae43fe540 /src/mbgl/storage | |
parent | 6d88a23a60bc0a6dc9945bf09a659d15dd827192 (diff) | |
download | qtlocation-mapboxgl-3af3e72bb3cb3f05b33be304d59e66cc244ef4d9.tar.gz |
[all] Replace HTTPContextBase/HTTPRequestBase with FileSource
Diffstat (limited to 'src/mbgl/storage')
-rw-r--r-- | src/mbgl/storage/http_context_base.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/storage/http_context_base.hpp | 22 | ||||
-rw-r--r-- | src/mbgl/storage/http_file_source.hpp | 25 | ||||
-rw-r--r-- | src/mbgl/storage/http_request_base.cpp | 23 | ||||
-rw-r--r-- | src/mbgl/storage/http_request_base.hpp | 40 |
5 files changed, 25 insertions, 90 deletions
diff --git a/src/mbgl/storage/http_context_base.cpp b/src/mbgl/storage/http_context_base.cpp deleted file mode 100644 index c69e7a36ae..0000000000 --- a/src/mbgl/storage/http_context_base.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include <mbgl/storage/http_context_base.hpp> - -namespace mbgl { - -} // namespace mbgl diff --git a/src/mbgl/storage/http_context_base.hpp b/src/mbgl/storage/http_context_base.hpp deleted file mode 100644 index 6615ea00cf..0000000000 --- a/src/mbgl/storage/http_context_base.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef MBGL_STORAGE_HTTP_CONTEXT_BASE -#define MBGL_STORAGE_HTTP_CONTEXT_BASE - -#include <mbgl/storage/http_request_base.hpp> -#include <mbgl/storage/network_status.hpp> - -#include <set> - -namespace mbgl { - -class HTTPContextBase { -public: - static std::unique_ptr<HTTPContextBase> createContext(); - static uint32_t maximumConcurrentRequests(); - - virtual ~HTTPContextBase() = default; - virtual HTTPRequestBase* createRequest(const Resource&, HTTPRequestBase::Callback) = 0; -}; - -} // namespace mbgl - -#endif // MBGL_STORAGE_HTTP_CONTEXT_BASE diff --git a/src/mbgl/storage/http_file_source.hpp b/src/mbgl/storage/http_file_source.hpp new file mode 100644 index 0000000000..5e306dbfc5 --- /dev/null +++ b/src/mbgl/storage/http_file_source.hpp @@ -0,0 +1,25 @@ +#ifndef MBGL_STORAGE_HTTP_FILE_SOURCE +#define MBGL_STORAGE_HTTP_FILE_SOURCE + +#include <mbgl/storage/file_source.hpp> + +namespace mbgl { + +class HTTPFileSource : public FileSource { +public: + HTTPFileSource(); + ~HTTPFileSource() override; + + std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override; + + static uint32_t maximumConcurrentRequests(); + +private: + friend class HTTPRequest; + class Impl; + std::unique_ptr<Impl> impl; +}; + +} // namespace mbgl + +#endif // MBGL_STORAGE_HTTP_FILE_SOURCE diff --git a/src/mbgl/storage/http_request_base.cpp b/src/mbgl/storage/http_request_base.cpp deleted file mode 100644 index 81be716ff2..0000000000 --- a/src/mbgl/storage/http_request_base.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include <mbgl/storage/http_request_base.hpp> - -#include <mbgl/util/http_header.hpp> -#include <mbgl/util/chrono.hpp> - -namespace mbgl { - -optional<SystemTimePoint> HTTPRequestBase::parseCacheControl(const char *value) { - if (!value) { - return {}; - } - - const auto cacheControl = http::CacheControl::parse(value); - if (!cacheControl.maxAge) { - return {}; - } - - // Round trip through time_t to truncate fractional seconds. - return SystemClock::from_time_t(SystemClock::to_time_t( - SystemClock::now() + std::chrono::seconds(*cacheControl.maxAge))); -} - -} // namespace mbgl diff --git a/src/mbgl/storage/http_request_base.hpp b/src/mbgl/storage/http_request_base.hpp deleted file mode 100644 index 37a0b4d091..0000000000 --- a/src/mbgl/storage/http_request_base.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef MBGL_STORAGE_HTTP_REQUEST_BASE -#define MBGL_STORAGE_HTTP_REQUEST_BASE - -#include <mbgl/storage/response.hpp> -#include <mbgl/storage/resource.hpp> - -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/chrono.hpp> -#include <mbgl/util/optional.hpp> - -#include <functional> - -namespace mbgl { - -class Response; - -class HTTPRequestBase : private util::noncopyable { -public: - using Callback = std::function<void (Response)>; - - HTTPRequestBase(const Resource& resource_, Callback notify_) - : resource(resource_) - , notify(std::move(notify_)) - , cancelled(false) { - } - - virtual ~HTTPRequestBase() = default; - virtual void cancel() { cancelled = true; }; - -protected: - static optional<SystemTimePoint> parseCacheControl(const char *value); - - Resource resource; - Callback notify; - bool cancelled; -}; - -} // namespace mbgl - -#endif // MBGL_STORAGE_HTTP_REQUEST_BASE |