From 1456b5b94a4eec32e9aa6a1727097933de64920a Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Tue, 16 Jun 2015 16:40:21 +0300 Subject: [PATCH] [alohalytics][ios] Reduced HTTP timeout to gracefully finish while in background fetch. --- 3party/Alohalytics/src/apple/http_client_apple.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/3party/Alohalytics/src/apple/http_client_apple.mm b/3party/Alohalytics/src/apple/http_client_apple.mm index 9ab61eba1c..fb6fd5e00e 100644 --- a/3party/Alohalytics/src/apple/http_client_apple.mm +++ b/3party/Alohalytics/src/apple/http_client_apple.mm @@ -44,16 +44,17 @@ extern NSString * gBrowserUserAgent; #include "../http_client.h" #include "../logger.h" -#define TIMEOUT_IN_SECONDS 30.0 - namespace alohalytics { +// If we try to upload our data from the background fetch handler on iOS, we have ~30 seconds to do that gracefully. +static const double kTimeoutInSeconds = 24.0; + bool HTTPClientPlatformWrapper::RunHTTPRequest() { @autoreleasepool { NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:[NSString stringWithUTF8String:url_requested_.c_str()]] - cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:TIMEOUT_IN_SECONDS]; + cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:kTimeoutInSeconds]; request.HTTPMethod = [NSString stringWithUTF8String:http_method_.c_str()]; if (!content_type_.empty()) {