diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-06-21 17:39:29 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-06-26 16:32:21 +0300 |
commit | ea34cb5725815dbb5075205b01407a00329a3542 (patch) | |
tree | 43f6eb33f444eaa4420a99a1bb93ab17e711af8e /include | |
parent | 515ffa975d027c7c1479b2d0211e798c25148d60 (diff) | |
download | qtlocation-mapboxgl-ea34cb5725815dbb5075205b01407a00329a3542.tar.gz |
[core] Use the ResourceTransform instead of callbacks
Based on the actor model, can be considered safer to use since
we don't need to worry about object lifetime anymore.
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/storage/default_file_source.hpp | 6 | ||||
-rw-r--r-- | include/mbgl/storage/online_file_source.hpp | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/include/mbgl/storage/default_file_source.hpp b/include/mbgl/storage/default_file_source.hpp index 556a8df586..9911e0ce67 100644 --- a/include/mbgl/storage/default_file_source.hpp +++ b/include/mbgl/storage/default_file_source.hpp @@ -1,8 +1,10 @@ #pragma once +#include <mbgl/actor/actor_ref.hpp> #include <mbgl/storage/file_source.hpp> #include <mbgl/storage/offline.hpp> #include <mbgl/util/constants.hpp> +#include <mbgl/util/optional.hpp> #include <vector> #include <mutex> @@ -13,6 +15,8 @@ namespace util { template <typename T> class Thread; } // namespace util +class ResourceTransform; + class DefaultFileSource : public FileSource { public: /* @@ -40,7 +44,7 @@ public: void setAccessToken(const std::string&); std::string getAccessToken(); - void setResourceTransform(std::function<std::string(Resource::Kind, std::string&&)>); + void setResourceTransform(optional<ActorRef<ResourceTransform>>&&); std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override; diff --git a/include/mbgl/storage/online_file_source.hpp b/include/mbgl/storage/online_file_source.hpp index 51cfc5a2a1..ffd75662e6 100644 --- a/include/mbgl/storage/online_file_source.hpp +++ b/include/mbgl/storage/online_file_source.hpp @@ -1,10 +1,14 @@ #pragma once +#include <mbgl/actor/actor_ref.hpp> #include <mbgl/storage/file_source.hpp> #include <mbgl/util/constants.hpp> +#include <mbgl/util/optional.hpp> namespace mbgl { +class ResourceTransform; + class OnlineFileSource : public FileSource { public: OnlineFileSource(); @@ -16,9 +20,7 @@ public: void setAccessToken(const std::string& t) { accessToken = t; } std::string getAccessToken() const { return accessToken; } - using ResourceTransform = - std::function<std::unique_ptr<AsyncRequest>(Resource::Kind, std::string&&, std::function<void(std::string&&)>)>; - void setResourceTransform(ResourceTransform&& cb); + void setResourceTransform(optional<ActorRef<ResourceTransform>>&&); std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override; |