diff options
Diffstat (limited to 'platform/darwin/src/http_file_source.mm')
-rw-r--r-- | platform/darwin/src/http_file_source.mm | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/platform/darwin/src/http_file_source.mm b/platform/darwin/src/http_file_source.mm index dbf92aa462..6f68111203 100644 --- a/platform/darwin/src/http_file_source.mm +++ b/platform/darwin/src/http_file_source.mm @@ -8,12 +8,7 @@ #import <Foundation/Foundation.h> -#import "MGLLoggingConfiguration_Private.h" -#import "MGLNetworkConfiguration_Private.h" - -#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR -#import "MGLAccountManager_Private.h" -#endif +#include <mbgl/interface/native_apple_interface.h> #include <mutex> #include <chrono> @@ -88,14 +83,10 @@ class HTTPFileSource::Impl { public: Impl() { @autoreleasepool { - NSURLSessionConfiguration *sessionConfig = [MGLNetworkConfiguration sharedManager].sessionConfiguration; + NSURLSessionConfiguration *sessionConfig = MGLNativeNetworkManager.sharedManager.sessionConfiguration; session = [NSURLSession sessionWithConfiguration:sessionConfig]; userAgent = getUserAgent(); - -#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR - accountType = [[NSUserDefaults standardUserDefaults] integerForKey:MGLMapboxAccountTypeKey]; -#endif } } @@ -195,7 +186,7 @@ HTTPFileSource::HTTPFileSource() HTTPFileSource::~HTTPFileSource() = default; -MGL_EXPORT +MGL_APPLE_EXPORT BOOL isValidMapboxEndpoint(NSURL *url) { return ([url.host isEqualToString:@"mapbox.com"] || [url.host hasSuffix:@".mapbox.com"] || @@ -203,7 +194,7 @@ BOOL isValidMapboxEndpoint(NSURL *url) { [url.host hasSuffix:@".mapbox.cn"]); } -MGL_EXPORT +MGL_APPLE_EXPORT NSURL *resourceURLWithAccountType(const Resource& resource, NSInteger accountType) { NSURL *url = [NSURL URLWithString:@(resource.url.c_str())]; @@ -217,7 +208,7 @@ NSURL *resourceURLWithAccountType(const Resource& resource, NSInteger accountTyp [queryItems addObject:[NSURLQueryItem queryItemWithName:@"offline" value:@"true"]]; } else { // Only add SKU token to requests not tagged as "offline" usage. - [queryItems addObject:[NSURLQueryItem queryItemWithName:@"sku" value:MGLAccountManager.skuToken]]; + [queryItems addObject:[NSURLQueryItem queryItemWithName:@"sku" value:MGLNativeNetworkManager.sharedManager.skuToken]]; } if (components.queryItems) { @@ -239,7 +230,7 @@ std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource, @autoreleasepool { NSURL *url = resourceURLWithAccountType(resource, impl->accountType); - MGLLogDebug(@"Requesting URI: %@", url.relativePath); + [MGLNativeNetworkManager.sharedManager debugLog:@"Requesting URI: %@", url.relativePath]; NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; if (resource.priorEtag) { @@ -255,22 +246,22 @@ std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource, const bool isTile = resource.kind == mbgl::Resource::Kind::Tile; if (isTile) { - [[MGLNetworkConfiguration sharedManager] startDownloadEvent:url.relativePath type:@"tile"]; + [MGLNativeNetworkManager.sharedManager startDownloadEvent:url.relativePath type:@"tile"]; } request->task = [impl->session dataTaskWithRequest:req completionHandler:^(NSData* data, NSURLResponse* res, NSError* error) { if (error && [error code] == NSURLErrorCancelled) { - [[MGLNetworkConfiguration sharedManager] cancelDownloadEventForResponse:res]; + [MGLNativeNetworkManager.sharedManager cancelDownloadEventForResponse:res]; return; } - [[MGLNetworkConfiguration sharedManager] stopDownloadEventForResponse:res]; + [MGLNativeNetworkManager.sharedManager stopDownloadEventForResponse:res]; Response response; using Error = Response::Error; if (error) { - MGLLogError(@"Requesting: %@ failed with error: %@", res.URL.relativePath, error); + [MGLNativeNetworkManager.sharedManager errorLog:@"Requesting: %@ failed with error: %@", res.URL.relativePath, error]; if (data) { response.data = @@ -303,7 +294,7 @@ std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource, } } else if ([res isKindOfClass:[NSHTTPURLResponse class]]) { const long responseCode = [(NSHTTPURLResponse *)res statusCode]; - MGLLogDebug(@"Requesting %@ returned responseCode: %lu", res.URL.relativePath, responseCode); + [MGLNativeNetworkManager.sharedManager debugLog:@"Requesting %@ returned responseCode: %lu", res.URL.relativePath, responseCode]; NSDictionary *headers = [(NSHTTPURLResponse *)res allHeaderFields]; NSString *cache_control = [headers objectForKey:@"Cache-Control"]; |