summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbgl/map/map.hpp3
-rw-r--r--include/mbgl/storage/caching_http_file_source.hpp3
-rw-r--r--include/mbgl/storage/file_source.hpp1
m---------ios/mapbox-gl-cocoa0
-rw-r--r--macosx/main.mm4
-rw-r--r--src/mbgl/map/map.cpp9
-rw-r--r--src/mbgl/storage/caching_http_file_source.cpp19
7 files changed, 14 insertions, 25 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 3a50a70136..08f4ca5647 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -122,9 +122,6 @@ public:
void toggleDebug();
bool getDebug() const;
- // Call this when the network reachability changed.
- void setReachability(bool status);
-
inline const TransformState &getState() const { return state; }
inline timestamp getTime() const { return animationTime; }
diff --git a/include/mbgl/storage/caching_http_file_source.hpp b/include/mbgl/storage/caching_http_file_source.hpp
index 08fd5b50cb..403db31838 100644
--- a/include/mbgl/storage/caching_http_file_source.hpp
+++ b/include/mbgl/storage/caching_http_file_source.hpp
@@ -30,7 +30,8 @@ public:
void prepare(std::function<void()> fn);
- void retryAllPending();
+ // Call this when the network status reachability changed.
+ void setReachability(bool reachable);
private:
std::thread::id thread_id;
diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp
index accdc3c499..c8f6217877 100644
--- a/include/mbgl/storage/file_source.hpp
+++ b/include/mbgl/storage/file_source.hpp
@@ -21,7 +21,6 @@ public:
virtual void setBase(const std::string &value) = 0;
virtual std::unique_ptr<Request> request(ResourceType type, const std::string &url) = 0;
virtual void prepare(std::function<void()> fn) = 0;
- virtual void retryAllPending() = 0;
};
}
diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa
-Subproject 7e16edebf067c4195c98cb050f08ef85c690078
+Subproject cf7436759fb39a9a28ce13aa1ba897d2c884103
diff --git a/macosx/main.mm b/macosx/main.mm
index 77305a3259..ca1a212551 100644
--- a/macosx/main.mm
+++ b/macosx/main.mm
@@ -76,7 +76,7 @@ int main() {
GLFWView view;
mbgl::CachingHTTPFileSource fileSource(mbgl::platform::defaultCacheDatabase());
mbgl::Map map(view, fileSource);
- mbgl::Map *map_ptr = &map;
+ mbgl::CachingHTTPFileSource *fileSourcePtr = &fileSource;
URLHandler *handler = [[URLHandler alloc] init];
[handler setMap:&map];
@@ -86,7 +86,7 @@ int main() {
// Notify map object when network reachability status changes.
Reachability* reachability = [Reachability reachabilityForInternetConnection];
reachability.reachableBlock = ^(Reachability *) {
- map_ptr->setReachability(true);
+ fileSourcePtr->setReachability(true);
};
[reachability startNotifier];
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 5be29d7543..1a45284757 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -286,15 +286,6 @@ void Map::terminate() {
painter->terminate();
}
-void Map::setReachability(bool reachable) {
- // Note: This function may be called from *any* thread.
- if (reachable) {
- fileSource.prepare([&]() {
- fileSource.retryAllPending();
- });
- }
-}
-
#pragma mark - Setup
void Map::setup() {
diff --git a/src/mbgl/storage/caching_http_file_source.cpp b/src/mbgl/storage/caching_http_file_source.cpp
index 70254b68da..64582ba5d4 100644
--- a/src/mbgl/storage/caching_http_file_source.cpp
+++ b/src/mbgl/storage/caching_http_file_source.cpp
@@ -100,16 +100,17 @@ void CachingHTTPFileSource::prepare(std::function<void()> fn) {
}
}
-void CachingHTTPFileSource::retryAllPending() {
- assert(thread_id == std::this_thread::get_id());
-
- util::ptr<BaseRequest> req;
- for (const std::pair<std::string, std::weak_ptr<BaseRequest>> &pair : pending) {
- if ((req = pair.second.lock())) {
- req->retryImmediately();
- }
+void CachingHTTPFileSource::setReachability(bool reachable) {
+ if (reachable && loop) {
+ prepare([this]() {
+ util::ptr<BaseRequest> req;
+ for (const std::pair<std::string, std::weak_ptr<BaseRequest>> &pair : pending) {
+ if ((req = pair.second.lock())) {
+ req->retryImmediately();
+ }
+ }
+ });
}
-
}
}