Showing
1 changed file
with
9 additions
and
2 deletions
| @@ -73,6 +73,8 @@ unsigned long const ASIWWANBandwidthThrottleAmount = 14800; | @@ -73,6 +73,8 @@ unsigned long const ASIWWANBandwidthThrottleAmount = 14800; | ||
| 73 | // It will be set to NO when throttling was turned on with setShouldThrottleBandwidthForWWAN, but a WI-FI connection is active | 73 | // It will be set to NO when throttling was turned on with setShouldThrottleBandwidthForWWAN, but a WI-FI connection is active |
| 74 | BOOL isBandwidthThrottled = NO; | 74 | BOOL isBandwidthThrottled = NO; |
| 75 | 75 | ||
| 76 | +BOOL shouldThrottleBandwithForWWANOnly = NO; | ||
| 77 | + | ||
| 76 | static NSLock *sessionCookiesLock = nil; | 78 | static NSLock *sessionCookiesLock = nil; |
| 77 | 79 | ||
| 78 | // Private stuff | 80 | // Private stuff |
| @@ -2328,7 +2330,8 @@ static NSLock *sessionCookiesLock = nil; | @@ -2328,7 +2330,8 @@ static NSLock *sessionCookiesLock = nil; | ||
| 2328 | { | 2330 | { |
| 2329 | #if TARGET_OS_IPHONE | 2331 | #if TARGET_OS_IPHONE |
| 2330 | [bandwidthThrottlingLock lock]; | 2332 | [bandwidthThrottlingLock lock]; |
| 2331 | - BOOL throttle = isBandwidthThrottled; | 2333 | + |
| 2334 | + BOOL throttle = isBandwidthThrottled || (!shouldThrottleBandwithForWWANOnly && (maxBandwidthPerSecond)); | ||
| 2332 | [bandwidthThrottlingLock unlock]; | 2335 | [bandwidthThrottlingLock unlock]; |
| 2333 | return throttle; | 2336 | return throttle; |
| 2334 | #else | 2337 | #else |
| @@ -2432,12 +2435,16 @@ static NSLock *sessionCookiesLock = nil; | @@ -2432,12 +2435,16 @@ static NSLock *sessionCookiesLock = nil; | ||
| 2432 | } else { | 2435 | } else { |
| 2433 | [[NSNotificationCenter defaultCenter] removeObserver:self name:@"kNetworkReachabilityChangedNotification" object:nil]; | 2436 | [[NSNotificationCenter defaultCenter] removeObserver:self name:@"kNetworkReachabilityChangedNotification" object:nil]; |
| 2434 | [ASIHTTPRequest setMaxBandwidthPerSecond:0]; | 2437 | [ASIHTTPRequest setMaxBandwidthPerSecond:0]; |
| 2438 | + [bandwidthThrottlingLock lock]; | ||
| 2439 | + shouldThrottleBandwithForWWANOnly = NO; | ||
| 2440 | + [bandwidthThrottlingLock unlock]; | ||
| 2435 | } | 2441 | } |
| 2436 | } | 2442 | } |
| 2437 | 2443 | ||
| 2438 | + (void)throttleBandwidthForWWANUsingLimit:(unsigned long)limit | 2444 | + (void)throttleBandwidthForWWANUsingLimit:(unsigned long)limit |
| 2439 | { | 2445 | { |
| 2440 | - [bandwidthThrottlingLock lock]; | 2446 | + [bandwidthThrottlingLock lock]; |
| 2447 | + shouldThrottleBandwithForWWANOnly = YES; | ||
| 2441 | maxBandwidthPerSecond = limit; | 2448 | maxBandwidthPerSecond = limit; |
| 2442 | [[Reachability sharedReachability] setNetworkStatusNotificationsEnabled:YES]; | 2449 | [[Reachability sharedReachability] setNetworkStatusNotificationsEnabled:YES]; |
| 2443 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:@"kNetworkReachabilityChangedNotification" object:nil]; | 2450 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:@"kNetworkReachabilityChangedNotification" object:nil]; |
-
Please register or login to post a comment