summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-08-22 18:50:09 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-09-24 16:12:02 +0200
commit34fe7dc627f08d57ac259c383e248ddf2f6fb0d3 (patch)
treedddbde6891826329f92922409fbed6964d5e4e7e /include
parentee3e0827a20492ba0f91c5c5f60cf24b2e49cb32 (diff)
downloadqtlocation-mapboxgl-34fe7dc627f08d57ac259c383e248ddf2f6fb0d3.tar.gz
add basic request caching with sqlite
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/platform/event.hpp2
-rw-r--r--include/mbgl/util/filesource.hpp15
2 files changed, 16 insertions, 1 deletions
diff --git a/include/mbgl/platform/event.hpp b/include/mbgl/platform/event.hpp
index 1676f40d2c..d2a06618a3 100644
--- a/include/mbgl/platform/event.hpp
+++ b/include/mbgl/platform/event.hpp
@@ -29,6 +29,7 @@ enum class Event : uint8_t {
ParseStyle,
ParseTile,
Render,
+ Database,
HttpRequest,
Sprite,
};
@@ -40,6 +41,7 @@ MBGL_DEFINE_ENUM_CLASS(EventClass, Event, {
{ Event::ParseStyle, "ParseStyle" },
{ Event::ParseTile, "ParseTile" },
{ Event::Render, "Render" },
+ { Event::Database, "Database" },
{ Event::HttpRequest, "HttpRequest" },
{ Event::Sprite, "Sprite" },
{ Event(-1), "Unknown" },
diff --git a/include/mbgl/util/filesource.hpp b/include/mbgl/util/filesource.hpp
index 18c63ddfeb..bc0a2927de 100644
--- a/include/mbgl/util/filesource.hpp
+++ b/include/mbgl/util/filesource.hpp
@@ -2,11 +2,15 @@
#define MBGL_UTIL_FILESOURCE
#include <mbgl/util/uv.hpp>
+#include <mbgl/util/noncopyable.hpp>
#include <string>
#include <memory>
#include <functional>
+typedef struct sqlite3 sqlite3;
+typedef struct sqlite3_stmt sqlite3_stmt;
+
namespace mbgl {
namespace platform {
@@ -21,9 +25,10 @@ enum class ResourceType : uint8_t {
JSON
};
-class FileSource {
+class FileSource : private util::noncopyable, public std::enable_shared_from_this<FileSource> {
public:
FileSource();
+ ~FileSource();
void setBase(const std::string &value);
const std::string &getBase() const;
@@ -31,11 +36,19 @@ public:
void load(ResourceType type, const std::string &url, std::function<void(platform::Response *)> callback, const std::shared_ptr<uv::loop> loop = nullptr);
private:
+ void closeDatabase();
+ void createSchema();
+ bool loadFile(const std::string &url, std::function<void(platform::Response *)> callback);
+ void saveFile(const std::string &url, platform::Response *res);
+
+private:
// Stores a URL that is used as a base for loading resources with relative path.
std::string base;
// Stores the absolute path to the cache directory.
const std::string cache;
+
+ sqlite3 *db = nullptr;
};
}