summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-04-07 18:04:23 +0200
committerKonstantin Käfer <mail@kkaefer.com>2015-04-07 18:04:23 +0200
commit7d58a41de5dbf1b24b8bad9a2a98c21a7bf75382 (patch)
tree1a5c75d39d6772346dbceb33129dfb5650d65ef6 /include
parentd424c09f038fdcd0a070e3d04684dc1511cd1732 (diff)
downloadqtlocation-mapboxgl-7d58a41de5dbf1b24b8bad9a2a98c21a7bf75382.tar.gz
make sqlite storage more resilient to sporadic errors
- catch SQLite exceptions and report them - failed statements are ignored, we're really just caching here, so if it fails we're handling it gracefully elsewhere - handle cases where the database file goes away after we opened it - handle cases where the schema wasn't created after the database file was opened successfully - add tests
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/platform/log.hpp4
-rw-r--r--include/mbgl/storage/default/sqlite_cache.hpp2
2 files changed, 5 insertions, 1 deletions
diff --git a/include/mbgl/platform/log.hpp b/include/mbgl/platform/log.hpp
index 5d287eb572..d6f3cd1ab4 100644
--- a/include/mbgl/platform/log.hpp
+++ b/include/mbgl/platform/log.hpp
@@ -4,6 +4,7 @@
#include <mbgl/platform/event.hpp>
#include <mbgl/util/std.hpp>
+#include <mbgl/util/noncopyable.hpp>
#include <memory>
#include <string>
@@ -12,7 +13,7 @@ namespace mbgl {
class Log {
public:
- class Observer {
+ class Observer : private util::noncopyable {
public:
virtual ~Observer() = default;
@@ -22,6 +23,7 @@ public:
};
static void setObserver(std::unique_ptr<Observer> Observer);
+ static std::unique_ptr<Observer> removeObserver();
private:
template <typename T, size_t N>
diff --git a/include/mbgl/storage/default/sqlite_cache.hpp b/include/mbgl/storage/default/sqlite_cache.hpp
index 8f2746561c..fe80a41b52 100644
--- a/include/mbgl/storage/default/sqlite_cache.hpp
+++ b/include/mbgl/storage/default/sqlite_cache.hpp
@@ -38,6 +38,7 @@ private:
void process(StopAction &action);
void createDatabase();
+ void createSchema();
const std::string path;
uv_loop_t *loop = nullptr;
@@ -45,6 +46,7 @@ private:
std::thread thread;
std::unique_ptr<::mapbox::sqlite::Database> db;
std::unique_ptr<::mapbox::sqlite::Statement> getStmt, putStmt, refreshStmt;
+ bool schema = false;
};
}