summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-03-09 08:36:41 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-03-10 17:08:58 -0800
commit68ba0712f758d774d544e2bdd05af9ff780583da (patch)
tree17d0bf5b2eb5400aeb8878645d64006cf3bb3266
parentc335847451a850dfcac8c3ea262f4d686115e146 (diff)
downloadqtlocation-mapboxgl-68ba0712f758d774d544e2bdd05af9ff780583da.tar.gz
[ios, osx] Privatized offline region observer
-rw-r--r--platform/darwin/src/MGLOfflineTask.mm21
-rw-r--r--platform/darwin/src/MGLOfflineTask_Private.h15
2 files changed, 15 insertions, 21 deletions
diff --git a/platform/darwin/src/MGLOfflineTask.mm b/platform/darwin/src/MGLOfflineTask.mm
index d57ae66056..a78df6a241 100644
--- a/platform/darwin/src/MGLOfflineTask.mm
+++ b/platform/darwin/src/MGLOfflineTask.mm
@@ -18,12 +18,21 @@
} \
} while (NO);
-class MBGLOfflineRegionObserver;
+class MBGLOfflineRegionObserver : public mbgl::OfflineRegionObserver {
+public:
+ MBGLOfflineRegionObserver(MGLOfflineTask *offlineTask_) : offlineTask(offlineTask_) {}
+
+ void statusChanged(mbgl::OfflineRegionStatus status) override;
+ void responseError(mbgl::Response::Error error) override;
+ void mapboxTileCountLimitExceeded(uint64_t limit) override;
+
+private:
+ __weak MGLOfflineTask *offlineTask = nullptr;
+};
@interface MGLOfflineTask ()
@property (nonatomic, readwrite) mbgl::OfflineRegion *mbglOfflineRegion;
-@property (nonatomic, readwrite) MBGLOfflineRegionObserver *mbglOfflineRegionObserver;
@property (nonatomic, readwrite) MGLOfflineTaskState state;
@property (nonatomic, readwrite) MGLOfflineTaskProgress progress;
@@ -43,17 +52,17 @@ class MBGLOfflineRegionObserver;
if (self = [super init]) {
_mbglOfflineRegion = region;
_state = MGLOfflineTaskStateInactive;
- _mbglOfflineRegionObserver = new MBGLOfflineRegionObserver(self);
mbgl::DefaultFileSource *mbglFileSource = [[MGLOfflineStorage sharedOfflineStorage] mbglFileSource];
- mbglFileSource->setOfflineRegionObserver(*_mbglOfflineRegion, std::make_unique<MBGLOfflineRegionObserver>(*_mbglOfflineRegionObserver));
+ MBGLOfflineRegionObserver *mbglObserver = new MBGLOfflineRegionObserver(self);
+ mbglFileSource->setOfflineRegionObserver(*_mbglOfflineRegion, std::make_unique<MBGLOfflineRegionObserver>(*mbglObserver));
}
return self;
}
- (void)dealloc {
- delete _mbglOfflineRegionObserver;
- _mbglOfflineRegionObserver = nullptr;
+ mbgl::DefaultFileSource *mbglFileSource = [[MGLOfflineStorage sharedOfflineStorage] mbglFileSource];
+ mbglFileSource->setOfflineRegionObserver(*_mbglOfflineRegion, nullptr);
}
- (id <MGLOfflineRegion>)region {
diff --git a/platform/darwin/src/MGLOfflineTask_Private.h b/platform/darwin/src/MGLOfflineTask_Private.h
index 0b630ff6ff..1c1ff59b84 100644
--- a/platform/darwin/src/MGLOfflineTask_Private.h
+++ b/platform/darwin/src/MGLOfflineTask_Private.h
@@ -2,27 +2,12 @@
#include <mbgl/storage/default_file_source.hpp>
-class MBGLOfflineRegionObserver;
-
@interface MGLOfflineTask (Private)
@property (nonatomic) mbgl::OfflineRegion *mbglOfflineRegion;
-@property (nonatomic, readonly) MBGLOfflineRegionObserver *mbglOfflineRegionObserver;
- (instancetype)initWithMBGLRegion:(mbgl::OfflineRegion *)region;
- (void)invalidate;
@end
-
-class MBGLOfflineRegionObserver : public mbgl::OfflineRegionObserver {
-public:
- MBGLOfflineRegionObserver(MGLOfflineTask *offlineTask_) : offlineTask(offlineTask_) {}
-
- void statusChanged(mbgl::OfflineRegionStatus status) override;
- void responseError(mbgl::Response::Error error) override;
- void mapboxTileCountLimitExceeded(uint64_t limit) override;
-
-private:
- __weak MGLOfflineTask *offlineTask = nullptr;
-};