summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmkiley <jordan.kiley@mapbox.com>2019-07-10 17:33:27 -0700
committerjmkiley <jordan.kiley@mapbox.com>2019-07-10 17:38:19 -0700
commit688ba57f1c128715b9a3137db7af95543cf3b292 (patch)
tree804266cdd4c30d0eb14e39047a14cc2cd3c4ec0d
parentf9c4b5b44288e33c25344217f3ec8bdf11ece1fb (diff)
downloadqtlocation-mapboxgl-688ba57f1c128715b9a3137db7af95543cf3b292.tar.gz
[ios] address feedback
-rw-r--r--platform/darwin/src/MGLOfflineStorage.mm50
1 files changed, 19 insertions, 31 deletions
diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm
index f7df2dc003..b1eab47f51 100644
--- a/platform/darwin/src/MGLOfflineStorage.mm
+++ b/platform/darwin/src/MGLOfflineStorage.mm
@@ -450,7 +450,6 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio
}
- (void)invalidatePack:(MGLOfflinePack *)pack withCompletionHandler:(void (^)(NSError * _Nullable))completion {
-
mbgl::OfflineRegion& region = *pack.mbglOfflineRegion;
NSError *error;
if (!pack.mbglOfflineRegion) {
@@ -460,11 +459,9 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio
_mbglFileSource->invalidateOfflineRegion(region, [&](std::exception_ptr exception) {
if (exception) {
- error = [NSError errorWithDomain:MGLErrorDomain
- code:-1
- userInfo:@{
- NSLocalizedDescriptionKey: @(mbgl::util::toString(exception).c_str()),
- }];
+ error = [NSError errorWithDomain:MGLErrorDomain code:-1 userInfo:@{
+ NSLocalizedDescriptionKey: @(mbgl::util::toString(exception).c_str()),
+ }];
}
});
if (completion) {
@@ -516,34 +513,29 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio
#pragma mark - Ambient Cache management
- (void)setMaximumAmbientCacheSize:(NSUInteger)cacheSize withCallback:(void (^)(NSError * _Nullable))completion {
-
_mbglFileSource->setMaximumAmbientCacheSize(cacheSize, [&, completion](std::exception_ptr exception) {
- if (!completion) { return; }
-
NSError *error;
if (exception) {
- error = [NSError errorWithDomain:MGLErrorDomain
- code:-1
- userInfo:@{
- NSLocalizedDescriptionKey: @(mbgl::util::toString(exception).c_str()),
- }
- ];
+ error = [NSError errorWithDomain:MGLErrorDomain code:-1 userInfo:@{
+ NSLocalizedDescriptionKey: @(mbgl::util::toString(exception).c_str()),
+ }];
+ }
+ if (!completion) {
+ dispatch_sync(dispatch_get_main_queue(), ^ {
+ completion(error);
+ });
}
- dispatch_sync(dispatch_get_main_queue(), ^ {
- completion(error);
- });
});
}
- (void)invalidateAmbientCacheWithCompletion:(void (^)(NSError *_Nullable))completion {
_mbglFileSource->invalidateAmbientCache([&, completion](std::exception_ptr exception){
-
NSError *error;
if (exception) {
// Convert std::exception_ptr to an NSError.
error = [NSError errorWithDomain:MGLErrorDomain code:-1 userInfo:@{
- NSLocalizedDescriptionKey: @(mbgl::util::toString(exception).c_str()),
- }];
+ NSLocalizedDescriptionKey: @(mbgl::util::toString(exception).c_str()),
+ }];
}
if (completion) {
dispatch_async(dispatch_get_main_queue(), ^ {
@@ -557,10 +549,9 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio
_mbglFileSource->clearAmbientCache([&, completion](std::exception_ptr exception){
NSError *error;
if (exception) {
- error = [NSError errorWithDomain:MGLErrorDomain
- code:-1 userInfo:@{
- NSLocalizedDescriptionKey: @(mbgl::util::toString(exception).c_str()),
- }];
+ error = [NSError errorWithDomain:MGLErrorDomain code:-1 userInfo:@{
+ NSLocalizedDescriptionKey: @(mbgl::util::toString(exception).c_str()),
+ }];
}
if (completion) {
dispatch_async(dispatch_get_main_queue(), [&, completion, error](void) {
@@ -571,15 +562,12 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio
}
- (void)resetDatabaseWithCompletionHandler:(void (^)(NSError *_Nullable error))completion {
- if (!completion) { return; };
-
_mbglFileSource->resetDatabase([&, completion](std::exception_ptr exception) {
NSError *error = nil;
if (exception) {
- error = [NSError errorWithDomain:MGLErrorDomain
- code:-1 userInfo:@{
- NSLocalizedDescriptionKey: @(mbgl::util::toString(exception).c_str()),
- }];
+ error = [NSError errorWithDomain:MGLErrorDomain code:-1 userInfo:@{
+ NSLocalizedDescriptionKey: @(mbgl::util::toString(exception).c_str()),
+ }];
}
if (completion) {
dispatch_async(dispatch_get_main_queue(), ^{