summaryrefslogtreecommitdiff
path: root/include/mbgl/storage
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-03-07 21:50:24 -0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-03-08 10:31:01 -0300
commitfa7c40c37fc2078b181f77afc808fdc4cd1baae9 (patch)
tree8b56eb1f406ca87153204aae6919f05ee188dd90 /include/mbgl/storage
parent20c3706536ac9e927f80a50e9ec8906dfd0d2baf (diff)
downloadqtlocation-mapboxgl-fa7c40c37fc2078b181f77afc808fdc4cd1baae9.tar.gz
[core] Add client defined network status
This API will let the client force a network status. If set to Offline, we won't make network requests. When set make to Online, it will trigger the pending requests and try to fetch tiles from the network.
Diffstat (limited to 'include/mbgl/storage')
-rw-r--r--include/mbgl/storage/network_status.hpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/mbgl/storage/network_status.hpp b/include/mbgl/storage/network_status.hpp
index 2a0ab78edd..4202793661 100644
--- a/include/mbgl/storage/network_status.hpp
+++ b/include/mbgl/storage/network_status.hpp
@@ -1,6 +1,7 @@
#ifndef MBGL_STORAGE_NETWORK_STATUS
#define MBGL_STORAGE_NETWORK_STATUS
+#include <atomic>
#include <mutex>
#include <set>
@@ -12,12 +13,21 @@ class AsyncTask;
class NetworkStatus {
public:
+ enum class Status : uint8_t {
+ Online,
+ Offline,
+ };
+
+ Status Get();
+ void Set(Status);
+
static void Reachable();
static void Subscribe(util::AsyncTask* async);
static void Unsubscribe(util::AsyncTask* async);
private:
+ static std::atomic<bool> online;
static std::mutex mtx;
static std::set<util::AsyncTask*> observers;
};