|
1 | | -#import "SentryQueueableRequestManager.h" |
2 | | -#import "SentryLog.h" |
3 | | -#import "SentryRequestOperation.h" |
4 | | - |
5 | | -NS_ASSUME_NONNULL_BEGIN |
6 | | - |
7 | | -@interface SentryQueueableRequestManager () |
8 | | - |
9 | | -@property (nonatomic, strong) NSOperationQueue *queue; |
10 | | -@property (nonatomic, strong) NSURLSession *session; |
11 | | - |
12 | | -@end |
13 | | - |
14 | | -@implementation SentryQueueableRequestManager |
15 | | - |
16 | | -- (instancetype)initWithSession:(NSURLSession *)session |
17 | | -{ |
18 | | - self = [super init]; |
19 | | - if (self) { |
20 | | - self.session = session; |
21 | | - self.queue = [[NSOperationQueue alloc] init]; |
22 | | - self.queue.name = @"io.sentry.QueueableRequestManager.OperationQueue"; |
23 | | - self.queue.maxConcurrentOperationCount = 3; |
24 | | - } |
25 | | - return self; |
26 | | -} |
27 | | - |
28 | | -- (BOOL)isReady |
29 | | -{ |
30 | | -#if SENTRY_TEST || SENTRY_TEST_CI |
31 | | - // force every envelope to be cached in UI tests so we can inspect what the SDK would've sent |
32 | | - // for a given operation |
33 | | - if ([NSProcessInfo.processInfo.environment[@"--io.sentry.sdk-environment"] |
34 | | - isEqualToString:@"ui-tests"]) { |
35 | | - return NO; |
36 | | - } |
37 | | -#elif DEBUG |
38 | | - if ([NSProcessInfo.processInfo.arguments |
39 | | - containsObject:@"--io.sentry.disable-http-transport"]) { |
40 | | - return NO; |
41 | | - } |
42 | | -#endif // SENTRY_TEST || SENTRY_TEST_CI |
43 | | - |
44 | | - // We always have at least one operation in the queue when calling this |
45 | | - return self.queue.operationCount <= 1; |
46 | | -} |
47 | | - |
48 | | -- (void)addRequest:(NSURLRequest *)request |
49 | | - completionHandler:(_Nullable SentryRequestOperationFinished)completionHandler |
50 | | -{ |
51 | | - SentryRequestOperation *operation = [[SentryRequestOperation alloc] |
52 | | - initWithSession:self.session |
53 | | - request:request |
54 | | - completionHandler:^(NSHTTPURLResponse *_Nullable response, NSError *_Nullable error) { |
55 | | - SENTRY_LOG_DEBUG(@"Queued requests: %@", @(self.queue.operationCount - 1)); |
56 | | - if (completionHandler) { |
57 | | - completionHandler(response, error); |
58 | | - } |
59 | | - }]; |
60 | | - [self.queue addOperation:operation]; |
61 | | -} |
62 | | - |
63 | | -@end |
64 | | - |
65 | | -NS_ASSUME_NONNULL_END |
| 1 | +// #import "SentryQueueableRequestManager.h" |
| 2 | +// #import "SentryLog.h" |
| 3 | +// #import "SentryRequestOperation.h" |
| 4 | +// |
| 5 | +// NS_ASSUME_NONNULL_BEGIN |
| 6 | +// |
| 7 | +//@interface SentryQueueableRequestManager () |
| 8 | +// |
| 9 | +//@property (nonatomic, strong) NSOperationQueue *queue; |
| 10 | +//@property (nonatomic, strong) NSURLSession *session; |
| 11 | +// |
| 12 | +//@end |
| 13 | +// |
| 14 | +//@implementation SentryQueueableRequestManager |
| 15 | +// |
| 16 | +//- (instancetype)initWithSession:(NSURLSession *)session |
| 17 | +//{ |
| 18 | +// self = [super init]; |
| 19 | +// if (self) { |
| 20 | +// self.session = session; |
| 21 | +// self.queue = [[NSOperationQueue alloc] init]; |
| 22 | +// self.queue.name = @"io.sentry.QueueableRequestManager.OperationQueue"; |
| 23 | +// self.queue.maxConcurrentOperationCount = 3; |
| 24 | +// } |
| 25 | +// return self; |
| 26 | +// } |
| 27 | +// |
| 28 | +//- (BOOL)isReady |
| 29 | +//{ |
| 30 | +// #if SENTRY_TEST || SENTRY_TEST_CI |
| 31 | +// // force every envelope to be cached in UI tests so we can inspect what the SDK would've sent |
| 32 | +// // for a given operation |
| 33 | +// if ([NSProcessInfo.processInfo.environment[@"--io.sentry.sdk-environment"] |
| 34 | +// isEqualToString:@"ui-tests"]) { |
| 35 | +// return NO; |
| 36 | +// } |
| 37 | +// #elif DEBUG |
| 38 | +// if ([NSProcessInfo.processInfo.arguments |
| 39 | +// containsObject:@"--io.sentry.disable-http-transport"]) { |
| 40 | +// return NO; |
| 41 | +// } |
| 42 | +// #endif // SENTRY_TEST || SENTRY_TEST_CI |
| 43 | +// |
| 44 | +// // We always have at least one operation in the queue when calling this |
| 45 | +// return self.queue.operationCount <= 1; |
| 46 | +// } |
| 47 | +// |
| 48 | +//- (void)addRequest:(NSURLRequest *)request |
| 49 | +// completionHandler:(_Nullable SentryRequestOperationFinished)completionHandler |
| 50 | +//{ |
| 51 | +// SentryRequestOperation *operation = [[SentryRequestOperation alloc] |
| 52 | +// initWithSession:self.session |
| 53 | +// request:request |
| 54 | +// completionHandler:^(NSHTTPURLResponse *_Nullable response, NSError *_Nullable error) { |
| 55 | +// SENTRY_LOG_DEBUG(@"Queued requests: %@", @(self.queue.operationCount - 1)); |
| 56 | +// if (completionHandler) { |
| 57 | +// completionHandler(response, error); |
| 58 | +// } |
| 59 | +// }]; |
| 60 | +// [self.queue addOperation:operation]; |
| 61 | +// } |
| 62 | +// |
| 63 | +//@end |
| 64 | +// |
| 65 | +// NS_ASSUME_NONNULL_END |
0 commit comments