diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2019-09-17 14:34:47 -0700 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2019-10-07 15:22:01 -0700 |
commit | 0d59621876372068d4d1b375d7d52f24b59f3e78 (patch) | |
tree | 2cca2e35fdc0b73c1bec46d0aa61ad7781e50b45 | |
parent | 23cebe20fed0e3ebc3328c6345af4e32d86cfcf5 (diff) | |
download | qtlocation-mapboxgl-0d59621876372068d4d1b375d7d52f24b59f3e78.tar.gz |
[ios] Add a flag to pause network requests.
-rw-r--r-- | platform/darwin/src/MGLNetworkConfiguration.h | 8 | ||||
-rw-r--r-- | platform/darwin/src/http_file_source.mm | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLNetworkConfiguration.h b/platform/darwin/src/MGLNetworkConfiguration.h index 6c56050aae..91932c2d1d 100644 --- a/platform/darwin/src/MGLNetworkConfiguration.h +++ b/platform/darwin/src/MGLNetworkConfiguration.h @@ -32,6 +32,14 @@ MGL_EXPORT */ @property (atomic, strong, null_resettable) NSURLSessionConfiguration *sessionConfiguration; +/** +A Boolean value indicating whether the current `NSURLSessionConfiguration` stops +making network requests. + +The default value of this property is `NO`. +*/ +@property (atomic, assign) BOOL stopsRequests; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/http_file_source.mm b/platform/darwin/src/http_file_source.mm index b0f69f4a7f..09562e0347 100644 --- a/platform/darwin/src/http_file_source.mm +++ b/platform/darwin/src/http_file_source.mm @@ -229,6 +229,10 @@ NSURL *resourceURLWithAccountType(const Resource& resource, NSInteger accountTyp std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource, Callback callback) { auto request = std::make_unique<HTTPRequest>(callback); auto shared = request->shared; // Explicit copy so that it also gets copied into the completion handler block below. + + if ([MGLNetworkConfiguration sharedManager].stopsRequests) { + return std::move(request); + } @autoreleasepool { NSURL *url = resourceURLWithAccountType(resource, impl->accountType); |