diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-01-06 18:01:31 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-01-08 12:31:13 -0800 |
commit | e7b0b31d58997ce0c849129d07a97cb0740beb7e (patch) | |
tree | e7c10e36551b81b40fbfb57e3dcc3da3fa55546f /src/mbgl/storage | |
parent | 0a8fef1f516a2d230c34980b31d8e46d891941e1 (diff) | |
download | qtlocation-mapboxgl-e7b0b31d58997ce0c849129d07a97cb0740beb7e.tar.gz |
[core] Privatize SQLiteCache
Diffstat (limited to 'src/mbgl/storage')
-rw-r--r-- | src/mbgl/storage/sqlite_cache.hpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/mbgl/storage/sqlite_cache.hpp b/src/mbgl/storage/sqlite_cache.hpp new file mode 100644 index 0000000000..6e79d44a33 --- /dev/null +++ b/src/mbgl/storage/sqlite_cache.hpp @@ -0,0 +1,44 @@ +#ifndef MBGL_STORAGE_DEFAULT_SQLITE_CACHE +#define MBGL_STORAGE_DEFAULT_SQLITE_CACHE + +#include <mbgl/storage/file_cache.hpp> + +#include <string> + +namespace mbgl { + +namespace util { +template <typename T> class Thread; +} // namespace util + +class SQLiteCache : public FileCache { +public: + SQLiteCache(const std::string &path = ":memory:"); + ~SQLiteCache() override; + + void setMaximumCacheSize(uint64_t size); + void setMaximumCacheEntrySize(uint64_t size); + + // FileCache API + std::unique_ptr<WorkRequest> get(const Resource &resource, Callback callback) override; + void put(const Resource &resource, std::shared_ptr<const Response> response, Hint hint) override; + + class Impl; + +private: + const std::unique_ptr<util::Thread<Impl>> thread; +}; + +class SharedSQLiteCache : util::noncopyable { +public: + static std::shared_ptr<SQLiteCache> get(const std::string &path = ":memory:"); + +private: + SharedSQLiteCache() {} + + static std::weak_ptr<SQLiteCache> masterPtr; +}; + +} // namespace mbgl + +#endif |